|
In original asteroids, I think you only had one missle at a time...so it's easy, xshot, yshot, xshotspeed, yshotspeed. If you want more than one missle, setarray shots,4*shotsmax; and for(this.i=0;this.i<(shotsmax/4);this.i++){ if(shots[this.i*4] in |x-1,x+1| && shots[(this.i*4)+1] in |y-1,y+1|){// hit something} shots[this.i*4]+=shots[(this.i*4)+2]; shots[(this.i*4)+1]+=shots[(this.i*4)+3]; }
Hope that confused the crud out of you. I'll now refuse to elaborate. ^_~
Naw, not that cruel. Here's your array:
shots=[32,32,-0.5,0.75,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
the first 2 numbers of each set of 4 is the x and y of the shot, in this case, shot 0 is at 32, 32. The third number is the x difference, every time it loops it moves left 0.5. The fourth is the y difference, every time it loops it moves down 0.75. It works, it's just a pain in the neck to write the for loop for finding a free slot, attacking, hitting something, etc. |