From ea623bdf656ddb886ac807dd2ec635b6c1571e36 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 17 Sep 2010 14:48:24 +0000 Subject: [PATCH] changed tests/checkerpick.lua to use ag.pickOne() instead of ag.pickObjects() for efficiency git-svn-id: svn://anubis/anaglym/trunk@311 99a6e188-d820-4881-8870-2d33a10e2619 --- tests/checkerpick.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/checkerpick.lua b/tests/checkerpick.lua index 8bbca73..e94352d 100644 --- a/tests/checkerpick.lua +++ b/tests/checkerpick.lua @@ -11,16 +11,14 @@ function init_event() 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 + 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