Author Topic: Axe Bullets  (Read 7085 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Axe Bullets
« 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)

Ashbad

  • Guest
Re: Axe Bullets
« Reply #1 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 :)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Bullets
« Reply #2 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.?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Bullets
« Reply #3 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 :)




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Bullets
« Reply #4 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?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Bullets
« Reply #5 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/[/ad]




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Bullets
« Reply #6 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/[/ad]

Thanks a lot :)

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Bullets
« Reply #7 on: May 21, 2011, 10:58:03 am »
And I just realized the nav system broke again. Should be fixed now, so please refresh :)
« Last Edit: May 21, 2011, 10:58:31 am by Deep Thought »




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Bullets
« Reply #8 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.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Bullets
« Reply #9 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.




Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Bullets
« Reply #10 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.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Bullets
« Reply #11 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

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Bullets
« Reply #12 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

Offline Compynerd255

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +53/-4
  • Betafreak Games
    • View Profile
    • Betafreak Games
Re: Axe Bullets
« Reply #13 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).
The Slime: On Hold, preparing to add dynamic tiles

Axe Eitrix: DONE

Betafreak Games: Fun filled games for XBox and PC. Check it out at http://www.betafreak.com



Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Bullets
« Reply #14 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