Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Sprite Missiles (15 enemies spinning and firing shots)

Author
Message
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 27th Nov 2002 00:59
Umm.. just playing about.. enjoy (apologies for lack of code button, not working for me yet) Cut and paste into DBP.


sync on:sync rate 100:hide mouse
box 0,0,10,10:get image 1,0,0,10,10:get image 2,0,0,6,6:get image 3,0,0,3,3

enemy_max=15
dim enemy(enemy_max,4)
for i=1 to enemy_max
enemy(i,1)=0 :`alive flag - not used yet
enemy(i,2)=0 :`firing flag - used
enemy(i,3)=0 :`turret sprite - not used yet
enemy(i,4)=45 :`turret sprite angle - used
sprite i,i*40,240,1
offset sprite i,getoffset("x",1),getoffset("y",1)
next i

missile_life=200
missile_speed_df=2
missile_speed=2

missile_total=20
dim missiles(enemy_max,missile_total,4)
for i=1 to enemy_max
for i2=1 to missile_total
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
missiles(i,i2,3)=49+count
missiles(i,i2,4)=2
inc count,1
next i2
next i

sprite 9998,mousex(),mousey(),3
offset sprite 9998,getoffset("x",3),getoffset("y",3)

do

sprite 9998,mousex(),mousey(),3

if rnd(20)=1
who=1+rnd(enemy_max-1)
enemy(who,2)=1
endif

for i=1 to enemy_max
temp=enemy(i,4)+3
enemy(i,4)=wrapvalue(temp)
rotate sprite i,enemy(i,4)
burst=1+(rnd(missile_total-1))
next i

for i=1 to enemy_max
if enemy(i,2)=1
for i2=1 to burst
if missiles(i,i2,1)=0
missiles(i,i2,1)=1
if sprite exist(missiles(i,i2,3))=1 then delete sprite missiles(i,i2,3)
sprite missiles(i,i2,3),sprite x(i),sprite y(i),missiles(i,i2,4)
offset sprite missiles(i,i2,3),getoffset("x",missiles(i,i2,4)),getoffset("y",missiles(i,i2,4))
rotate sprite missiles(i,i2,3),enemy(i,4)
show sprite missiles(i,i2,3)
exit
endif
next burst
endif
next i

for i=1 to enemy_max
for i2=1 to missile_total
if missiles(i,i2,1)=1
move sprite missiles(i,i2,3),missile_speed
dec missiles(i,i2,2),1
`basic col test
if sprite collision(9998,missiles(i,i2,3))=1 then text 320,440,"ARRGHGHGH!!"
if missiles(i,i2,2)=0
hide sprite missiles(i,i2,3)
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
enemy(i,2)=0
delete sprite missiles(i,i2,3)
endif
endif
next i2
next i

sync
loop

function getoffset(xory$,image)
if sprite exist(9999)=1 then delete sprite 9999
sprite 9999,0,0,image
if xory$="x" then returnval=sprite width(9999)/2
if xory$="y" then returnval=sprite height(9999)/2
delete sprite 9999
endfunction returnval
Skyone
21
Years of Service
User Offline
Joined: 30th Dec 2002
Location: United States
Posted: 31st Dec 2002 02:45
just add [/code ] around your code

Code of the Week: Moving an object back.
If Downkey()=1 then Move object x,-10
x=Object Number
Puffy
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United States
Posted: 1st Jan 2003 10:37
ok ... np...

AMD Athlon XP 2100+ OC to 3Ghz/1.5gigs ram/128mb ti4200/120gigs hd/19" monitor/Sound Blaster Audigy Platinum EX/3072kbs Sat Con... I joined in!
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 5th Jan 2003 16:06
Testing 1.2.3...

/code
sync on:sync rate 100:hide mouse
box 0,0,10,10:get image 1,0,0,10,10:get image 2,0,0,6,6:get image 3,0,0,3,3

enemy_max=15
dim enemy(enemy_max,4)
for i=1 to enemy_max
enemy(i,1)=0 :`alive flag - not used yet
enemy(i,2)=0 :`firing flag - used
enemy(i,3)=0 :`turret sprite - not used yet
enemy(i,4)=45 :`turret sprite angle - used
sprite i,i*40,240,1
offset sprite i,getoffset("x",1),getoffset("y",1)
next i

missile_life=200
missile_speed_df=2
missile_speed=2

missile_total=20
dim missiles(enemy_max,missile_total,4)
for i=1 to enemy_max
for i2=1 to missile_total
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
missiles(i,i2,3)=49+count
missiles(i,i2,4)=2
inc count,1
next i2
next i

sprite 9998,mousex(),mousey(),3
offset sprite 9998,getoffset("x",3),getoffset("y",3)

do

sprite 9998,mousex(),mousey(),3

if rnd(20)=1
who=1+rnd(enemy_max-1)
enemy(who,2)=1
endif

for i=1 to enemy_max
temp=enemy(i,4)+3
enemy(i,4)=wrapvalue(temp)
rotate sprite i,enemy(i,4)
burst=1+(rnd(missile_total-1))
next i

for i=1 to enemy_max
if enemy(i,2)=1
for i2=1 to burst
if missiles(i,i2,1)=0
missiles(i,i2,1)=1
if sprite exist(missiles(i,i2,3))=1 then delete sprite missiles(i,i2,3)
sprite missiles(i,i2,3),sprite x(i),sprite y(i),missiles(i,i2,4)
offset sprite missiles(i,i2,3),getoffset("x",missiles(i,i2,4)),getoffset("y",missiles(i,i2,4))
rotate sprite missiles(i,i2,3),enemy(i,4)
show sprite missiles(i,i2,3)
exit
endif
next burst
endif
next i

for i=1 to enemy_max
for i2=1 to missile_total
if missiles(i,i2,1)=1
move sprite missiles(i,i2,3),missile_speed
dec missiles(i,i2,2),1
`basic col test
if sprite collision(9998,missiles(i,i2,3))=1 then text 320,440,"ARRGHGHGH!!"
if missiles(i,i2,2)=0
hide sprite missiles(i,i2,3)
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
enemy(i,2)=0
delete sprite missiles(i,i2,3)
endif
endif
next i2
next i

