Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Munchor on May 20, 2011, 07:41:12 pm

Title: Axe Bullets
Post 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.

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

Code: [Select]
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)
Title: Re: Axe Bullets
Post by: Ashbad on May 20, 2011, 07:57:56 pm
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 :)
Title: Re: Axe Bullets
Post by: Munchor on May 20, 2011, 08:00:16 pm
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.?
Title: Re: Axe Bullets
Post by: Deep Toaster on May 21, 2011, 10:46:40 am
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 :)
Title: Re: Axe Bullets
Post by: Munchor on May 21, 2011, 10:51:57 am
Then I need to learn arrays, is it L1 and L2, so is it like BASIC Lists?
Title: Re: Axe Bullets
Post by: Deep Toaster on May 21, 2011, 10:54:44 am
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]
Title: Re: Axe Bullets
Post by: Munchor on May 21, 2011, 10:56:10 am
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 :)
Title: Re: Axe Bullets
Post by: Deep Toaster on May 21, 2011, 10:58:03 am
And I just realized the nav system broke again. Should be fixed now, so please refresh :)
Title: Re: Axe Bullets
Post by: Munchor on May 21, 2011, 10:59:17 am
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.
Title: Re: Axe Bullets
Post by: Deep Toaster on May 21, 2011, 11:00:16 am
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.
Title: Re: Axe Bullets
Post by: ztrumpet on May 21, 2011, 11:19:39 am
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.
Title: Re: Axe Bullets
Post by: Munchor on May 21, 2011, 12:42:23 pm
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
Title: Re: Axe Bullets
Post by: ztrumpet on May 21, 2011, 01:38:33 pm
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
Title: Re: Axe Bullets
Post by: Compynerd255 on May 25, 2011, 10:36:45 am
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).
Title: Re: Axe Bullets
Post by: Munchor on May 27, 2011, 12:54:34 pm
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