Author Topic: Fog  (Read 1246 times)

Cosmo

  • Guest
Fog
« on: 06. February 2014, 12:12:40 »
Hello,

A little bit fog.
Code: [Select]
--' 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()
« Last Edit: 06. February 2014, 12:33:33 by Cosmo »

Cosmo

  • Guest
Re: Fog
« Reply #1 on: 07. February 2014, 12:59:01 »
Hello,

Another idea.
Just move your mouse.

Code: [Select]
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()     
« Last Edit: 08. February 2014, 13:38:30 by Cosmo »

GEEK

  • Jr. Member
  • **
  • Posts: 83
  • want to learn c++, if you want to teach me, pm me!
    • View Profile
Re: Fog
« Reply #2 on: 07. February 2014, 17:15:48 »
lua:21: attempt to call field 'mod' (a nil value)

try this: index = math.fmod(frames+i,60) ;)
« Last Edit: 07. February 2014, 17:22:04 by GEEK »

Cosmo

  • Guest
Re: Fog
« Reply #3 on: 07. February 2014, 18:27:33 »
Hi Geek,

Quote
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 ?

Bereb

  • Newcomer
  • *
  • Posts: 47
    • View Profile
Re: Fog
« Reply #4 on: 07. February 2014, 18:43:50 »
Quote
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:
Code: [Select]
index = (frames+i) % 60
« Last Edit: 07. February 2014, 19:02:54 by Bereb »
Regards, Bertrand :)
** Lubuntu 14.04 (Intel Celeron CPU 2.66GHz - 1280MiB) **

Cosmo

  • Guest
Re: Fog
« Reply #5 on: 07. February 2014, 21:47:39 »
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!
« Last Edit: 08. February 2014, 00:07:56 by Cosmo »

GEEK

  • Jr. Member
  • **
  • Posts: 83
  • want to learn c++, if you want to teach me, pm me!
    • View Profile
Re: Fog
« Reply #6 on: 08. February 2014, 00:37:55 »
I use the standart EGSL IDE and maybe that's why we got this problem and you don't?
I use "lua52.dll"

Cosmo

  • Guest
Re: Fog
« Reply #7 on: 08. February 2014, 12:18:42 »
Hi Geek,

where did you get it?  (lua52.dll)

Tomaaz

  • Guest
Re: Fog
« Reply #8 on: 08. February 2014, 12:34:26 »
where did you get it?  (lua52.dll)

EGSL 1.6 uses lua52, EGSL 1.5 - lua51.

Cosmo

  • Guest
Re: Fog
« Reply #9 on: 08. February 2014, 13:45:17 »
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  :)