added checkerpick test script with example for mouse motion selection on a grid
git-svn-id: svn://anubis/anaglym/trunk@308 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
7c7609045d
commit
89e065ebb5
1
.todo
1
.todo
@ -1,2 +1,3 @@
|
||||
add ag.pickOne
|
||||
add gradient functionality
|
||||
fix blending of overlay drawing routines
|
||||
|
26
tests/checkerpick.lua
Normal file
26
tests/checkerpick.lua
Normal file
@ -0,0 +1,26 @@
|
||||
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})
|
||||
hilite:setColor(0.3, 0.5, 1)
|
||||
hilite:setPosition(1, 1, 0.1)
|
||||
|
||||
ag.setCursorVisible(true)
|
||||
end
|
||||
|
||||
function mouse_motion_event(x, y, xrel, yrel)
|
||||
objects = ag.pickObjects(x, y)
|
||||
for i, obj in ipairs(objects) do
|
||||
if obj == ground then
|
||||
x = obj.pick_pos[1]
|
||||
y = obj.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
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user