anaglym/tests/checkerpick.lua
Josh Holtrop 11da99b3ad added ag::object::setTransparency() and Engine::Object::setTransparency()
git-svn-id: svn://anubis/anaglym/trunk@316 99a6e188-d820-4881-8870-2d33a10e2619
2010-09-17 17:02:28 +00:00

26 lines
798 B
Lua

function init_event()
local checker_texture = ag.loadTexture("checker.jpg")
ground = ag.createBox(8, 8, 0.1, {static = true})
ground:setTexture(checker_texture)
ag.setCamera(10, -10, 10, 0, 0, 0)
hilite = ag.createBox(2, 2, 0.1, {static = true, enable_blending = true})
hilite:setColor(0.3, 0.5, 1)
hilite:setPosition(1, 1, 0.1)
hilite:setTransparency(0.4)
ag.setCursorVisible(true)
end
function mouse_motion_event(x, y, xrel, yrel)
local hit = ag.pickOne(x, y, ground)
if hit then
x = ground.pick_pos[1]
y = ground.pick_pos[2]
xp = 2 * math.floor(x / 2) + 1
yp = 2 * math.floor(y / 2) + 1
if xp >= -3 and xp <= 3 and yp >= -3 and yp <= 3 then
hilite:setPosition(xp, yp, 0.1)
end
end
end