0 Members and 2 Guests are viewing this topic.
For(A,0,29)0->{L1+A}->{L1+1+A}->{L1+2+A}->{L1+3+A}End
For(A,0,29){L1+A}+{L1+2+A}->{L1+A}{L1+1+A}+{L1+3+A}->{L1+1+A}End
:Lbl CREATE:For(r3,0,9 //maximum of 10bullets on screen:!If {r3*3+L1}:1->{r3*3+L1}:r1->{r3*3+L1+1}:r2->{r3*3+L1+2}:10->r3 //escape from loop:End:End
:Lbl DESTR:0->{r1+L1}
:Lbl UPDAT:For(r1,0,9:If {r1*3+L1}:{r1*3+L1+1}++ //when it moves horizontally:If 96 //outside the screen borders:Sub(DESTR,r1:End:End:End
What's kind of tricky about bullets in general is removing them from the array safely--when a bullet in the middle of the array needs to be removed. What I ended up doing for Essence was a Copy() to bring the data for the bullets after the one being deleted.
:Lbl INI:Fill({L1},2*<max number of bullets>+1,0)
:Lbl ADD:!If {L1}-10 :.10 is max number of bullets:X->{L1+{L1}+1}:Y->{L1+{L1}+2}:End
:Lbl DESTR:Copy(L1+{L1},Ptr to cell,2):{L1+{L1}}-1->{L1}:Return
:Lbl UPD:.Store X Increment in U.Y increment in V:For(A,1,{L1}:{L1+A}+U->{L1+A}:{L1+A+1}+V->{L1+A+1}:Pt-ON({L1+A},{L1+A+1},<Sprite data>):End:DispGraph^rr:Return
What's kind of tricky about bullets in general is removing them from the array safely--when a bullet in the middle of the array needs to be removed.
Quote from: Darl181 on October 19, 2011, 03:27:27 pmWhat's kind of tricky about bullets in general is removing them from the array safely--when a bullet in the middle of the array needs to be removed.What I do is just go ahead and remove it, regardless where it is in the array. Then, when the user presses [2ND], I search through the array and put a new one wherever it fits. So every iteration of the main game loop, I move the bullets and display them and do collision checks with objects and such.
Quote from: buttsfredkin on October 19, 2011, 04:44:22 pmQuote from: Darl181 on October 19, 2011, 03:27:27 pmWhat's kind of tricky about bullets in general is removing them from the array safely--when a bullet in the middle of the array needs to be removed.What I do is just go ahead and remove it, regardless where it is in the array. Then, when the user presses [2ND], I search through the array and put a new one wherever it fits. So every iteration of the main game loop, I move the bullets and display them and do collision checks with objects and such.This is also very very useful if you use the address of the bullets elsewhere, since with this method the address of the bullets never change