forums

TNT Basic Forums > Programming Q&A
kaboom!
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-30-2004 17:38

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

hi

ive been making explosions in my game for when i shoot bad guys. the explosions are made up of a number of sprites.

what i want is to have more than one explosion on screen at any time,
but im a bit stuck.

heres the code:


procedure destroyenemy()
int p,u,n


if destroyed =true
destroyed=false


repeat
n=random(0,5)
until dead[n]=false
dead[n]=true



for op[n]=0 to 20

explex[op[n]]=true
expltrans[op[n]]=0
explrad[op[n]]=random(0,30)
expldeg[op[n]]=random(0,360)
destx[op[n]]=ndestx
desty[op[n]]=ndesty
next
'next
end if


for u=0 to (5)
if dead=true
for pi =0 to 20
if explex[pi]=true

explx[pi]=(sin(expldeg[pi])*explrad[pi])+destx[pi]
exply[pi]=(cos(expldeg[pi])*explrad[pi])+desty[pi]

expldeg[pi]=expldeg[pi]+1
explrad[pi]=explrad[pi]+5
expltrans[pi]=expltrans[pi]+5
set sprite priority pi+5500,1
set sprite transparency pi+5500,expltrans[pi]
sprite pi+5500,explx[pi],exply[pi],14
end if
if expltrans[pi]>=100
sprite off pi+5500
dead=false
explex[pi]=false


end if

next
end if
next u

end proc



i understand that this may be somewhat difficult to understand

cheers
charlie

03-30-2004 20:04

Posted by:
-wyvern

Location:
Bedroom

Find more posts by -wyvern

what do all your variables represent? It's a little hard to figure out what's going on...

03-30-2004 20:09

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Wait, so this places 20 explosion sprites randomly along a circle around the enemy right? I don't see any draw frame calls in your procedure, so I'm guessing it just creates the sprites and then you drow them later in your main loop.
You could just create a global integer to hold how many explosion sprites are still on, and then your procedure could know to make sprites with a higher index:

global int gOldExplosions

procedure BLAH()
for pi=0 to 20
...
set sprite priority pi+5500+gOldExplosions,1
...
next pi

gOldExplosions=gOldExplosions+20

end proc


and so on.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.