Oh yeah, if you wonder about the code making the blades of the mill turn…
Here you go:
local windville = {}
local map=field:GetMap().map
local mills = {}
local rand=love.math.random
local millclock = klok:CreateTimer(.005)
function windville:oncycle()
if millclock:enough() then
for mill in each (mills) do
mill.deg = mill.deg + mill.spd
if mill.deg>360 then mill.deg = mill.deg - 360 end
mill.obj.ROTATION=mill.deg
end
millclock:reset()
end
end
local function startmills()
CSay("= Starting all the windmills")
for o,l in map:allobjects() do
if o.TEXTURE=="GFX/TEXTURES/WINDVILLE/MOLEN/WIEKEN.JPBF" then
CSay(" = Found a mill blade on layer "..l)
local mill = {}
mills[#mills+1]=mill
mill.obj=o
mill.layer=l
mill.deg=rand(0,360)
mill.spd=rand(50,110)/1000
o.ROTATION=mill.deg
end
end
return windville
end
return startmills() -- will return the entire module in the process and start the mills. Yup, this is what we call dirty code.
Please note though, that this code refers to many functions in other source files :P This game is using the LÖVE engine, but let’s be frank… We don’t see any references to the love. object, do we?
0 comments