Here is the code of my particle-gravity program.
Copy it and try out!!
With "anzahl" you can change the number of particles,
speed and startspeed should be clear,
and with barriere you can change the behaviour of particles, when they collide.
Please ask me questions if you want to.
And if you have ideas to improve it, tell them to me.
Every kind of feedback is welcome!!
Sorry, it's not structured very well *lol*
Copy it and try out!!
With "anzahl" you can change the number of particles,
speed and startspeed should be clear,
and with barriere you can change the behaviour of particles, when they collide.
Please ask me questions if you want to.
And if you have ideas to improve it, tell them to me.
Every kind of feedback is welcome!!
Graphics 1024,768 speed# = 2 startspeed# = 1 zuf# = 0 abstandsfaktor = 2 anzahl = 130 barriere = 0.1 Global partx#[anzahl] Global party#[anzahl] Global partxs#[anzahl] Global partys#[anzahl] Global rot[anzahl] Global gruen[anzahl] Global blau[anzahl] For x = 0 To (anzahl-1) partx[x] = Rnd(0,1024) party[x] = Rnd(0,768) rot[x] = Rnd (1,255) gruen[x] = Rnd (1,100) blau[x] = Rnd (1,255) partxs[x] = Rnd(-startspeed,startspeed) partys[x] = Rnd(-startspeed,startspeed) Next Repeat dxsv# = 0 dysv#= 0 For x = 0 To (anzahl-1) partx[x] =partx[x] + partxs[x] party[x] = party[x] + partys[x] SetColor rot[x],gruen[x],blau[x] DrawRect (partx[x]-(0)),(party[x]-(0)),2,2 dxsv = dxsv + partx[x] dysv = dysv + party[x] SetColor 255,255,255 Next dxs# = (dxsv/anzahl) dys# = (dysv/anzahl) For x = 0 To (anzahl-1) For y = 0 To (anzahl-1) abstand# = abstandsfaktor*(((partx[x]-partx[y])^2+(party[x]-party[y])^2)^.5) If partx[x] < partx[y] Then partxs[x] = partxs[x] +(.speed * (1/abstand)*Rnd(1-zuf,1+zuf)) End If If partx[x] > partx[y] Then partxs[x] = partxs[x] -(.speed * (1/abstand)*Rnd(1-zuf,1+zuf)) End If If party[x] < party[y] Then partys[x] = partys[x] +(.speed * (1/abstand)*Rnd(1-zuf,1+zuf)) End If If party[x] > party[y] Then partys[x] = partys[x] -(.speed * (1/abstand)*Rnd(1-zuf,1+zuf)) End If If y <> x Then If Abs(partx[x]-partx[y]) < 2 And Abs (party[x]-party[y])<2 Then durchx = (partxs[x]+partxs[y]) /2 durchy = (partys[x]+partys[y]) /2 partxs[x] = durchx*0.1 partys[x] = durchy*0.1 End If End If Next Next If MouseDown (1) Then For x = 0 To (anzahl-1) For y = 0 To (anzahl-1) abstand# = abstandsfaktor*(((MouseX()-partx[y])^2+(MouseY()-party[y])^2)^.5) If MouseX() < partx[y] Then xspeed# = xspeed +(.speed * (1/abstand)*Rnd(1-zuf,1+zuf)) End If If partx[x] > partx[y] Then xspeed = xspeed -(.speed * (1/abstand)*Rnd(1-zuf,1+zuf)) End If If party[x] < party[y] Then yspeed# = yspeed +(.speed * (1/abstand)*Rnd(1-zuf,1+zuf)) End If If party[x] > party[y] Then yspeed = yspeed -(.speed * (1/abstand)*Rnd(1-zuf,1+zuf)) End If Next Next DrawText xspeed,MouseX(),MouseY()+15 DrawText yspeed,MouseX(),MouseY()+25 xspeed = 0 yspeed = 0 End If Flip If Not KeyDown(key_space) Cls End If Until KeyHit (key_escape) End
Sorry, it's not structured very well *lol*