main.lua, turtle.lua
This commit is contained in:
40
main.lua
Normal file
40
main.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
mkTurtle = require "turtle"
|
||||
local screen = {
|
||||
width = love.graphics.getWidth(),
|
||||
height = love.graphics.getHeight(),
|
||||
}
|
||||
local o = mkTurtle(screen.width/2, screen.height*3/4)
|
||||
|
||||
local t = 0;
|
||||
function love.update(dt)
|
||||
t = t+ dt
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function love.draw()
|
||||
tt = o:dup()
|
||||
|
||||
-- local fd, lt, rt, bk, pd = tt.fd, tt.lt, tt.rt, tt.bk, tt.pd
|
||||
-- tt.rt(45).fd(10)
|
||||
|
||||
local amultl = 0.8 + math.cos(t*5)/2
|
||||
local amultr = 0.8 + math.cos(t*7)/2
|
||||
local lmultl = 0.7 + math.cos(t*3)/2
|
||||
local lmultr = 0.7 + math.cos(t*4.5)/2
|
||||
local iangle = math.cos(t*2.5)*40-20
|
||||
function trunk(tt, level, length, angle)
|
||||
tt.fd(length)
|
||||
if level > 0 then
|
||||
tt.lt(iangle)
|
||||
trunk(tt:dup().lt(angle), level-1, length*lmultl, angle*amultl)
|
||||
trunk(tt:dup().rt(angle), level-1, length*lmultr, angle*amultr)
|
||||
end
|
||||
end
|
||||
|
||||
trunk(tt, 10, 60, math.sin(t)*180)
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user