sync
loop

function getoffset(xory$,image)
if sprite exist(9999)=1 then delete sprite 9999
sprite 9999,0,0,image
if xory$="x" then returnval=sprite width(9999)/2
if xory$="y" then returnval=sprite height(9999)/2
delete sprite 9999
endfunction returnval
/code
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 5th Jan 2003 16:06
And again..


sync on:sync rate 100:hide mouse
box 0,0,10,10:get image 1,0,0,10,10:get image 2,0,0,6,6:get image 3,0,0,3,3

enemy_max=15
dim enemy(enemy_max,4)
for i=1 to enemy_max
enemy(i,1)=0 :`alive flag - not used yet
enemy(i,2)=0 :`firing flag - used
enemy(i,3)=0 :`turret sprite - not used yet
enemy(i,4)=45 :`turret sprite angle - used
sprite i,i*40,240,1
offset sprite i,getoffset("x",1),getoffset("y",1)
next i

missile_life=200
missile_speed_df=2
missile_speed=2

missile_total=20
dim missiles(enemy_max,missile_total,4)
for i=1 to enemy_max
for i2=1 to missile_total
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
missiles(i,i2,3)=49+count
missiles(i,i2,4)=2
inc count,1
next i2
next i

sprite 9998,mousex(),mousey(),3
offset sprite 9998,getoffset("x",3),getoffset("y",3)

do

sprite 9998,mousex(),mousey(),3

if rnd(20)=1
who=1+rnd(enemy_max-1)
enemy(who,2)=1
endif

for i=1 to enemy_max
temp=enemy(i,4)+3
enemy(i,4)=wrapvalue(temp)
rotate sprite i,enemy(i,4)
burst=1+(rnd(missile_total-1))
next i

for i=1 to enemy_max
if enemy(i,2)=1
for i2=1 to burst
if missiles(i,i2,1)=0
missiles(i,i2,1)=1
if sprite exist(missiles(i,i2,3))=1 then delete sprite missiles(i,i2,3)
sprite missiles(i,i2,3),sprite x(i),sprite y(i),missiles(i,i2,4)
offset sprite missiles(i,i2,3),getoffset("x",missiles(i,i2,4)),getoffset("y",missiles(i,i2,4))
rotate sprite missiles(i,i2,3),enemy(i,4)
show sprite missiles(i,i2,3)
exit
endif
next burst
endif
next i

