Ok, thanks all three of you! Very Happy

Sam, I saw your message in SAX and the 85 supports calling programs as subroutines (I actually make heavy use of that here). So do you think I should turn some of what would be looped into their own subprograms to make program flow easier and make it so I don't have to use nested loops as much? How would you recommend I go about doing that? Smile
You might start by considering each box in your flow chart that you posted earlier as a potential subprogram. For instance, the player attack phase could be in a subprogram and the enemy attack code could be in its own subprogram. Also, getting user input for a particular action is a good candidate for a subprogram if it involves more than a few lines of code.

As far as optimizations, one thing off the top of my head is that you can save a couple of bytes by removing the fourth argument from the For() loop: You don't have to specify it if you're incrementing by 1 since that's the default.
Travis wrote:
You might start by considering each box in your flow chart that you posted earlier as a potential subprogram. For instance, the player attack phase could be in a subprogram and the enemy attack code could be in its own subprogram. Also, getting user input for a particular action is a good candidate for a subprogram if it involves more than a few lines of code.

As far as optimizations, one thing off the top of my head is that you can save a couple of bytes by removing the fourth argument from the For() loop: You don't have to specify it if you're incrementing by 1 since that's the default.


Ok, thanks! I'll do that! Very Happy
For instance, it looks like you have two sets of code each for “player attacks” and “enemy attacks” where the code is very similar except for a couple of differences. You could consolidate each into a single subprogram and just use a variable to account for the differences (in damage calculated and locations in the list to store, if I'm reading it correctly). That would save space and potentially make the program easier to understand. And as Jeffitus said, on all the places where you have If:Then:…:End with only one instruction to execute, you can simply remove the Then and End.
Travis wrote:
For instance, it looks like you have two sets of code each for “player attacks” and “enemy attacks” where the code is very similar except for a couple of differences. You could consolidate each into a single subprogram and just use a variable to account for the differences (in damage calculated and locations in the list to store, if I'm reading it correctly). That would save space and potentially make the program easier to understand. And as Jeffitus said, on all the places where you have If:Then:…:End with only one instruction to execute, you can simply remove the Then and End.


Awesome! Thanks for the help and tips Very Happy

EDIT: Here's where I am:

I've optimized the code like this:
Main Program:

Code:
:{20,10,10,15,2,2}üENEMDAT1
:{20,10,10,15,2,2}üENEMDAT2
:{20,10,10,15,2,2}üENEMDAT3
:{25,5,5,10,0,0}üENEMDAT4
:{30,5,5,10,0,0}üENEMDAT5
:ClLCD
:Disp "CHAPTER 1"
:Disp "As you walk down the"
:Disp "hallway you spot a"
:Disp "grouping of hostile"
:Disp "looking monsters."
:Disp "Press ENTER"
:Pause
:For(R,1,5)
:1+int(5rand)üD
:If D == 1
:Then
:ENEMDAT1üENEMYDAT
:If D == 2
:Then
:ENEMDAT2üENEMYDAT
:If D == 3
:Then
:ENEMDAT3üENEMYDAT
:If D == 4
:Then
:ENEMDAT4üENEMYDAT
:If D == 5
:Then
:ENEMDAT5üENEMYDAT
:While SAVEDATA(3)>0  and ENEMYDAT(3)>0
:ClLCD
:Disp "CHAPTER 1"
:Outpt(3,1,"ENEMY:")
:Outpt(3,7,ENEMYDAT(3))
:Outpt(4,1,"YOU:")
:Outpt(4,5,SAVEDATA(3))
:Outpt(5,1,"AC:")
:Outpt(5,4,ARMDATA(1))
:Outpt(6,1,"Melee:")
:Outpt(6,7,ARMDATA(3))
:Outpt(7,1,"Ranged:")
:Outpt(7,8,ARMDATA(5))
:If SAVEDATA(1) ù ENEMYDAT(1)
:Then
:Menu(1,"Melee",MELA,2,"Ranged",RANA)
:Lbl MELA
:ARMDATA(3)üARMTEMP
:PLAYERTN
:ENEMYTN
:Lbl RANA
:ARMDATA(5)üARMTEMP
:PLAYERTN
:ENEMYTN
:Else
:Menu(1,"Melee",MELB,2,"Ranged",RANB)
:Lbl MELB
:ARMDATA(3)üARMTEMP
:ENEMYTN
:PLAYERTN
:Lbl RANB
:ARMDATA(5)üARMTEMP
:ENEMYTN
:PLAYERTN
:End
:End
:End
:If SAVEDATA(3) ÷ 0
:DEATH
:Return

Player Attack:

Code:
:Disp "You attack!"
:If ENEMYDAT(4) < (int(20rand)+ARMDATA(2))
:Then
:ENEMYDAT(3)-(int(10rand)+ARMTEMP)üENEMYDAT(3)
:Disp "You hit!"
:Else
:Disp "You miss!"
:End
:Return

Enemy Attack:

Code:
:Disp "Enemy attacks!"
:If ARMDATA(1) < (int(20rand)+ENEMYDAT(5))
:Then
:SAVEDATA(3)-(int(6rand)+ENEMYDAT(6))üSAVEDATA(3)
:Disp "Enemy hits!"
:Else
:Disp "Enemy misses!"
:End
:Return


These are all separate programs.

Before putting that on my calc, I decided to try this just to make sure the "End" statement would solve my issues. Here is the code in that program:

Code:
:{20,10,10,15,2,2}üENEMDAT1
:{20,10,10,15,2,2}üENEMDAT2
:{20,10,10,15,2,2}üENEMDAT3
:{25,5,5,10,0,0}üENEMDAT4
:{30,5,5,10,0,0}üENEMDAT5
:ClLCD
:Disp "CHAPTER 1"
:Disp "As you walk down the"
:Disp "hallway you spot a"
:Disp "grouping of hostile"
:Disp "looking monsters."
:Disp "Press ENTER"
:Pause
:For(R,1,5)
:1+int(5rand)üD
:If D == 1
:Then
:ENEMDAT1üENEMYDAT
:If D == 2
:Then
:ENEMDAT2üENEMYDAT
:If D == 3
:Then
:ENEMDAT3üENEMYDAT
:If D == 4
:Then
:ENEMDAT4üENEMYDAT
:If D == 5
:Then
:ENEMDAT5üENEMYDAT
:While SAVEDATA(3)>0  and ENEMYDAT(3)>0
:ClLCD
:Disp "CHAPTER 1"
:Outpt(3,1,"ENEMY:")
:Outpt(3,7,ENEMYDAT(3))
:Outpt(4,1,"YOU:")
:Outpt(4,5,SAVEDATA(3))
:Outpt(5,1,"AC:")
:Outpt(5,4,ARMDATA(1))
:Outpt(6,1,"Melee:")
:Outpt(6,7,ARMDATA(3))
:Outpt(7,1,"Ranged:")
:Outpt(7,8,ARMDATA(5))
:If SAVEDATA(1) ù ENEMYDAT(1)
:Then
:Menu(1,"Melee",MELA,2,"Ranged",RANA)
:Lbl MELA
:Disp "You attack!"
:If ENEMYDAT(4) < (int(20rand)+ARMDATA(2))
:Then
:ENEMYDAT(3)-(int(10rand)+ARMDATA(3))üENEMYDAT(3)
:Disp "You hit!"
:Else
:Disp "You miss!"
:End
:Disp "Enemy attacks!"
:If ARMDATA(1) < (int(20rand)+ENEMYDAT(5))
:Then
:SAVEDATA(3)-(int(6rand)+ENEMYDAT(6))üSAVEDATA(3)
:Disp "Enemy hits!"
:Else
:Disp "Enemy misses!"
:End
:Lbl RANA
:Disp "You attack!"
:If ENEMYDAT(4) < (int(20rand)+ARMDATA(4))
:Then
:ENEMYDAT(3)-(int(8rand)+ARMDATA(5))üENEMYDAT(3)
:Disp "You hit!"
:Else
:Disp "You miss!"
:End
:Disp "Enemy attacks!"
:If ARMDATA(1) < (int(20rand)+ENEMYDAT(5))
:Then
:SAVEDATA(3)-(int(6rand)+ENEMYDAT(6))üSAVEDATA(3)
:Disp "Enemy hits!"
:Else
:Disp "Enemy misses!"
:End
:Else
:Menu(1,"Melee",MELB,2,"Ranged",RANB)
:Lbl MELB
:Disp "Enemy attacks!"
:If ARMDATA(1) < (int(20rand)+ENEMYDAT(5))
:Then
:SAVEDATA(3)-(int(6rand)+ENEMYDAT(6))üSAVEDATA(3)
:Disp "Enemy hits!"
:Else
:Disp "Enemy misses!"
:End
:Disp "You attack!"
:If ENEMYDAT(4) < (int(20rand)+ARMDATA(2))
:Then
:ENEMYDAT(3)-(int(10rand)+ARMDATA(3))üENEMYDAT(3)
:Disp "You hit!"
:Else
:Disp "You miss!"
:End
:Lbl RANB
:Disp "Enemy attacks!"
:If ARMDATA(1) < (int(20rand)+ENEMYDAT(5))
:Then
:SAVEDATA(3)-(int(6rand)+ENEMYDAT(6))üSAVEDATA(3)
:Disp "Enemy hits!"
:Else
:Disp "Enemy misses!"
:End
:Disp "You attack!"
:If ENEMYDAT(4) < (int(20rand)+ARMDATA(4))
:Then
:ENEMYDAT(3)-(int(8rand)+ARMDATA(5))üENEMYDAT(3)
:Disp "You hit!"
:Else
:Disp "You miss!"
:End
:End
:End
:End
:If SAVEDATA(3) ÷ 0
:DEATH
:Return


And here is the output:


Any help would be appriceated (note, some of the characters are wrong in the code listing)

It is getting tripped up with the While loop for some reason
I would add to my previous post, but this is a different problem and that post was getting lengthy with edits. This time I'm having trouble with the HP not resetting on the character even though I tell the program to do so in this program:

Code:
:{0,int(20rand),0,int(20rand),0}üARMDATA
:{30,20+int(5rand),0,1}üSAVEDATA
:SAVEDATA(2)üSAVEDATA(3)
:Lbl BEGIN
:ClLCD
:Outpt(1,6,"Equipment")
:Outpt(3,1,"Armor:")
:Outpt(3,7, ARMDATA(1))
:Outpt(4,1,"Melee:")
:Outpt(4,7, ARMDATA(3))
:Outpt(5,1,"Ranged:")
:Outpt(5,8, ARMDATA(5))
:Menu(1,"Armor",ARMOR,2,"Melee",MELEE,3,"Ranged",RANGED,5,"Cont",CONT)
:Lbl ARMOR
:ClLCD
:Outpt(1,8,"Armor")
:Outpt(3,1,"1: Scout")
:Outpt(4,1,"2: Soldier")
:Outpt(5,1,"3: Tank")
:Menu(1,"1",SCOUT,2,"2",SOLDIER,3,"3",TANK)
:Lbl SCOUT
:10üARMDATA(1)
:SAVEDATA(1)+5üSAVEDATA(1)
:Goto BEGIN
:Lbl SOLDIER
:11üARMDATA(1)
:Goto BEGIN
:Lbl TANK
:13üARMDATA(1)
:SAVEDATA(1)-5üSAVEDATA(1)
:Goto BEGIN
:Lbl MELEE
:ClLCD
:Outpt(1,8,"Melee")
:Outpt(3,1,"1: Laser Knife")
:Outpt(4,1,"2: Laser Sword")
:Outpt(5,1,"3: Laser Axe")
:Menu(1,"1",LK,2,"2",LS,3,"3",LA)
:Lbl LK
:int(10rand)+1üARMDATA(3)
:Goto BEGIN
:Lbl LS
:int(10rand)+3üARMDATA(3)
:Goto BEGIN
:Lbl LA
:int(10rand)+5üARMDATA(3)
:Goto BEGIN
:Lbl RANGED
:ClLCD
:Outpt(1,8,"Ranged")
:Outpt(3,1,"1: Laser Gun")
:Outpt(4,1,"2: Laser Rifle")
:Outpt(5,1,"3: Laser Cannon")
:Menu(1,"1",LG,2,"2",LR,3,"3",LC)
:Lbl LG
:int(8rand)+1üARMDATA(5)
:Goto BEGIN
:Lbl LR
:int(8rand)+3üARMDATA(5)
:Goto BEGIN
:Lbl LC
:int(8rand)+5üARMDATA(5)
:Goto BEGIN
:Lbl CONT
:CHAPT1


The line in question is line 3, which references line 2. I can upload screenshots and/or files if desired.
Under what conditions exactly is the HP supposed to reset and when is it not doing so? Yeah, some screenshots would probably help.
Travis wrote:
Under what conditions exactly is the HP supposed to reset and when is it not doing so? Yeah, some screenshots would probably help.


The HP is supposed to reset every time a new character is made. I put it at the beginning of the equipment chooser program, which is the program listing I included in my previous post (the u with the umlaut is supposed to be the STO-> character). Here's a screenshot of what it does. As you can see by me displaying the list for the save data at the end, the current hp (element three) is at 0, which is what caused the game over screen. It should be set to the same as the maximum HP (element 2).

It seems like the routine you posted itself would work. You might add some temporary code to print SAVEDATA at the end of that equipment choose subprogram (or just run the subprogram by itself and then check the contents of the list). If it's properly reset then, then I'd double-check all the code that runs after that up to the point where the game-over screen is prematurely displaying to see if there's anything that's changing SAVEDATA(3) accidentally when it shouldn't, or is saving into it when it should actually be storing somewhere else, or something like that. Adding some temporary “Disp SAVEDATA” lines in a few places in the code may help narrow down when it's happening.
Travis wrote:
It seems like the routine you posted itself would work. You might add some temporary code to print SAVEDATA at the end of that equipment choose subprogram (or just run the subprogram by itself and then check the contents of the list). If it's properly reset then, then I'd double-check all the code that runs after that up to the point where the game-over screen is prematurely displaying to see if there's anything that's changing SAVEDATA(3) accidentally when it shouldn't, or is saving into it when it should actually be storing somewhere else, or something like that. Adding some temporary “Disp SAVEDATA” lines in a few places in the code may help narrow down when it's happening.


Ok, thanks. I'll do that Very Happy

EDIT: The issue seemed to resolve itself oddly enough. All it took me was putting in the debug statements and now the version without the debug statements works as well. Razz

Man... My brain really is mush... The For loop isn't bad...

Would people be willing to do a beta test just to make sure the battle mechanics are ok and everything?

EDIT: That is no longer a bug, now it's a feature Razz

Anybody want to test the game in its current state and give feedback? Smile
It seems you just edited out all the details of the problem, but what I was going to ask was: What character is the ù in “If SAVEDATA(1) ù ENEMYDAT(1)” supposed to be, and what do those values represent? Is that If:Then where the selection code was supposed to be? If so, then the condition must be ending up false somehow when you're expecting it to be true.
Travis wrote:
It seems you just edited out all the details of the problem, but what I was going to ask was: What character is the ù in “If SAVEDATA(1) ù ENEMYDAT(1)” supposed to be, and what do those values represent? Is that If:Then where the selection code was supposed to be? If so, then the condition must be ending up false somehow when you're expecting it to be true.


That is supposed to be a greater than or equal to symbol. Those values are compared to determine who goes first, you or your opponent Smile

I can give the details again if you'd like. I was nearing my wits' end because I'd been trying to debug this software and decided to call it a "feature." (This is turning my brain into mush, I can't wait until I can program in Assembly and be free from GRAPH-LINK).
Well, if TI-BASIC is turning your brain into mush, you may want to consider waiting until you're a little more comfortable with it before tackling ASM and all of its additional low-level concepts and abstractions, and where things can get really weird and confusing when something goes wrong. Wink

I'm not 100% familiar with the program yet (I was just quickly skimming it to try to look for any obvious clues), but if I'm correct that all the player selection code that should run every turn is actually inside that “if player goes first” comparison, then unless you have it somewhere else too it won't run at all on turns where the enemy goes first. I can't remember for sure, but that's my guess.

If you haven't tried it already, it may help to go through the routines, following them and pretending you're the calculator and are executing them (take your time and try to pay close attention to the code and notice what it really says rather than what you might have thought you remembered writing, since there's a possibility of errors or typos that you might have overlooked). If you “execute” the program correctly just like the calculator does, you should be able to discover where it's going wrong.
Travis wrote:
Well, if TI-BASIC is turning your brain into mush, you may want to consider waiting until you're a little more comfortable with it before tackling ASM and all of its additional low-level concepts and abstractions, and where things can get really weird and confusing when something goes wrong. Wink

I'm not 100% familiar with the program yet (I was just quickly skimming it to try to look for any obvious clues), but if I'm correct that all the player selection code that should run every turn is actually inside that “if player goes first” comparison, then unless you have it somewhere else too it won't run at all on turns where the enemy goes first. I can't remember for sure, but that's my guess.

If you haven't tried it already, it may help to go through the routines, following them and pretending you're the calculator and are executing them (take your time and try to pay close attention to the code and notice what it really says rather than what you might have thought you remembered writing, since there's a possibility of errors or typos that you might have overlooked). If you “execute” the program correctly just like the calculator does, you should be able to discover where it's going wrong.


Ok, thank you for your help. It's not the language itself that is messing with me, it's the antiquated software I have to use to program (I think I might try to make a TI-BASIC IDE for all versions of TI-BASIC once I get enough experience. Smile

I'll try to do what you suggested, chances are I did make an error somewhere along the way.

Edit: I found the error! Very Happy

I found that I didn't restart the while loop soon enough. Now the question is how to do a check of both your hit points and your opponent's hit points with each repetition. Smile

Here's the issue I'm encountering (it should return to the prompt for how to attack after one round (you and the enemy attack once):


Here's the code:

Code:
:{20,10,10,15,2,2}üENEMDAT1
:{20,10,10,15,2,2}üENEMDAT2
:{20,10,10,15,2,2}üENEMDAT3
:{25,5,5,10,0,0}üENEMDAT4
:{30,5,5,10,0,0}üENEMDAT5
:ClLCD
:Disp "CHAPTER 1"
:Disp "As you walk down the"
:Disp "hallway you spot a"
:Disp "grouping of hostile"
:Disp "looking monsters."
:Disp "Press ENTER"
:Pause
:For(R,1,5)
:1+int(5rand)üD
:If D == 1
:ENEMDAT1üENEMYDAT
:If D == 2
:ENEMDAT2üENEMYDAT
:If D == 3
:ENEMDAT3üENEMYDAT
:If D == 4
:ENEMDAT4üENEMYDAT
:If D == 5
:ENEMDAT5üENEMYDAT
:While SAVEDATA(3)>0  and ENEMYDAT(3)>0
:ClLCD
:Disp "CHAPTER 1"
:Outpt(3,1,"ENEMY:")
:Outpt(3,7,ENEMYDAT(3))
:Outpt(4,1,"YOU:")
:Outpt(4,5,SAVEDATA(3))
:Outpt(5,1,"AC:")
:Outpt(5,4,ARMDATA(1))
:Outpt(6,1,"Melee:")
:Outpt(6,7,ARMDATA(3))
:Outpt(7,1,"Ranged:")
:Outpt(7,8,ARMDATA(5))
:If SAVEDATA(1) ù ENEMYDAT(1)
:Then
:Menu(1,"Melee",MELA,2,"Ranged",RANA)
:Lbl MELA
:ClLCD
:ARMDATA(3)üARMTEMP
:PLAYERTN
:ENEMYTN
:Lbl RANA
:ClLCD
:ARMDATA(5)üARMTEMP
:PLAYERTN
:ENEMYTN
:Else
:Menu(1,"Melee",MELB,2,"Ranged",RANB)
:Lbl MELB
:ClLCD
:ARMDATA(3)üARMTEMP
:ENEMYTN
:PLAYERTN
:Lbl RANB
:ClLCD
:ARMDATA(5)üARMTEMP
:ENEMYTN
:PLAYERTN
:End
:End
:End
:If SAVEDATA(3) ÷ 0
:DEATH
:Return


This time I won't impulsively edit it out of the post Wink
RogerWilco wrote:
I found that I didn't restart the while loop soon enough. Now the question is how to do a check of both your hit points and your opponent's hit points with each repetition. Smile

Here's the issue I'm encountering (it should return to the prompt for how to attack after one round (you and the enemy attack once):


Here's the code:

Code:


Code:
:Lbl MELA
:ClLCD
:ARMDATA(3)üARMTEMP
:PLAYERTN
:ENEMYTN
:Lbl RANA
:ClLCD
:ARMDATA(5)üARMTEMP
:PLAYERTN
:ENEMYTN

should be:

Code:
:Lbl MELA
:ClLCD
:ARMDATA(3)üARMTEMP
:PLAYERTN
:ENEMYTN
:goto SKPA
:Lbl RANA
:ClLCD
:ARMDATA(5)üARMTEMP
:PLAYERTN
:ENEMYTN
:Lbl SKPA
And it is similar for the Bs

Seriously, Defining Labels one after the other does not mean it skips the second label (This isn't the first time).

Great game, I look forward to seeing this be completed! Very Happy
LogicalJoe wrote:
RogerWilco wrote:
I found that I didn't restart the while loop soon enough. Now the question is how to do a check of both your hit points and your opponent's hit points with each repetition. Smile

Here's the issue I'm encountering (it should return to the prompt for how to attack after one round (you and the enemy attack once):


Here's the code:

Code:


Code:
:Lbl MELA
:ClLCD
:ARMDATA(3)üARMTEMP
:PLAYERTN
:ENEMYTN
:Lbl RANA
:ClLCD
:ARMDATA(5)üARMTEMP
:PLAYERTN
:ENEMYTN

should be:

Code:
:Lbl MELA
:ClLCD
:ARMDATA(3)üARMTEMP
:PLAYERTN
:ENEMYTN
:goto SKPA
:Lbl RANA
:ClLCD
:ARMDATA(5)üARMTEMP
:PLAYERTN
:ENEMYTN
:Lbl SKPA
And it is similar for the Bs

Seriously, Defining Labels one after the other does not mean it skips the second label (This isn't the first time).


Yeah, I don't know what I was thinking. I have experience in this and I know how to control program flow in TI-BASIC. I think I was just sort of trying to rush through the battle routines. Razz

Thanks for your help Very Happy

EDIT: After an intense debugging session that spanned multiple days (not continuous):


I submitted the file to the contest just now. Thanks to everyone for their help, this has been an amazing journey. Here is a link to the page with the file on the archives:

TICalc: https://www.ticalc.org/archives/files/fileinfo/472/47256.html
Cemetech" https://www.cemetech.net/programs/85/SpaceAdventure85Release.zip
Just an update: A bug has been found in the game (thanks to Jeffitus and GregsAStar for finding it and reporting it). If any more bugs are found, feel free to mention them here. I will get fixes released as soon as possible.

Also, the TI-89 port will most likely not be happening (at least not anytime soon). The soundtrack that I hinted at however will be happening very soon, it is just a matter of finding the time.

Thanks again for all of the support and I hope you vote for my program! Very Happy

EDIT: Link to a demo of one track from the soundtrack (will edit in the full playlist once the soundtrack is complete): https://soundcloud.com/user-385492180/space-adventure-85-title-screen-demo/s-hHG5v
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement