Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: adamac16 on January 24, 2011, 02:12:29 pm

Title: Choice Endurance Help
Post by: adamac16 on January 24, 2011, 02:12:29 pm
Im working on a game called Choice Endurance (CE for short), and im trying to add 500 health after every battle. I had something, but it only reset the 2nd battles health to 500 instead of 538 or something. Heres the code.....

First battle:
Code: [Select]
: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

Second Battle:
Code: [Select]
: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
Title: Re: Choice Endurance Help
Post by: meishe91 on January 24, 2011, 04:36:00 pm
Could you upload any files or anything? It would be helpful to see exactly what's going on. I kind of went over the code but not entirely but didn't see anything unless prgmA resets the value of A or something.
Title: Re: Choice Endurance Help
Post by: adamac16 on January 24, 2011, 08:15:13 pm
It won't let me upload anything... it keeps saying "theres already a file with the same name" no matter what i name it.
Title: Re: Choice Endurance Help
Post by: meishe91 on January 24, 2011, 08:54:01 pm
What names have you tried? Have you tried just punching in a bunch of random crap and testing?
Title: Re: Choice Endurance Help
Post by: adamac16 on January 25, 2011, 05:16:17 pm
Ive tried copying them, just putting CE, S1, etc. and it still said it.
Title: Re: Choice Endurance Help
Post by: meishe91 on January 25, 2011, 05:51:48 pm
Well try just typing in random characters like CElskdjfslkj or something like that. When you get down to stuff like two or three letters then there is a good chance it's been taken already. Or common things like A, B, C, etc. those have been taken too already.
Title: Re: Choice Endurance Help
Post by: adamac16 on January 25, 2011, 06:33:27 pm
Here you go...just put all the files in Wabbitemu and youre set.
Title: Re: Choice Endurance Help
Post by: meishe91 on January 25, 2011, 11:48:29 pm
Ok, I'll take a look ASAP. Could you tell maybe what each one does or which needs to be run first or something?
Title: Re: Choice Endurance Help
Post by: adamac16 on January 26, 2011, 05:06:53 pm
The first link, prgmA, is a wordwrap program.
The second link, prgmCHOICEEN (CE), is the main program.
Third-Fifth link, Str1,Str2,Str3, is needed to run CE.
Just run them all at the same time.
Title: Re: Choice Endurance Help
Post by: kalan_vod on January 26, 2011, 07:39:11 pm
It would be helpful if you could provide a list of the variables used, as what do they contain (used for).
Title: Re: Choice Endurance Help
Post by: meishe91 on January 26, 2011, 07:41:33 pm
Ok, thanks. I'll try to get to it when I get some time.
Title: Re: Choice Endurance Help
Post by: adamac16 on January 27, 2011, 06:53:14 pm
WOOOOOOOO!!!!! Finally fixed. Now i can continue and finish Choice Endurance.
Title: Re: Choice Endurance Help
Post by: meishe91 on January 27, 2011, 08:02:01 pm
Oh, ok. What was the problem?
Title: Re: Choice Endurance Help
Post by: DJ Omnimaga on January 27, 2011, 08:18:45 pm
Glad to hear you fixed it, but it would be cool if you shared what you did to fix it with us, in case someone else might run into a similar problem in the future. :)
Title: Re: Choice Endurance Help
Post by: kalan_vod on January 27, 2011, 11:01:05 pm
I was going through the code, but there are many occurrences of redundancies which made it difficult to pinpoint the issue. After the first battle I went from 1 Life to 500 Life, but never could make it further than that. Glad you figured it out, it is always harder for someone to figure out someones code :P
Title: Re: Choice Endurance Help
Post by: adamac16 on January 29, 2011, 07:30:44 pm
yea. prgmA was resetting the value of the health, so i had to change the health variables (A and B to X and P). Now it works. And im planning to do a Choice Endurance 2 in the future (after CE1)

@kalan_vod: what do you mean "redundancies"? Please explain.