• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Sub-pixel Camera Movement in GM2

D

DiscivilObedience

Guest
So I'm not sure if this has already been addressed for gamemaker 2.

I'm trying to figure out how to move the camera at sub-pixel increments for my game. I actually had this working in the older version of gamemaker but I wanted to upgrade. I am used to using views instead of this new camera system. My first attempt used those set_camera_view commands that seem to be the replacements for the view system in old GM. I'd like to try and stick with views as I have no need for camera functionality in the game. Does anyone know how to move a view at sub-pixel increments in the new system? Thanks!
 

samspade

Member
I would watch this as it is probably the simplest and easiest to understand GMS 2 Camera Tutorial.


As far as sub pixel, I think you achieve that by scaling the application surface, but I'm not sure. I'll let someone else answer that. There are also a lot of forum posts on the subject you could find by searching.
 
D

DiscivilObedience

Guest
Thanks a ton! This solved my issue and the camera is moving at subpixel increments now!!
 
Last edited by a moderator:
C

Christopher Rosa

Guest
can you post your code for the subpixel increments i'm having the same issue :(
 

NightFrost

Member
The video, linked above, covers all you need to know. You don't need to address subpixels in any special manner in your movement code. One thing I recall the video glossing over a little is the draw phase; when the view is taken from your room and drawn to application surface, coordinates get multiplied by the ratio between the two. Then, because partial pixels do not exist they are rounded to nearest application surface pixel.

Worth noting: some people coming from GMS1.4 may be in the habit of rounding coordinates in Draw Event sprite draw commands. That shouldn't be done with this method as it results in janky movement (unless your movement is in integers only). I assume the coordinates are getting rounded to room space coordinates before they get multiplied to application surface space.
 
Top