Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: hellninjas on May 09, 2012, 11:23:51 am

Title: Correction Code
Post by: hellninjas on May 09, 2012, 11:23:51 am
It's me again, still trying to figure out bullets. I received some help form Derf, and it was very helpful, I feel that I am very close to figuring this out!
But I have a problem, I can't figure out what's wrong with this code, as it does not work for me...
Below is the code I received from Derf, if you could help me, it would be much appreciated :D
Code: [Select]
0->G
repeat getkey(15)
DispgraphClrdraw
For(G,1,I)               //Repeat code for every bullet
Pxl-Off{L1+(G*4)},{L1+(G*4)+1})      //Turn display for bullet off

If {L1+(G*4)+2}=1:{L1+(G*4)+1}-1->{L1+(G*4)+1}               //Depending on what direction bullet has, move it that way
End
If {L1+(G*4)+2}=2:{L1+(G*4)}+1->{L1+(G*4)}
End
If {L1+(G*4)+2}=3:{L1+(G*4)+1}+1->{L‚+(G*4)+1}
End
If {L1+(G*4)+2}=4:{L1+(G*4)}-1->{L1+(G*4)}
End:End

For(G,1,I)                                                   //Repeat code for every bullet
If pxl-Test({L1+(G*4)},{L1+(G*4)+1})            //If hits a lit up pixel (wall), move coordinates to 0,0 (storage)
0->{L1+(G*4)}->{L1+(G*4)+1}
Else
Pxl-On({L1+(G*4)},{L1+(G*4)+1})              //Otherwise, turn the bullet back on
End

I'm not entirely sure why this isn't working...
Title: Re: Correction Code
Post by: Sorunome on May 09, 2012, 11:51:51 am
Aren't there some ends missing at the end of the code? (two i think)
Title: Re: Correction Code
Post by: hellninjas on May 09, 2012, 11:56:18 am
I have those in my code, I guess I forgot to type them x.x
Title: Re: Correction Code
Post by: Derf321 on May 11, 2012, 05:02:20 pm
You need:

GetKey → K   //Should have this at start of program loop
If K=1          //If key pressed is down
1 → {L1+(G*4)+2}  //Store 1 to that bullets direction variable
End
If K=2.... etc.
Title: Re: Correction Code
Post by: kindermoumoute on May 11, 2012, 06:22:05 pm
You need:

GetKey → K   //Should have this at start of program loop
If K=1          //If key pressed is down
1 → {L1+(G*4)+2}  //Store 1 to that bullets direction variable
End
If K=2.... etc.
Optimize it please x) :
Code: [Select]
GetKey
!If -1
.getKey=1
Else!If -1
.getKey=2
Else!If -1
.getKey=3
...
Title: Re: Correction Code
Post by: squidgetx on May 14, 2012, 10:31:44 pm
You should just be using getKey() instead of the BASIC-style getKey->var :P
Title: Re: Correction Code
Post by: hellninjas on May 15, 2012, 07:46:19 am
It's all in but I still can't get it to work ;.;