Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Munchor on May 20, 2011, 07:41:12 pm
-
First of all, I shall explain why this isn't in the Axe Q&A topic. It's because this is something harder and that I need an explanation but not just for me, I think everybody can benefit if anyone can teach me this.
.A
0->Y->B->X->A
ClrDraw^^r
[38283B123C501028]->Pic1A
[1C14DC483C0A0814]->Pic1B
Repeat getKey(15)
ClrDraw
Pic1A->O
If getKey(3)
Pic1A->O
End
If getKey(2)
Pic1B->O
End
Pt-On(X/256,Y/256,O
DispGraph
End
I had this code, and I wanted to implement bullets. This is what I used to do:
If getKey(54)
Pxl-On(X+8,Y+2)^r
End
.CODE
Horizontal -^r
This is quite a dirty hack because this way bullets can only go to the right.
However, let's say one needs to make bullets for both sides. What code have you guys written for this before?
(This is more a sort of a discussion)
-
well, you can use velocities to determine how they'll move ;) that's a simple way, though in Uncharted TI I do the dirty hack and just move it by one pixel per frame, since it's fast and small in code, and bullets are insanely fast anyways :)
-
well, you can use velocities to determine how they'll move ;) that's a simple way, though in Uncharted TI I do the dirty hack and just move it by one pixel per frame, since it's fast and small in code, and bullets are insanely fast anyways :)
Yes so how do you make them for both sides? Or you're not really using Horizontals, etc.?
-
Create an array for the bullets, reserving for each bullet an X position, a Y position, an X velocity, and a Y velocity. Then loop through the array each pass to move each bullet individually. It's actually faster than you'd think :)
-
Then I need to learn arrays, is it L1 and L2, so is it like BASIC Lists?
-
Well, Axe doesn't natively support arrays, so you just have to reserve some memory and create your own :D
[ad]http://clrhome.co.cc/resources/tuts/arrays/ (http://clrhome.co.cc/resources/tuts/arrays/)[/ad]
-
Well, Axe doesn't natively support arrays, so you just have to reserve some memory and create your own :D
[ad]http://clrhome.co.cc/resources/tuts/arrays/ (http://clrhome.co.cc/resources/tuts/arrays/)[/ad]
Thanks a lot :)
-
And I just realized the nav system broke again. Should be fixed now, so please refresh :)
-
So is the example in that tutorial a bullets example? I did not really get it but I cannot read the whole thing now, I will later.
PS: I am on IE, hence I am not in OmnomIRC.
-
So is the example in that tutorial a bullets example? I did not really get it but I cannot read the whole thing now, I will later.
Sort of. Just mod it to suit your bullet engine.
-
I moved this to the Axe Language board, as it was originally posted in the Asm Language board.
What I normally do is store either 1 or 65535 (-1) to a variable and add that to its current X position to make it move.
-
I moved this to the Axe Language board, as it was originally posted in the Asm Language board.
What I normally do is store either 1 or 65535 (-1) to a variable and add that to its current X position to make it move.
But that implies having a variable for each bullet =P
-
I moved this to the Axe Language board, as it was originally posted in the Asm Language board.
What I normally do is store either 1 or 65535 (-1) to a variable and add that to its current X position to make it move.
But that implies having a variable for each bullet =P
Yup, so if you want multiple bullets you'll need to use arrays with at least 3 elements per bullet: X position, Y position, direction
-
You might also want to add another variable indicating which team (player or enemy) shot it. That way, when the bullet is shot, it doesn't affect the player who shot it. Either that, or you could use a time variable indicating how much time the bullet has existed (fresh bullets don't do damage, bullets that have existed too long are destroyed).
-
You might also want to add another variable indicating which team (player or enemy) shot it. That way, when the bullet is shot, it doesn't affect the player who shot it. Either that, or you could use a time variable indicating how much time the bullet has existed (fresh bullets don't do damage, bullets that have existed too long are destroyed).
Yeah, and I can also check if bullets hit walls to make them go back if I want :D