Author Topic: Devilish Particles  (Read 1664 times)

Peter

  • Guest
Devilish Particles
« on: November 19, 2012, 02:07:44 PM »
Hi,

some devilish particles for Christmas.
Code: [Select]
screen(640,480,0,"Particles")
backcolor(0,0,0)
setframetimer(60)
mousehide()

function distance(x1,y1,x2,y2)
   local dx, dy
   dx=x1-x2
   dy=y1-y2
   return math.sqrt(dx*dx+dy*dy)
end

function xMove(x3,w,s)
  return x3 + cosin[w]*s
end

function yMove(y3,w,s)
  return y3 + sinus[w]*s
end

function rand(minZahl,maxZahl)
  maxZahl=(maxZahl-minZahl)
  return int(rnd()*maxZahl+minZahl)
end

anzahl,i,aSpeed,xscreen,yscreen = 1000,0,0,640,480
xmitte,ymitte,devil,p,col = 0,0,0,0,0
xmitte = xscreen/2
ymitte = yscreen/2
x={}; y={}; winkel={}; speed={}; sinus={}; cosin={}

for i=1,anzahl do
  x[i] = xmitte
  y[i] = ymitte
  speed[i] = rand(1,3)
  winkel[i]= rand(1,360)
end
for i=1,360 do
  sinus[i] = sin(math.rad(i))
  cosin[i] = cos(math.rad(i))
end

devil=loadimage("devil.png")

repeat
p=getkey()
alphachannel(255)
cls()
putimage(mousex() -32,mousey() -48,devil)
for i=1,anzahl do
   aSpeed = distance(xmitte,ymitte,x[i],y[i]) /200 * speed[i]+1
   x[i] = xMove(x[i], winkel[i], aSpeed)
   y[i] = yMove(y[i], winkel[i], aSpeed)
   if x[i] < 0 or x[i] > xscreen or y[i] < 0 or y[i] > yscreen then
      x[i] = xmitte
      y[i] = ymitte
      winkel[i]= rand(1,360)
      speed[i] = rand(1,3)
   end
   col=speed[i]*100-55
   alphachannel(100)
   color(col,col,col)
   fillellipse(x[i],y[i],4,4)
end
xmitte = mousex()
ymitte = mousey()
redraw()
until p==27
closewindow()
« Last Edit: November 19, 2012, 05:10:35 PM by Peter »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: Devilish Particles
« Reply #1 on: November 19, 2012, 03:22:55 PM »
What about a mousehide() ?  ;)