local rx = 0
local ry = 0
function onCreate()
my.variables.rotSpeedX = math.random() * 2 + 1
my.variables.rotSpeedY = math.random() * 2 + 1
my.variables.colorR = math.random() * 0.3 + 0.3
my.variables.colorG = math.random() * 0.3 + 0.6
my.variables.colorB = math.random() * 0.2 + 0.8
end
function onUpdate(dt)
rx = rx + (my.variables.rotSpeedX or 1.2) * dt
ry = ry + (my.variables.rotSpeedY or 1.8) * dt
end
function onDraw()
local size = 0.45
local rawVerts = {
{0, -size, 0},
{0, size, 0},
{-size*0.7, 0, -size*0.7},
{size*0.7, 0, -size*0.7},
{size*0.7, 0, size*0.7},
{-size*0.7, 0, size*0.7}
}
local rotVerts = {}
for i, v in ipairs(rawVerts) do
local x, y, z = v[1], v[2], v[3]
local cy, sy = math.cos(ry), math.sin(ry)
local x1 = x * cy + z * sy
local z1 = -x * sy + z * cy
local cx, sx = math.cos(rx), math.sin(rx)
local y2 = y * cx - z1 * sx
local z2 = y * sx + z1 * cx
rotVerts[i] = {x1, y2, z2}
end
local rx = 0
local ry = 0
local rz = 0
function onCreate()
my.variables.rotSpeedX = math.random() * 2 + 1
my.variables.rotSpeedY = math.random() * 2 + 1
my.variables.rotSpeedZ = math.random() * 0.5
my.variables.colorR = math.random() * 0.2 + 0.8
my.variables.colorG = math.random() * 0.2 + 0.7
my.variables.colorB = math.random() * 0.1
end
function onUpdate(dt)
rx = rx + (my.variables.rotSpeedX or 1) * dt
ry = ry + (my.variables.rotSpeedY or 1.5) * dt
rz = rz + (my.variables.rotSpeedZ or 0.5) * dt
end
function onDraw()
local R = 0.38
local H = 0.22
local rawVerts = {}
-- Bottom cap (z = -H)
for i = 0, 5 do
local theta = i * 2 * math.pi / 6
table.insert(rawVerts, {R * math.cos(theta), R * math.sin(theta), -H})
end
-- Top cap (z = H)
for i = 0, 5 do
local theta = i * 2 * math.pi / 6
table.insert(rawVerts, {R * math.cos(theta), R * math.sin(theta), H})
end
local rotVerts = {}
for i, v in ipairs(rawVerts) do
local x, y, z = v[