for i=1 to enemy_max
for i2=1 to missile_total
if missiles(i,i2,1)=1
move sprite missiles(i,i2,3),missile_speed
dec missiles(i,i2,2),1
`basic col test
if sprite collision(9998,missiles(i,i2,3))=1 then text 320,440,"ARRGHGHGH!!"
if missiles(i,i2,2)=0
hide sprite missiles(i,i2,3)
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
enemy(i,2)=0
delete sprite missiles(i,i2,3)
endif
endif
next i2
next i

sync
loop

function getoffset(xory$,image)
if sprite exist(9999)=1 then delete sprite 9999
sprite 9999,0,0,image
if xory$="x" then returnval=sprite width(9999)/2
if xory$="y" then returnval=sprite height(9999)/2
delete sprite 9999
endfunction returnval
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 5th Jan 2003 16:07
Damn I'm thick

The code button above gives me an error on the page.

Final test..

<CODE>
`Hello
</CODE>
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 5th Jan 2003 16:08
Erm.. sorry dudes.. wasting forum space

Cheers.
Inkybro
21
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 7th Jan 2003 00:39
Replace the < and > with [ and ]

Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 7th Jan 2003 15:00

sync on:sync rate 100:hide mouse
box 0,0,10,10:get image 1,0,0,10,10:get image 2,0,0,6,6:get image 3,0,0,3,3

enemy_max=15
dim enemy(enemy_max,4)
for i=1 to enemy_max
enemy(i,1)=0 :`alive flag - not used yet
enemy(i,2)=0 :`firing flag - used
enemy(i,3)=0 :`turret sprite - not used yet
enemy(i,4)=45 :`turret sprite angle - used
sprite i,i*40,240,1
offset sprite i,getoffset("x",1),getoffset("y",1)
next i

missile_life=200
missile_speed_df=2
missile_speed=2

missile_total=20
dim missiles(enemy_max,missile_total,4)
for i=1 to enemy_max
for i2=1 to missile_total
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
missiles(i,i2,3)=49+count
missiles(i,i2,4)=2
inc count,1
next i2
next i

sprite 9998,mousex(),mousey(),3
offset sprite 9998,getoffset("x",3),getoffset("y",3)

do

sprite 9998,mousex(),mousey(),3

if rnd(20)=1
who=1+rnd(enemy_max-1)
enemy(who,2)=1
endif

for i=1 to enemy_max
temp=enemy(i,4)+3
enemy(i,4)=wrapvalue(temp)
rotate sprite i,enemy(i,4)
burst=1+(rnd(missile_total-1))
next i

for i=1 to enemy_max
if enemy(i,2)=1
for i2=1 to burst
if missiles(i,i2,1)=0
missiles(i,i2,1)=1
if sprite exist(missiles(i,i2,3))=1 then delete sprite missiles(i,i2,3)
sprite missiles(i,i2,3),sprite x(i),sprite y(i),missiles(i,i2,4)
offset sprite missiles(i,i2,3),getoffset("x",missiles(i,i2,4)),getoffset("y",missiles(i,i2,4))
rotate sprite missiles(i,i2,3),enemy(i,4)
show sprite missiles(i,i2,3)
exit
endif
next burst
endif
next i

for i=1 to enemy_max
for i2=1 to missile_total
if missiles(i,i2,1)=1
move sprite missiles(i,i2,3),missile_speed
dec missiles(i,i2,2),1
`basic col test
if sprite collision(9998,missiles(i,i2,3))=1 then text 320,440,"ARRGHGHGH!!"
if missiles(i,i2,2)=0
hide sprite missiles(i,i2,3)
missiles(i,i2,1)=0
missiles(i,i2,2)=missile_life
enemy(i,2)=0
delete sprite missiles(i,i2,3)
endif
endif
next i2
next i

sync
loop

function getoffset(xory$,image)
if sprite exist(9999)=1 then delete sprite 9999
sprite 9999,0,0,image
if xory$="x" then returnval=sprite width(9999)/2
if xory$="y" then returnval=sprite height(9999)/2
delete sprite 9999
endfunction returnval
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 7th Jan 2003 15:00
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 7th Jan 2003 15:01
Thanks (sorry, I finally got it right.. big DOH!)..
vivi
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 7th Jan 2003 17:45
Nice piece of code.

In the end


WHY WAIT FOR GAMES.......MAKE THEM COME TO YOU
>>>>www.sharksoft.scripterz.com<<<<<
THANKS IN ADVANCE

Login to post a reply

Server time is: 2024-11-24 07:27:59
Your offset time is: 2024-11-24 07:27:59