tslusny Posted August 14, 2012 Author Share Posted August 14, 2012 I need help with **Particle system** that im planning to add to **Eclipse Advanced:** http://www.touchofdeathforums.com/smf2/index.php/topic,82336.0.htmlThis is how far i get it to work[![](http://www.freemmorpgmaker.com/files/imagehost/pics/0ff375d7fef84bb2cee25d1a25f39ae5.PNG)](http://www.freemmorpgmaker.com/files/imagehost/#0ff375d7fef84bb2cee25d1a25f39ae5.PNG)But it should look like this:[![](http://www.freemmorpgmaker.com/files/imagehost/pics/a3af90cea2920f2a305d2b913cbaff28.png)](http://www.freemmorpgmaker.com/files/imagehost/#a3af90cea2920f2a305d2b913cbaff28.png)I changed particle texture to just simple black box texture becouse of that original texture was too hard to see.**This is source what i used (it is only particle system). vbGore used this source for their particle system.**Link to download: http://www.mediafire.com/?ij67s37ql5ipgfcCode what i implemented to eclipse (of course DX8):Class Particle```Option ExplicitPrivate mvarsngX As SinglePrivate mvarsngY As SinglePrivate mvarsngSize As SinglePrivate mvarsngXSpeed As SinglePrivate mvarsngYSpeed As SinglePrivate mvarsngXAccel As SinglePrivate mvarsngYAccel As SinglePrivate mvarsngR As SinglePrivate mvarsngG As SinglePrivate mvarsngB As SinglePrivate mvarsngA As SinglePrivate mvarsngAlphaDecay As SinglePublic Property Let sngAlphaDecay(ByVal vData As Single) mvarsngAlphaDecay = vDataEnd PropertyPublic Property Get sngAlphaDecay() As Single sngAlphaDecay = mvarsngAlphaDecayEnd PropertyPublic Property Let sngA(ByVal vData As Single) mvarsngA = vDataEnd PropertyPublic Property Get sngA() As Single sngA = mvarsngAEnd PropertyPublic Property Let sngB(ByVal vData As Single) mvarsngB = vDataEnd PropertyPublic Property Get sngB() As Single sngB = mvarsngBEnd PropertyPublic Property Let sngG(ByVal vData As Single) mvarsngG = vDataEnd PropertyPublic Property Get sngG() As Single sngG = mvarsngGEnd PropertyPublic Property Let sngR(ByVal vData As Single) mvarsngR = vDataEnd PropertyPublic Property Get sngR() As Single sngR = mvarsngREnd PropertyPublic Property Let sngYAccel(ByVal vData As Single) mvarsngYAccel = vDataEnd PropertyPublic Property Get sngYAccel() As Single sngYAccel = mvarsngYAccelEnd PropertyPublic Property Let sngXAccel(ByVal vData As Single) mvarsngXAccel = vDataEnd PropertyPublic Property Get sngXAccel() As Single sngXAccel = mvarsngXAccelEnd PropertyPublic Property Let sngYSpeed(ByVal vData As Single) mvarsngYSpeed = vDataEnd PropertyPublic Property Get sngYSpeed() As Single sngYSpeed = mvarsngYSpeedEnd PropertyPublic Property Let sngXSpeed(ByVal vData As Single) mvarsngXSpeed = vDataEnd PropertyPublic Property Get sngXSpeed() As Single sngXSpeed = mvarsngXSpeedEnd PropertyPublic Property Let sngSize(ByVal vData As Single) mvarsngSize = vDataEnd PropertyPublic Property Get sngSize() As Single sngSize = mvarsngSizeEnd PropertyPublic Property Let sngY(ByVal vData As Single) mvarsngY = vDataEnd PropertyPublic Property Get sngY() As Single sngY = mvarsngYEnd PropertyPublic Property Let sngX(ByVal vData As Single) mvarsngX = vDataEnd PropertyPublic Property Get sngX() As Single sngX = mvarsngXEnd PropertyPublic Sub ResetColor(sngRed As Single, sngGreen As Single, sngBlue As Single, sngAlpha As Single, sngDecay As Single) '//Reset color to the new values sngR = sngRed sngG = sngGreen sngB = sngBlue sngA = sngAlpha sngAlphaDecay = sngDecayEnd SubPublic Sub ResetIt(X As Single, Y As Single, XSpeed As Single, YSpeed As Single, XAcc As Single, YAcc As Single, sngResetSize As Single) sngX = X sngY = Y sngXSpeed = XSpeed sngYSpeed = YSpeed sngXAccel = XAcc sngYAccel = YAcc sngSize = sngResetSizeEnd SubPublic Sub UpdateParticle(sngTime As Single) sngX = sngX + sngXSpeed * sngTime sngY = sngY + sngYSpeed * sngTime sngXSpeed = sngXSpeed + sngXAccel * sngTime sngYSpeed = sngYSpeed + sngYAccel * sngTime sngA = sngA - sngAlphaDecay * sngTimeEnd Sub```Class ColFireFX (this class is for drawing that fire)```Option ExplicitPrivate Particles() As ParticlePrivate vertsPoints() As TLVERTEXPrivate mCol As CollectionPrivate sngX As Single, sngY As SinglePublic ParticleCounts As LongPrivate lngFloat0 As LongPrivate lngFloat1 As LongPrivate lngFloatSize As LongPrivate lngPreviousFrame As LongPublic Sub Begin() '//We initialize our stuff here Dim I As Long lngFloat0 = FtoDW(0) lngFloat1 = FtoDW(1) lngFloatSize = FtoDW(25) '//Size of our flame particles.. '//Redim our particles to the particlecount ReDim Particles(0 To ParticleCounts) '//Redim vertices to the particle count '//Point sprites, so 1 per particle ReDim vertsPoints(0 To ParticleCounts) '//Now generate all particles For I = 0 To ParticleCounts Set Particles(I) = New Particle vertsPoints(I).RHW = 1 Call Reset(I) Next I '//Set initial time lngPreviousFrame = timeGetTimeEnd SubPublic Sub Reset(I As Long) Dim X As Single, Y As Single X = sngX + (Rnd * 10) Y = sngY '//This is were we will reset individual particles. With Particles(I) Call .ResetIt(X, Y, -0.4 + (Rnd * 0.8), -0.5 - (Rnd * 0.4), 0, -(Rnd * 0.3), 2) Call .ResetColor(1, 0.5, 0.2, 0.6 + (0.2 * Rnd), 0.01 + Rnd * 0.05) End WithEnd SubPublic Sub Update() Dim I As Long Dim sngElapsedTime As Single '//We calculate the time difference here sngElapsedTime = (timeGetTime - lngPreviousFrame) / 100 lngPreviousFrame = timeGetTime For I = 0 To ParticleCounts With Particles(I) Call .UpdateParticle(sngElapsedTime) '//If the particle is invisible, reset it again. If .sngA <= 0 Then Call Reset(I) End If vertsPoints(I).Color = D3DColorMake(.sngR, .sngG, .sngB, .sngA) vertsPoints(I).X = .sngX vertsPoints(I).Y = .sngY End With Next IEnd SubPublic Sub Render() With Direct3D_Device '//Set our texture .SetTexture 0, gTexture(Tex_Particle.Texture).Texture '//And draw all our particles :D .DrawPrimitiveUP D3DPT_POINTLIST, ParticleCounts, vertsPoints(0), Len(vertsPoints(0)) End WithEnd SubPublic Sub ReLocate(sngNewX As Single, sngNewY As Single) sngX = sngNewX sngY = sngNewYEnd Sub```I added this to Sub Render_Graphics into that direct3D scene:```myNewFire.Update myNewFire.Render```I added this to bottom of Sub GameInit```Set myNewFire = New colFireFX myNewFire.ParticleCounts = 150 myNewFire.ReLocate 150, 200 myNewFire.Begin```And i added to modGlobals:```Public myNewFire As colFireFXPublic Declare Function timeGetTime Lib "winmm.dll" () As Long``` Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now