GML Maintain low resolution look but with a smooth camera?

hdarren

Member
My game's base resolution is 256x144 and using the window_set_size() I can upscale the game to whatever size I like whilst maintaining that pixel perfect on-the-grid look. However this can make for a very janky camera as the view is also forced to the grid. I've tried using the surface_resize() function which gives a very silky smooth camera as it isn't forced to the grid, but unfortunately everything else is too which can make some image manipulations like using image_angle and image_scale go off-grid which loses that low resolution look.

So is there a way of making the camera have that silky smooth off grid movement, but make it so everything else sticks to the grid?
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
if you make the view two pixels larger (+1 in each direction) and draw it to a surface, you can then draw that surface in Draw GUI event while offsetting it as per sub-pixel offset
 

hdarren

Member
Hmm... thank you but I'm struggling to wrap my head around this. I have a Camera object that follows the player, and I made a Canvas object that now draws the application_surface to the screen via Draw GUI. But how do I work out what offset to use?
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Hmm... thank you but I'm struggling to wrap my head around this. I have a Camera object that follows the player, and I made a Canvas object that now draws the application_surface to the screen via Draw GUI. But how do I work out what offset to use?
The offset is merely the difference between where the view should be looking at (with fractions) and where the camera is showing it (rounded coordinates)
 

hdarren

Member
I'm very sorry I am not understanding the process.

1) In my room I have set the Camera Properties and Viewport Properties to have Width:258 and Height:146.

2) At the beginning of my game I use this code "window_set_size(256*4,144*4);" to upscale the game window so it isn't tiny.

3) In my Camera object it moves towards the Player object so it smoothly moves towards him. I use the camera_set_view_pos() function to set the camera (including fractions).

4) In my Canvas object in the Draw GUI I use "draw_surface(application_surface,0,0)" to draw the screen.

Is this the correct process to use? And which value would I use to get the correct fraction?

I'm very sorry for being dumb but the way cameras work with views and surfaces really confuses me. :(


///edited
I am trying to get the offset code but I don't know if I'm doing this correct.

Code:
if round(Camera.x) > Camera.x {vx = 1-(round(Camera.x)-Camera.x);}
else if round(Camera.x) < Camera.x {vx = Camera.x-round(Camera.x);}
draw_surface(application_surface,vx,vy);
It still appears janky so I'm unsure if this is the right track. :(
 
Last edited:
S

Simsure

Guest
@YellowAfterlife i'm sorry to bother, but i'm also facing this exact problem and had some difficulties applying your solution.
If you have time can please explain it step by step?
Thanks ❤
 
Top