|
Post by andymc on May 9, 2016 6:18:44 GMT 1
Those particles look great Wonder! Are they individual stories controlled by you code or are you using particle commands in libgdx? I'm adding rain and snow to my game soon and on PC I used individual sprites all in a list which I updated and drew got each frame, 150 worked no problem so I'm now planning to do the same with libgdx for weather and blood particles on android.
|
|
|
Post by wonder on May 9, 2016 11:42:06 GMT 1
I love doing things "by hand", so yeah, no special LibGDX voodoo involved:
Dim x, y As Double gl.glEnable(Gl.GL10_BLEND) Gl.glBlendFunc(Gl.GL10_SRC_ALPHA, Gl.GL10_ONE_MINUS_SRC_ALPHA) Camera.Update vector.ProjectionMatrix = Camera.Combined vector.Begin(vector.SHAPETYPE_Filled)
'Each particle must belong to an actor For Each character As GameCharacter In CharacterList For Each actor As Actor In character.actor If actor.isParticlesActive Then vector.Color = IfTrue(actor.particleColor1 <> actor.particleColor2 And frameCount mod 2 = 0, actor.particleColor1, actor.particleColor2) For Each p As GameParticle In actor.particles If p.active Then x = cam.offsetX + p.x - actor.particleHalfSize y = cam.offsetY + p.y - actor.particleHalfSize vector.Rect(x, y, p.size, p.size) End If Next 'This function takes care of updating the velocity and position vectors, as well as deactivating any "outOfMap" particles actor.ParticlesUpdate(LGStep) End If Next Next
vector.end Gl.glDisable(Gl.GL10_BLEND)
|
|
|
Post by andymc on May 9, 2016 14:48:27 GMT 1
thanks for that Wonder, I was going to implement a similar particles system myself. I was going to use scaled sprites as particles though but it looks like your using shaped here.
|
|
|
Post by wonder on May 9, 2016 17:04:53 GMT 1
By the way, did you notice my IfTrue() function? It saves me huge amounts of time!!
'Before If a > b Then c = 32 Else c = 64 End If
'Now c = IfTrue(a > b, 32, 64)
CODE SNIPPET:
'A pocket sized, type independent If statement! :D Private Sub IfTrue(expression As Object, TrueResult As Object, FalseResult As Object) As Object If expression Then Return TrueResult Return FalseResult End Sub
Another Example:
Dim direction As String Dim vectorDirection As Int
...
'--------------------------------------------------------------------------------------- 'A single line of code does the job! ;) vectorDirection = IfTrue(direction = "LEFT", -1, ifTrue(direction = "RIGHT", 1, 0)) '---------------------------------------------------------------------------------------
'Which is the same as: If direction = "LEFT" Then vectorDirection = -1 Else _ If direction = "RIGHT" Then vectorDirection = 1 Else vectorDirection = 0 End If
'Which in turn is the same as: Select direction Case "LEFT" vectorDirection = -1 Exit
Case "RIGHT" vectorDirection = 1 Exit
Case Else vectorDirection = 0 Exit End Select
|
|
|
Post by account_disabled on Sept 20, 2017 9:29:05 GMT 1
Can this people record life with mobile-spy-apps.com mobile recorder on Android?
|
|