Legacy GM Smoother view?

T

Tonydaderp

Guest
Hey guys, right now, I am making my new game called Nether. It is a metroidvania style game, but there is one problem. The player has a variable for gravity called _gravity. However, the value is set to 0.8 when it needs to (typical game maker gravity stuff). There is a view that follows the player. Don't worry, I know all about hbors and vbors and stuff XD. But since the gravity variable is a decimal, It may be the cause to the flicker view. Horizontal movement is fine, but when falling and jumping, the view gets flicker and distorts some pixels on the player sprite. Is this fixable by implementing something? If not, i'll just set the variable to a whole number. XD thx if u are reading this. XD
 

TheouAegis

Member
Player's Begin Draw event:
view_xview = clamp(floor(x)-view_wview/2,0,room_width-view_wview)
view_yview = clamp(floor(y)-view_hview/2,0,room_height-view_hview)

Set the view_object to noone.
 
M

Maximus

Guest
Just FYI, Nether is a first-person multiplayer survival game for Windows developed by Phosphor Games and was first available October 29, 2013.
 
T

Tonydaderp

Guest
Just FYI, Nether is a first-person multiplayer survival game for Windows developed by Phosphor Games and was first available October 29, 2013.
really? oh lol. I'll change title then. I'm nowhere near finished anyways.
 
T

Tonydaderp

Guest
hmm, it seems to work, but because my game has parallax scrolling backgrounds and gui huds, this mechanic doesn't work perfectly. Thanks a ton anyways! XD
 
M

Maximus

Guest
really? oh lol. I'll change title then. I'm nowhere near finished anyways.
Always good to google a name idea when you come up with it, because most of the time it has already been used for something especially with one word titles.

 

Joe Ellis

Member
I would use d3d_set_projection_ext, it still works in 2d mode and doesnt have to be snapped to the nearest pixel like a view, you can also zoom in and out with it quite easily by setting the z value to lower or higher, however zooming is probably not a good idea for pixel art, but with the vertical movement it should be fine and its infinitely smoother than a view as it can move by a really low decimal at a time. Game maker's default epsilon is 0.000001 or something.
 
I

icuurd12b42

Guest
You can also call d3d_set_projection_ortho, passing the view_ parameters except the view_x/view; for those you can pass the values as calculated by TheouAegis, but without using floor in the math. This will allow smooth scrolling on zoomed in view. this need to be called in the draw event in an object that draws first
 

Joe Ellis

Member
Yeah I was gonna say about d3d_set_projection_ortho, its just I've never used it myself so didn't wanna write anything misleading.
 

TheouAegis

Member
really? oh lol. I'll change title then. I'm nowhere near finished anyways.
You don't have to change the title if the title is simply a pre-existing English word. People write songs with the same titles all the time. If you're really worried about it, just call it "The Nether".
 

NightFrost

Member
You can also call d3d_set_projection_ortho, passing the view_ parameters except the view_x/view; for those you can pass the values as calculated by TheouAegis, but without using floor in the math. This will allow smooth scrolling on zoomed in view. this need to be called in the draw event in an object that draws first
This got me curious as I've never touched 3D in GM before. I did some quick testing but with poor results. I suppose views must be off the start with, and background needs to be handled in some specific manner?
 
I

icuurd12b42

Guest
This got me curious as I've never touched 3D in GM before. I did some quick testing but with poor results. I suppose views must be off the start with, and background needs to be handled in some specific manner?
d3d_set_projection_ortho is the function studio uses to set a view position and size. The problem is the vew_xview and view_yview are integers in the engine, making the view in zoomed in game move in a pixelated way.

You can remedy this by calling the function yourself using the fractional position that a fraction movement results in.

This does not change the behavior of anything in the game.
 
The problem is the vew_xview and view_yview are integers in the engine
Really? I've most certainly used non-whole numbers to position my view, especially when my application surface is larger than my view. So is this really necessary? What will this do if your application surface and view are the same size? ...I should really go play with this.
 
I

icuurd12b42

Guest
unless they fixed this... if you are zoomed in a view in room of say 200x100 and your port is 800x400. the view will jump 1 view pixel or 4 port pixels...
 
unless they fixed this... if you are zoomed in a view in room of say 200x100 and your port is 800x400. the view will jump 1 view pixel or 4 port pixels...
This is definitely still true if you are using the built in view object following, but if you are manually positioning the view xview and view yview (say with something like view_xview=x-view_wview/2) it works fine. It's still a good idea to round the value as you an sometimes see "lines" between tiles and other distortions, but you don't have to round it to a whole number. If your app surface is twice the size of your view, you can round it to the nearest .5.
 
T

Tonydaderp

Guest
Thank you all, guys! I decided just to change the variable to a whole number XD.
 
Top