Author Topic: Follow the mouse [CMLua]  (Read 616 times)

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 573
    • View Profile
    • Home of EGSL
Follow the mouse [CMLua]
« on: 02. March 2014, 12:11:03 »
The follow the mouse demo ported to ChipmonkeyLua:
Code: [Select]
-- move the mouse and press any key
-- to exit the demo

page = 0
activepage (page)
paper (hrgb(200,200,200))
cls()

rr=40
r={}
g={}
b={}
x={}
y={}

for i=1,200 do
 r[i]=int(rnd()*255)+1
 g[i]=int(rnd()*255)+1
 b[i]=int(rnd()*255)+1
end

for i=1,100 do
mx=mousex()
my=mousey()

x[i]=mx
y[i]=my
end
i=1
repeat
  activepage (page)
  clear()
   
  mx=mousex()
  my=mousey()
  x[i]=mx
  y[i]=my

  k=i
  for j=100,1,-1 do
    k=i-(j-1)*5
    if k<1 then
      k=k+1000
    end
 
    ink (hrgb (r[j],g[j],b[j]))

    fillcircle (x[k],y[k],rr)
   
    end
  i=i+1
  if i> 1000 then
    i=1
  end
sleep (5)
visualpage (page)
page = page + 1
if page > 1 then
    page = 0
end

until keypressed()
Best regards,
Cybermonkey