Black Smoke Effect (DBC and DBPro) by Hamish McHaggis27th Jan 2004 12:42
|
---|
Summary A black smoke effect, similar to the white one. Description This is basically the white smoke code, just it uses a different colour texture and negative alphablending/dark-ghosting. The transparent colour (as far as I can tell) for dark-ghosting is rgb(127,127,127). Also fading doesn't work so the smoke just suddenly disappears. A fading effect could be made by using DBPro's SET ALPHA MAPPING ON command, or just by scaling the particle to nothing. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Black Smoke particle effect `By Joseph Thomson `27/01/04 `Setup SYNC ON SYNC RATE 40 HIDE MOUSE `Number of smoke particles numSmokeParticles=50 `Particle value arrays DIM smokeParticlesPos#(numSmokeParticles,3) DIM smokeParticlesVel#(numSmokeParticles,3) DIM smokeParticlesSize#(numSmokeParticles,3) DIM smokeParticlesFade#(numSmokeParticles,2) `Create smoke image CREATE BITMAP 1,50,50 INK RGB(127,127,127),0 BOX 0,0,50,50 INK RGB(100,100,100),0 `Draw random dots in a circle shape FOR x=1 TO 1000 ang=RND(360) rad=RND(20) DOT 25+SIN(ang)*rad,25+COS(ang)*rad NEXT x `Blur smoke image BLUR BITMAP 1,8 GET IMAGE 1,0,0,50,50 DELETE BITMAP 1 BACKDROP ON COLOR BACKDROP RGB(255,255,255) `Make particles FOR x=1 TO numSmokeParticles MAKE OBJECT PLAIN x,10,10 TEXTURE OBJECT x,1 HIDE OBJECT x `Deactivate ambient light `REMARK FOR DBC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SET OBJECT AMBIENT x,0 `Make black areas see through `REMARK FOR DBC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SET OBJECT TRANSPARENCY x,1 `UNREMARK FOR DBC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! `set object x,1,0,1,1,1,1,0 `Dark-Ghost particle GHOST OBJECT ON x,1 NEXT x POSITION CAMERA 0,20,-50 DO `Position new particle at origin every nth time INC count IF count=2 THEN count=0 IF count=0 `Increase number of particle to reset INC currentParticle `Loop round if you reach the end of the particles IF currentParticle>numSmokeParticles THEN currentParticle=1 `Reset particle values `Position smokeParticlesPos#(currentParticle,1)=0 smokeParticlesPos#(currentParticle,2)=0 smokeParticlesPos#(currentParticle,3)=0 `Scale smokeParticlesSize#(currentParticle,1)=50 smokeParticlesSize#(currentParticle,2)=50 `Velocity (randomize) smokeParticlesVel#(currentParticle,1)=RND(200)/1000.0-0.1 smokeParticlesVel#(currentParticle,2)=RND(100)/1000.0+0.1 smokeParticlesVel#(currentParticle,3)=RND(200)/1000.0-0.1 smokeParticlesFade#(currentParticle,1)=200 `Show the particle SHOW OBJECT currentParticle ENDIF `Loop through particles FOR x=1 TO numSmokeParticles `Re-position and scale particle values FOR y=1 TO 3 smokeParticlesSize#(x,y)=smokeParticlesSize#(x,y)+0.5 smokeParticlesPos#(x,y)=smokeParticlesPos#(x,y)+smokeParticlesVel#(x,y) NEXT y `Fade particle value smokeParticlesFade#(x,1)=smokeParticlesFade#(x,1)+1.5 `Position, scale and fade particle object POSITION OBJECT x,smokeParticlesPos#(x,1),smokeParticlesPos#(x,2),smokeParticlesPos#(x,3) SCALE OBJECT x,smokeParticlesSize#(x,1),smokeParticlesSize#(x,2),100 FADE OBJECT x,smokeParticlesFade#(x,1) `Point at camera SET OBJECT TO CAMERA ORIENTATION x NEXT x SYNC LOOP |