Author Topic: If this isn't nice?  (Read 3024 times)

GEEK

  • Guest
If this isn't nice?
« on: February 21, 2014, 04:32:45 AM »
Code: [Select]
screen(800,500,0,".scr")
togglefullscreen()
mousehide()
setframetimer(60)

w = screenwidth()
h = screenheight()

x = w/2
y = h/2

function random(min,max)
   return int((max-min+1)*rnd()+min)
end

--------------------------------------------------------------------------------

speed = 1

myRotation = 0
xchange = x
ychange = y

function update()

myRotation = myRotation + int(rnd()*30-15)
ychange = (cos((math.pi/180)*myRotation))*speed
xchange = (sin((math.pi/180)*myRotation))*speed
if x < 0 then x = w end
if x > w then x = 0 end
if y < 0 then y = h end
if y > h then y = 0 end
y = y - ychange
x = x + xchange
rotation = myRotation

        alphachannel(80)
        color(0,random(80,180),0)
        fillcircle(x,y,3)

        alphachannel(255)
        color(0,255,0)
        fillcircle(x-2,y-2,1)
end

repeat k=getkey()
--cls()

update()

redraw()
until k==27 closewindow()
« Last Edit: February 21, 2014, 04:34:27 AM by GEEK »

GEEK

  • Guest
Re: If this isn't nice?
« Reply #1 on: February 21, 2014, 07:21:48 PM »
anyone like spaghetti? ;D

Code: [Select]
screen(800,600,0,".scr")
--togglefullscreen()
mousehide()
setframetimer(60)

w = screenwidth()
h = screenheight()

x_ = w/2
y_ = h/2

function random(min,max)
   return int((max-min+1)*rnd()+min)
end

--------------------------------------------------------------------------------

speed = 1
amount = 50

myRotation = {}
xchange = {}
ychange = {}
colors= {}

x= {}
y= {}

for i = 1,amount do
   x[i] = x_
   y[i] = y_
   xchange[i] = 0
   ychange[i] = 0
   myRotation[i] = int(rnd()*360)
   colors[i] = {random(0,255),random(0,255),random(0,255)}
end

function update()
      local i ; for i = 1,amount do

myRotation[i] = myRotation[i] + int(rnd()*30-15)
ychange[i] = (cos((math.pi/180)*myRotation[i]))*speed
xchange[i] = (sin((math.pi/180)*myRotation[i]))*speed
if x[i] < 0 then x[i] = w end
if x[i] > w then x[i] = 0 end
if y[i] < 0 then y[i] = h end
if y[i] > h then y[i] = 0 end
y[i] = y[i] - ychange[i]
x[i] = x[i] + xchange[i]

        color(0,0,0)
        fillcircle(x[i],y[i],1)
        --dot(x[i],y[i])

        color(colors[i][1],colors[i][2],colors[i][3])
        fillcircle(x[i]-2,y[i]-2,1)
        --dot(x[i]-1,y[i]-1)

end ; end

repeat k=getkey()
--cls()

update()

redraw()
until k==27 closewindow()

GEEK

  • Guest
Re: If this isn't nice?
« Reply #2 on: February 23, 2014, 11:31:14 PM »
And fade them out:

Code: [Select]
screen(800,500,0,".scr")
--togglefullscreen()
mousehide()
setframetimer(60)

w = screenwidth()
h = screenheight()

x_ = w/2
y_ = h/2

function random(min,max)
   return int((max-min+1)*rnd()+min)
end

angle = 0 -- needed for rainbow color --obo
channel = 0 -- needed for rainbow color --obo
RAD = (math.pi / 180) -- needed for rainbow color -- obo

-- RAINBOW COLOR -- OBO
getColour = function(angle, channel)
local cos =  math.cos(angle * RAD) * 255   -- lower 255 for darker colors
local sin =  math.sin(angle * RAD) * 255   -- lower 255 for darker colors


if     channel == 0 then  colour(cos, sin, 0)
elseif channel == 1 then  colour(0, cos, sin)
    elseif channel == 2 then  colour(sin, 0, cos)
    end
end

--------------------------------------------------------------------------------

speed = 1
amount = 10

myRotation = {}
xchange = {}
ychange = {}

x= {}
y= {}

for i = 1,amount do
   x[i] = x_
   y[i] = y_
   xchange[i] = 0
   ychange[i] = 0
   myRotation[i] = int(rnd()*360)
end

function update()
        local i
        for i = 1,amount do
myRotation[i] = myRotation[i] + int(rnd()*30-15)
ychange[i] = (cos((math.pi/180)*myRotation[i]))*speed
xchange[i] = (sin((math.pi/180)*myRotation[i]))*speed
if x[i] < 0 then x[i] = 0 end
if x[i] > w then x[i] = w end
if y[i] < 0 then y[i] = 0 end
if y[i] > h then y[i] = h end
y[i] = y[i] - ychange[i]
x[i] = x[i] + xchange[i]
        fillcircle(x[i],y[i],3)
        end
end

repeat k=getkey()
      color(0,0,0) alphachannel(1) fillbox(0,0,w,h)

      -- color update --obo
      if angle == 90 then
angle = 0

        if channel ~= 2 then channel = channel + 1
        else channel = 0
        end
      end

      getColour(angle, channel)
      angle = angle + 1
      -- end color update -- obo

      alphachannel(255)

      update()
sync()
until k==27 closewindow()