![]() |
Basic Particle code - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Basic Particle code (/showthread.php?tid=1231) |
Basic Particle code - Ambientiger - 29-08-2007 Not really sure where to put this, it's not a tutorial, a feature or the likes. Please move it if you think there's a better place for it. I take no credit for it, but I also can't give any credit to someone for it. ![]() I found it on a source code site whilst looking for ideas and code examples for my engine, but I don't remember where. It's short, sweet, doesn't use DX or BitBlt and could be modified numerous ways, hope you like. Simply open a new VB6 project and paste the code below into the forms code box. [code]Private Type Ptype X As Long Y As Long Xv As Long Yv As Long LifeSpan As Long End Type Const Max = 250 Dim Particle(Max) As Ptype Dim bRunning As Boolean Dim Xstart As Long, Ystart As Long Dim i As Long Private Sub Form_Load() Show Xstart = ScaleWidth \ 2 Ystart = ScaleHeight \ 2 For i = 0 To Max Particle(i).LifeSpan = Rnd * 500 Particle(i).X = Xstart Particle(i).Y = Ystart Particle(i).Yv = Rnd * -15 Particle(i).Xv = Rnd * -10 + 5 Next i bRunning = True ParticleLoop End Sub Private Sub ParticleLoop() Do While bRunning DoEvents For i = 0 To Max PSet (Particle(i).X, Particle(i).Y), BackColor Particle(i).X = Particle(i).X + Particle(i).Xv Particle(i).Y = Particle(i).Y + Particle(i).Yv Particle(i).Yv = Particle(i).Yv + 0.96 If Particle(i).Y >= ScaleHeight Then Particle(i).Yv = -(Particle(i).Yv * 0.46) Particle(i).Y = ScaleHeight End If Particle(i).LifeSpan = Particle(i).LifeSpan - 1 If Particle(i).LifeSpan Re: Basic Particle code - William - 29-08-2007 I have never before heared of: Code: PSet Although I dont think it would work on the picscreen. And its pretty slow too. Re: Basic Particle code - Rezeyu - 29-08-2007 Doesn't it set pixel color? I remember reading about it when I was looking up VBCrLf |