anaglym/tests/managed_objects.lua
Josh Holtrop f07e0b69f3 adding AMotors works! added test to managed_objects.lua
git-svn-id: svn://anubis/anaglym/trunk@236 99a6e188-d820-4881-8870-2d33a10e2619
2010-01-31 02:19:37 +00:00

48 lines
1.3 KiB
Lua

function init_event()
local crate_texture = ag.loadTexture("checker.jpg")
local ground = ag.createPlane(0, 0, 1, 0)
ground:setColor(0.2, 1.0, 0.2)
ground:setTexture(crate_texture)
ag.setCamera(10, -10, 10, 0, 0, 0)
if (ag.import("rot_camera") ~= true) then
ag.println("error importing rot_camera")
ag.exit()
end
end
function init_obj(obj)
obj:setColor(math.random(), math.random(), math.random())
obj:setPosition((math.random() - 0.5) * 10, (math.random() - 0.5) * 10, 10)
end
-- function update_event()
-- rot_camera()
-- end
function key_down_event(key)
if (key == "b") then
local box = ag.createBox(1, 1, 1)
init_obj(box)
elseif (key == "c") then
-- cylinders are buggy in ODE
local cyl = ag.createCylinder(0.5, 1)
init_obj(cyl)
elseif (key == "a") then
local ccyl = ag.createCapsule(0.5, 1)
init_obj(ccyl)
elseif (key == "s") then
local sphere = ag.createSphere(0.8)
init_obj(sphere)
elseif (key == "q") then
ag.exit()
elseif (key == "r") then
-- creating a rotating cube
local box = ag.createBox(1, 1, 1)
init_obj(box)
ag.createAMotor(0, box,
{ x = 0, y = 0, z = 1, vel = 10, fmax = 10 })
end
end