My first particle system

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

My first particle system

Post by eatcomics »

Ok, I made this because I'm doing an Allegro one and I wanted to get the look and feel for it... Oh you definitley want to read the read me other wise your screwed...

Particle System

Click here to see the hidden message (It might contain spoilers)
;Particle Engine
;Eat Komics production
;This is a demo that I am doing to get the look and feel that I want
;for my c++ allegro particle engine
;I hope logan gets to see this and it isn't just a want to do
;logan you should see this and the c++ one before any one on youtube does soooo let's get to it

Graphics 800, 600
SeedRnd (MilliSecs())
AutoMidHandle True
SetBuffer BackBuffer()

Type Particle

Field colour ;I spelled it that way because i can't use "color" it's reserved for blitz
Field life
Field x#
Field y#
Field xvel#
Field yvel#

End Type

Global gravity# = 0.4
Global maxlife = 65
Global angle = 0
Global intensity = 65
Global cursorx = 400
Global cursory = 300
Global colour = 1

While Not KeyDown(1)

Cls
Test_Input()
Draw_HUD()

If KeyDown(42)

Create_Particles(cursorx,cursory,angle,intensity)

EndIf

Update_Particles()
FlushKeys

Flip
Wend
End

Function Test_Input()

;;;;;;;;;;;;;;;;;;;;;;;;;this point to next huge comment point are controls for the cursor;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If KeyDown(17) Then cursory = cursory - 5 ;"W" key moves cursor up
If KeyDown(30) Then cursorx = cursorx - 5 ;"A" key moves cursor left
If KeyDown(31) Then cursory = cursory + 5 ;"S" key moves cursor down
If KeyDown(32) Then cursorx = cursorx + 5 ;"D" key moves cursor right
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If KeyDown(205) Then angle = angle + 20
If KeyDown(203) Then angle = angle - 20
If KeyDown(22) Then gravity# = gravity# + 0.005 If gravity# > 1.0 Then gravity# = 0.1 ;"U" key controls gravity
If KeyDown(23) Then maxlife = maxlife + 1 If maxlife > 100 Then maxlife = 1 ;"I" key controls life
If KeyDown(24) Then intensity = intensity + 1 If intensity > 300 Then intensity = 1;"O" key controls intensity
If KeyHit(25) Then colour = colour + 1 If colour > 4 Then colour = 1 ;"P" key controls color
If testangle > 360 Then angle = angle - 360
If testangle < 0 Then angle = angle + 360

End Function


Function Draw_HUD()
Text 150, 10, gravity
Text 150, 20, maxlife
Text 250, 30, intensity

Color 128,128,128
Rect cursorx, cursory, 10, 10, 1

;drawing things here
Text 10, 10, "Gravity "
Text 12, 22, "Life "
Text 12, 32, "Intensity "
;this is were the meters are drawn
Color 0,255,0
Rect 100, 10, gravity# * 50, 10, 1 ;meter 1

Color 255,255,255
Rect 100, 22, maxlife / 2 , 10, 1 ;meter 2

Color 0,255,0
Rect 100, 34, intensity / 2, 10, 1 ;meter 3

;i will now draw the clor choice buttons

Color 255,255,255
Text 10, 100, "White"
Color 0,255,0
Text 10, 120, "Green"
Color 0,0,255
Text 10, 140, "Blue"
Color 255,0,0
Text 10, 160, "Red"

End Function


Function Create_Particles(cursorx,cursory,angle,intensity)

For i = 0 To intensity

particle.Particle = New Particle

particle\x = cursorx + Rnd(-3,3)
particle\y = cursory + Rnd(-3,3)

relativeangle = angle + Rnd(-55,55)

particle\xvel = (Cos(relativeangle) * (intensity / Rnd(10,24)))
particle\yvel = (Sin(relativeangle) * (intensity / Rnd(10,24)))

particle\life = maxlife + Rnd(-(intensity / 12), 0)

Next

End Function


Function Update_Particles()

For cur.Particle = Each Particle

cur\x = cur\x + cur\xvel
cur\y = cur\y + cur\yvel

cur\yvel = cur\yvel + gravity#

cur\life = cur\life - 1

If colour = 1 Then Color 255,255,255
If colour = 2 Then Color 0,255,0
If colour = 3 Then Color 0,0,255
If colour = 4 Then Color 255,0,0

Rect cur\x, cur\y, 2, 2

If cur\life < 0 Then Delete cur

Next

End Function



ReadMe

Click here to see the hidden message (It might contain spoilers)
EK particle engine

this is just my first attempt at a particle engine it is written in blitz basic
it is going to be ported to allegro later i did this justto get the look and feel for the allegro one


these are the controls

"W A S D" keys cntrol the cursor x and y
"LEFT and RIGHT" keys control the sprays angle
"U" key controls the gravity
"I" key controls the life of each particle (the longe the life the longer the particle lasts)
"O" key controls how much spary there is
"P" key switches the color of the particles

I think that is all Oh yeah "LEFT SHIFT" to spray the particles

Credits

Eric Kline (I did everything)
Jslemming (I used the particle engine he posted on the chaos rift as an example)
Gyrovorbis (I think some of it was taken from the one he showed on his youtube acount)

copyright 2008 - 2010 Eat Komics Incorporated

And I hate all you retards who have'nt put your particle engines online it took two whole days to make this cause i had no examples thank god i remembered the chaos rift

well please email me at 33kawsome@live.com with your feedback sorry if it is'nt commented enough for you who are going to use it for an example

well bye yall

Image
guyofcomics
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 53
Joined: Wed Apr 09, 2008 12:33 am
Contact:

Post by guyofcomics »

what are u programming with now? srry, I haven't been working on programming for months. I know, i suck. lol
Go Bears!
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Post by eatcomics »

Oh that's blitz basic you can download the demo at there website which is blitzplus.com
Image
Post Reply