> The only way to restrict cursor movement that I can think of would be to call Window#mouse_x= and #mouse_y= on every update, but this probably wouldn't work since the mouse obviously moves a lot faster than once every update_interval.
mouse_x/y=
are indeed built-in for that purpose, though they will work better in fullscreen mode.update
call, you would move the camera based on the new (real) cursor position and reset the (real) cursor to the center of the screen.mouse_x/y
will work seamlessly when the cursor is outside the window. For example, you can keep scrolling left as long as mouse_x
is between -50 and 50 and mouse_y
is between 0 and window.height
.mouse_x/y=
will work better in fullscreen mode ?
MouseTrap#initialize
method. You can set instance variables even if they have never been used or declared in initialize
.#update(window)
(basically delete all the @ signs).window.width
is not necessarily the width of the window in pixels. If you try to create a 8000x6000px Gosu::Window
, Gosu will automatically scale the window down to fit on the screen. However, window.width
will still return 8000
so that your calculations stay intact. This would break your script.GetClientRect
instead to retrieve the size of the window's contents in pixels.
tilable
attribute when instanciating the Gosu::Image
is no use) ? I think everyone knows what happens when stretching each tile individualy :)Window#record
method : my idea was to record the map as one Gosu::Image
and then scale that, but I found out that this actually has exactly the same effect since #record
actually returns a Gosu::Macro
and not a Gosu::Image
.Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill