Author Topic: Circles  (Read 2177 times)

Cosmo

  • Guest
Circles
« on: February 04, 2014, 12:40:17 PM »
Last demo.
I write a small game, to learn Lua correctly. That will need a bit time.

Hi Tomaaz, is this also a rosetta thing or what rosetta is ?
I love your dogged remarks.  :P
Code: [Select]
--' Cosmo o4.o2.14
function rand(minzahl,maxzahl)
   maxzahl = (maxzahl-minzahl)
   return int(rnd()*maxzahl+minzahl)
end

screen(800,600,0,"Circles")
setframetimer(60)

local h = screenheight()/2
local w = screenwidth() /2
local a,m,t = 0,0,0

repeat
k=getkey()
clearscreen()
if a<1   then m=1; end
if a>150 then m=0; end
if m==1 then
   a=a +2
else
   a=a -1
end
t=timerticks()/1000
for i=1,100 do
   color(rand(32,255),rand(32,255),rand(32,255))
   circle(w+sin(i*90+t)/2*(20+a),h+cos(i*90+t)*(20+a)/2,a/2)
   color(255,255,255)
   circle(w+sin(i*90+t)*200,h+cos(i*90+t)*200,50)
end
redraw()
until k==27
closewindow()

Tomaaz

  • Guest
Re: Circles
« Reply #1 on: February 04, 2014, 02:22:08 PM »
Hi Tomaaz, is this also a rosetta thing or what rosetta is ?

I don't know (I'm kinda specializing in fractals  :P), but it's definitely poorly coded. If you're using setframetimer(), use sync() instead of redraw().

I love your dogged remarks.  :P

Oh, come on... There is nothing wrong with translating these simple examples, but I think that majority of users here will agree that it's a good practice to mention the original source.