2D Particles by Webber10th Feb 2011 23:39
|
---|
Summary Cool 2D particles. No media. Just click the mouse. Description This program creates colorful 2D particles when the mouse is clicked. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Project: 2D Particles `Author: The Game Guy sync on : sync rate 60 Particles = 500 `The amount of particles that can be on the screen at a time Rem Create The Particle Arrays dim ParX#(Particles) : dim ParY#(Particles) `The XY Position of the Particles dim ParXS#(Particles) : dim ParYS#(Particles) `The XY Speed of the Particles Rem The Main Loop do Rem Variables for the xy mouse positions and the xy mouse speed MX# = MouseX() MY# = MouseY() MMX# = MouseMoveX() MMY# = MouseMoveY() Rem Create particles when the user clicks the mouse if mouseclick() = 1 for i = 1 to 3 `makes three particles at a time Particle = Particle + 1 if Particle > Particles then Particle = 0 `positions the particles to the position of the mouse ParX#(Particle) = MX# ParY#(Particle) = MY# ParXS#(Particle) = (MMX#)+(rnd(100)-50)/10.0 `randomizes the x-speed of the particles ParYS#(Particle) = (MMY#)+(rnd(100)-50)/20.0 `randomizes the y-speed of the particles next i endif Rem Draws all of the particles for i = 1 to Particles ink rgb(255,255-ParY#(i)/2,0),0 `Adds color to the particles line ParX#(i),ParY#(i),ParX#(i)+ParXS#(i),ParY#(i)+ParYS#(i) `draws the particle ParX#(i) = ParX#(i)+ParXS#(i) `updates the particles x position ParY#(i) = ParY#(i)+ParYS#(i) `updates the particles y position if ParX#(i) <= 0 then ParXS#(i)=-ParXS#(i)/1.5 `bounces the particles on the left wall if ParX#(i) >= 640 then ParXS#(i)=-ParXS#(i)/1.5 `bounces the particles on the right wall if ParY#(i) >= 480 then ParYS#(i)=-ParYS#(i)/1.5 `bounces the particles on the floor ParYS#(i) = ParYS#(i) +1.5 `Particles Gravity next i if inkey$() <> "" then exit `exits the program when the user hits a key sync cls `clears the screen loop end |