O'Reilly logo

Lua Game Development Cookbook by Mário Kašuba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moving the window

In some situations, it may be desirable for the user to be able to move the window to different places. There are many ways to achieve window movement. This recipe will show you how to use matrix operations to apply correct drag and drop movements in various situations.

Getting ready

First, you'll need to have the working event system from the LuaSDL library to catch the input from your mouse device. There are two kinds of events you'll want to detect: mouse movement and mouse button presses/releases. The most important part of this process is obtaining the mouse cursor position on the application window.

The last component of this recipe that you'll need is the window's model-view matrix. This will be used to determine the mouse ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required