Im making a game called Choice Endurance (CE for short) and im trying to get it to add 500 health after every battle. I have something set up, but it just resets the 2nd battles health to 500 instead of 538 or something. Heres the code......

First battle:

Code:
:ClrHome 
:AxesOff 
:ZStandard 
:ClrDraw 
:Text(25,35,"LOADING") 
:Shade({-}3,{-}1 
:ClrHome 
:ClrDraw 
:1000→A:1000→B 
:DelVar CDelVar DWhile A>0 and B>0 
:Text(1,1,Str2+":",A) 
:Text(16,1,"BRIGGS:",B) 
:Text(32,1,"HIT WHERE?") 
:Text(40,1,"LOW=1 MID=2 HI=3") 
:DelVar Z:Repeat Z=92 or Z=93 or Z=94 
:randInt(1,3→D 
:getKey→Z 
:End 
:ClrDraw 
:If Z=92 and D=1 
:Text(48,1,"BLOCKED") 
:If Z=92 and D=2 
:Then 
:randInt(1,20→E 
:A-E→A 
:Text(48,1,"BRIGGS HITS") 
:End 
:If Z=92 and D=3 
:Then 
:randInt(1,20→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=93 and D=1 
:Then 
:randInt(1,15→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=93 and D=2 
:Text(48,1,"BLOCKED") 
:If Z=93 and D=3 
:Then 
:randInt(1,15→E 
:A-E→A 
:Text(48,1,"BRIGGS HITS") 
:End 
:If Z=94 and D=1 
:Then 
:randInt(1,10→E 
:A-E→A 
:Text(48,1,"BRIGGS HITS") 
:End 
:If Z=94 and D=2 
:Then 
:randInt(1,10→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=94 and D=3 
:Text(48,1,"BLOCKED") 
:End 
:ClrHome 
:If A≤0 and B≥0 
:Then 
:"BRIGGS WINS        GAME OVER 
:prgmA 
:ClrDraw 
:AxesOn:Goto A 
:End 
:If B≤0 and A≥0 
:Then 
:"YOU WIN   CONGRATS! 
:prgmA 
:ClrDraw 
:AxesOn 
:End


Secibd Battle:

Code:
:ClrHome 
:AxesOff 
:ZStandard 
:Text(25,35,"LOADING") 
:Shade({-}3,{-}1 
:ClrHome 
:ClrDraw 
:A+500→A:1000→B 
:DelVar CDelVar DWhile A>0 and B>0 
:Text(1,1,Str2+":",A) 
:Text(16,1,"TANK:",B) 
:Text(32,1,"HIT WHERE?") 
:Text(40,1,"LOW=1 MID=2 HI=3") 
:DelVar Z:Repeat Z=92 or Z=93 or Z=94 
:randInt(1,3→D 
:getKey→Z 
:End 
:ClrDraw 
:If Z=92 and D=1 
:Text(48,1,"BLOCKED") 
:If Z=92 and D=2 
:Then 
:randInt(1,20→E 
:A-E→A 
:Text(48,1,"TANK HITS") 
:End 
:If Z=92 and D=3 
:Then 
:randInt(1,20→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=93 and D=1 
:Then 
:randInt(1,15→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=93 and D=2 
:Text(48,1,"BLOCKED") 
:If Z=93 and D=3 
:Then 
:randInt(1,15→E 
:A-E→A 
:Text(48,1,"TANK HITS") 
:End 
:If Z=94 and D=1 
:Then 
:randInt(1,10→E 
:A-E→A 
:Text(48,1,"TANK HITS") 
:End 
:If Z=94 and D=2 
:Then 
:randInt(1,10→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=94 and D=3 
:Text(48,1,"BLOCKED") 
:End 
:If A≤0 and B≥0 
:Then 
:"TANK WINS          GAME OVER 
:prgmA 
:ClrDraw 
:AxesOn:Goto A 
:End 
:If B≤0 and A≥0 
:Then 
:"YOU WIN   CONGRATS! 
:prgmA 
:ClrDraw 
:AxesOn 
:End 
:Goto θθ 
:Lbl H 
:ClrHome 
:AxesOff 
:ZStandard 
:Text(25,35,"LOADING") 
:Shade({-}3,{-}1 
:ClrHome 
:ClrDraw 
:1000→A:1000→B 
:DelVar CDelVar DWhile A>0 and B>0 
:Text(1,1,Str2+":",A) 
:Text(16,1,"SPIDER:",B) 
:Text(32,1,"HIT WHERE?") 
:Text(40,1,"LOW=1 MID=2 HI=3") 
:DelVar Z:Repeat Z=92 or Z=93 or Z=94 
:randInt(1,3→D 
:getKey→Z 
:End 
:ClrDraw 
:If Z=92 and D=1 
:Text(48,1,"BLOCKED") 
:If Z=92 and D=2 
:Then 
:randInt(1,20→E 
:A-E→A 
:Text(48,1,"SPIDER HITS") 
:End 
:If Z=92 and D=3 
:Then 
:randInt(1,20→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=93 and D=1 
:Then 
:randInt(1,15→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=93 and D=2 
:Text(48,1,"BLOCKED") 
:If Z=93 and D=3 
:Then 
:randInt(1,15→E 
:A-E→A 
:Text(48,1,"SPIDER HITS") 
:End 
:If Z=94 and D=1 
:Then 
:randInt(1,10→E 
:A-E→A 
:Text(48,1,"SPIDER HITS") 
:End 
:If Z=94 and D=2 
:Then 
:randInt(1,10→E 
:B-E→B 
:Text(48,1,Str2+" HITS") 
:End 
:If Z=94 and D=3 
:Text(48,1,"BLOCKED") 
:End 
:If A≤0 and B≥0 
:Then 
:"SPIDER WINS        GAME OVER 
:prgmA 
:ClrDraw 
:AxesOn:Goto A 
:End 
:If B≤0 and A≥0 
:Then 
:"YOU WIN   CONGRATS! 
:prgmA 
:ClrDraw 
:End


What should i do?
Are you deleting variable A somewhere between running the two programs? does prgmA touch variable A?
I don't know whether it does or not.
Post the code of prgmA here so we can see.
Heres prgmA:

Code:
:Ans+" →Str1
:DelVar A1→B
:ClrHome
:While Ans
:inString(Str1," ",A+1→C
:If 16<Ans-B or not(Ans
:Then
:Disp sub(Str1,B,A-B
:A+1→B
:End
:C→A
:End
:Pause
:ClrHome
This code changes B in the line A+1->B, so you'll have to back up B somewhere before running the program.
backup B?
adamac15 wrote:
backup B?

Store B to a temporary variable. What is prgmA used for?
prgmA is a wordwrap program
adamac15 wrote:
prgmA is a wordwrap program
Did you make sure it doesn't touch variable A?
i know nothing about that. do you think if i removed prgmA, it would work?
It apparently deletes variable A. Wink
then what do i do?
Where did you get the word wrap program, or did you program it yourself? I think the problem is in that program. Smile
I got it from someone who addressed me to it. (although i forget who.)
I made the word wrap routine. If it uses a variable that another program needs, then by all means, use a variable that the other program doesn't use.
adamac15 wrote:
I got it from someone who addressed me to it. (although i forget who.)
So did you check if it uses A or not?
it does but i need batteries for my calc again. Ill have to wait till i get some more for it to fix it. Stupid cheap batteries.
adamac15 wrote:
it does but i need batteries for my calc again. Ill have to wait till i get some more for it to fix it. Stupid cheap batteries.
Ah, good luck then; let us know once you've taken a look at prgmA. Perhaps it's in a thread here somewhere?
http://www.cemetech.net/forum/viewtopic.php?t=5165&start=0
here it is...youll have to go down the page a bit.
  
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 1 of 2
» All times are UTC - 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