diff --git a/.todo b/.todo index a89f511..aa4e6fa 100644 --- a/.todo +++ b/.todo @@ -1,4 +1,3 @@ add audio capabilities add fillCircle() add gradient functionality -reconcile mouse coordinates & 2D coordinates diff --git a/Engine.cc b/Engine.cc index 74abb67..27e4996 100644 --- a/Engine.cc +++ b/Engine.cc @@ -670,7 +670,7 @@ refptr< vector > Engine::pickObjects(int x, int y) forward[0], forward[1], forward[2]); initial_direction[0] = x - m_av.getWidth() / 2; initial_direction[1] = m_screen_dist; - initial_direction[2] = m_av.getHeight() / 2 - y; + initial_direction[2] = y - m_av.getHeight() / 2; dMultiply0(rotated_direction, r, initial_direction, 3, 3, 1); normalize(rotated_direction); @@ -1040,7 +1040,7 @@ void Engine::mousebutton_down_event(int button, int x, int y) EVENT_HANDLER_AG_NAME(mousebutton_down)); lua_pushinteger(m_luaState, button); lua_pushnumber(m_luaState, x); - lua_pushnumber(m_luaState, y); + lua_pushnumber(m_luaState, m_av.getHeight() - y); /* call the mouse button down event function * This pops the function ref and arguments from the stack */ int s = lua_pcall(m_luaState, 3, 0, 0); @@ -1056,7 +1056,7 @@ void Engine::mousebutton_up_event(int button, int x, int y) EVENT_HANDLER_AG_NAME(mousebutton_up)); lua_pushinteger(m_luaState, button); lua_pushnumber(m_luaState, x); - lua_pushnumber(m_luaState, y); + lua_pushnumber(m_luaState, m_av.getHeight() - y); /* call the mouse button up event function * This pops the function ref and arguments from the stack */ int s = lua_pcall(m_luaState, 3, 0, 0); @@ -1071,9 +1071,9 @@ void Engine::mouse_motion_event(int x, int y, int xrel, int yrel) lua_getfield(m_luaState, LUA_GLOBALSINDEX, EVENT_HANDLER_AG_NAME(mouse_motion)); lua_pushnumber(m_luaState, x); - lua_pushnumber(m_luaState, y); + lua_pushnumber(m_luaState, m_av.getHeight() - y); lua_pushnumber(m_luaState, xrel); - lua_pushnumber(m_luaState, yrel); + lua_pushnumber(m_luaState, -yrel); /* call the mouse motion event function * This pops the function ref and arguments from the stack */ int s = lua_pcall(m_luaState, 4, 0, 0);