RetroBASIC
Retrogamecoding(.org) => EGSL => Topic started by: Cosmo on February 06, 2014, 11:12:40 AM
-
Hello,
A little bit fog.
--' by peter wirbelauer.
function rand(minZahl,maxZahl)
maxZahl= (maxZahl-minZahl)
return int(rnd()*maxZahl+minZahl)
end
function sprite(id,x,y,w,h,fx)
drawimage(w*fx,0,w,h,x,y,id)
end
screen(800,600,0,"fog")
backcolor(0,0,0)
setframetimer(200)
local i,t,xres,yres,u,fz,h,w = 0,0,800,600,0,0,0,0
local cloudx={}
local cloudy={}
local clouds={}
w = screenwidth() /2
h = screenheight()/2
u = loadimage("png/ufostrip.png")
for i=1,250 do
cloudx[i]=rand(1,xres-2)
cloudy[i]=rand(1,yres-2)
clouds[i]=rand(1,4)
end
function move_clouds()
for i=1,250 do
alphachannel(35)
color(200,200,200)
fillcircle(cloudx[i],cloudy[i],90)
cloudx[i] = cloudx[i]+clouds[i]
if cloudx[i] > xres+128 then
cloudx[i] = -128
cloudy[i] = rand(1,yres -2)
clouds[i] = rand(1,4)
end
end
end
repeat
t=getkey()
cls()
alphachannel(255)
sprite(u,w,h,199,85,fz)
move_clouds()
fz=fz+1
if fz==8 then fz=0;end
redraw()
until t==27
closewindow()
-
Hello,
Another idea.
Just move your mouse.
screen(640,480,0,"Jelly")
setframetimer(60)
backcolor(0,0,200)
local frames,index,n,i = 1,0,60,0
local mx={}
local my={}
for i=1,60 do
mx[60]=0
my[60]=0
end
repeat
k=getkey()
clearscreen()
alphachannel(60)
mx[frames] = mousex()-30
my[frames] = mousey()-30
for i=1,n do
index = math.fmod(frames+i,60)
color(240,255,255)
ellipse(mx[index],my[index],i,i)
end
frames=frames +1
if frames==60 then frames=1; end
sync()
until k==27
closewindow()
-
lua:21: attempt to call field 'mod' (a nil value)
try this: index = math.fmod(frames+i,60) ;)
-
Hi Geek,
lua:21: attempt to call field 'mod' (a nil value)
What lua:21 ? Is running here! No error, no crash.
I use lua 5.1 and what have you ?
-
lua:21: attempt to call field 'mod' (a nil value)
What lua:21 ? Is running here! No error, no crash.
I use lua 5.1 and what have you ?
lua:21 is the line number where occured the error (same on my computer) ;)
As GEEK wrote, math.fmod() corrects the problem... However I think this function isn't in Lua 5.1 but in Lua 5.2 (I'm not sure), and EGSL 1.6.0 is built with Lua 5.2
Correction: math.mod() doesn't exist either in Lua 5.1, it's math.fmod(). But there is also an operator % which can be usefull:
index = (frames+i) % 60
-
Hi Bereb,
I have Lua5.1.dll here! math.mod doesn't make trouble.
Jelly runs fine here with Windows7.
When it would not run, I would not put it to the forum!
-
I use the standart EGSL IDE and maybe that's why we got this problem and you don't?
I use "lua52.dll"
-
Hi Geek,
where did you get it? (lua52.dll)
-
where did you get it? (lua52.dll)
EGSL 1.6 uses lua52, EGSL 1.5 - lua51.
-
Thanks Tomaaz,
Just downloaded EGSl 1.6 and installed.
Jelly was corrected (math.mod) with (math.fmod)
From now, I am running EGSL 1.6 on Windows7 :)