Legacy GM Why does object shake while jumping/falling?

C

camscottbryce

Guest
[I apologize in advance because I've already posted in this forum asking for help with every single problem I encountered. Believe me when I say I have searched through other posts/the GM Help stuff for a solution, but I'm just too dumb to figure it out]

When my player object falls, the object shakes (I believe it is the object and not the view). I'm not entirely sure why. I wondered if it had something to do with the fact my jump speed/gravity are not whole numbers, but I don't see that being the case. I'll post a video so you can see what I mean (please note that all the sprites are all placeholder, they're kinda silly, etc. etc.).


If you'd like to take a look at the game files, you can download the project file here: https://drive.google.com/file/d/0B6-J1QIOsrBLXzd1V3dFNzBQd1k/view?usp=sharing (just click the download button at the top).

Any help would be appreciated. I'm just trying to get some of the "basics" of my game down before anything else, so I'd rather nail out these issues now.
 
C

camscottbryce

Guest
maybe it's your sprites origin, are you using only one sprite?
For now, yes it is only one sprite. What should the origin be in this instance/why would that affect it? (Out of curiosity).
 
C

camscottbryce

Guest
try setting your sprite's origin centered, if you do change your sprite while jumping or falling, your sprites origin must remain consistent or you'll get something like that

have you been using view codes? or ch view tab?
Changing the origin of the sprite did not help.

As for the view, I've been using the view tab in the room editor. The settings are view/port : 480 x 270, and hbor: 240 (-1) vbor: 135 (-1).
 
C

camscottbryce

Guest
@camscottbryce can you tell me the program you used to capture your desktop please? I've been looking forever for one that doesn't lag and works well.
The one I use is NVIDIA's Shadowplay. It's a shame that Shadowplay requires specific GPU's to run, it is the best recording software I've ever used.
 
C

camscottbryce

Guest
what about your jumpspeed/gravity? your values and how do you compute them?
In the create event I set up several variables: grav = 0.16, jumpspeed = 4.6.

This is the only code (I believe) that deals with jumping/those variables.

Code:
if (vsp < 10) vsp += grav;

if (place_meeting(x,y+1,solid_16))
{
    vsp = key_jump * -jumpspeed
}
If you'd like to take a more in depth look, the file is in the OP (not that you have to, I'm here to provide all the info, but in case you missed it/felt inclined).
 
C

camscottbryce

Guest
have you tried making your jumpspeed a whole number?
and that number is divisible by your gravity without any remainder?
like
grav = 0.2, jumpspeed = 5

so when gm computes your vsp += grav
5-.2 = 4.8 - .2 = 4.6 ... to a flat 0

that's all i can think of, maybe others will reply soon
Yeah, sadly I have tried that, and it did not work. Thanks for your thoughts though, hopefully some other replies filter through soon.
 

M. Idrees

Member
Set the room_view hsp & vsp to 4
Set also hbor to half of you room width and vbor to half of your room height
and then check again.
 
C

camscottbryce

Guest
Set the room_view hsp & vsp to 4 and then check again.
That didn't change anything. It appears as though the object is shaking, not the view (could be wrong though). But yeah, the room_view hsp vsp didn't change anything.
 

M. Idrees

Member
Your Project file missing files can't load in GMS
You have to Export your project to gmz file and then upload it
 
S

seanm

Guest
simple fix would probably be to draw your sprite with floor(y) as an argument.

other than that there are a loooooooooooooot of things you could do to prevent this. all good or bad for different reasons
 

Bingdom

Googledom
It's because your view is small. Your player is moving by pixels, not half pixels. You can help prevent this by increasing room speed or making your view and room bigger
 
C

camscottbryce

Guest
It's because your view is small. Your player is moving by pixels, not half pixels. You can help prevent this by increasing room speed or making your view and room bigger
Room speed is 60. And this issue happens when the view port is 1920x1080 (though it happens on a smaller scale because it's masked by more pixels). i don't think those are the issues, but I've been wrong before.
 

M. Idrees

Member
seanm method working for you put this code in your player [ Draw Event ]
Code:
draw_sprite(sprite_index,image_index,x,floor(y));
 
C

camscottbryce

Guest
seanm method working for you put this code in your player [ Draw Event ]
Code:
draw_sprite(sprite_index,image_index,x,floor(y));
Okay, this solves the weird shaking issue, but now occasionally the sprite lands (from jumping) and appears to be floating above the ground 1 pixel. as seen in this image:
FloatingMan.png
( http://imgur.com/a/FxyQV )

Any idea why this would be? also what exactly does this code do? Can it be used for sprites with multiple frames/speeds?
 
C

camscottbryce

Guest
LOL - anyone read my post? :p
Yeah, sorry, was getting to yours, was just trying to address Zee first! That sounds good, but any chance you could elaborate on using a controller object? You use another object to determine the player object's sprites, animation speeds, etc.?
 
S

seanm

Guest
That might be it @Lonewolff, but it also might just be the fact that the player is moving by subpixel increments, and so it bounces around when the view tries to follow it.

@camscottbryce basically, making a low resolution game is a pain in the ass. To avoid that issue entirely, im assuming there is a line in your physics code that looks like this

Code:
y+=vspd
change it to

Code:
y+=round(vspd)
 
C

camscottbryce

Guest
That might be it @Lonewolff, but it also might just be the fact that the player is moving by subpixel increments, and so it bounces around when the view tries to follow it.

@camscottbryce basically, making a low resolution game is a pain in the ass. To avoid that issue entirely, im assuming there is a line in your physics code that looks like this

Code:
y+=vspd
change it to

Code:
y+=round(vspd)
That worked, no problems with this method. That said, you mentioned before that some of this could be "good or bad" for different reasons. Is there a downside to rounding?
 
S

seanm

Guest
In this case the downside is just how it looks, and how it will look if you scale the screen.

I wouldn't worry too much about it. There are more important things for you to be spending your time on right now.
 
C

camscottbryce

Guest
In this case the downside is just how it looks, and how it will look if you scale the screen.

I wouldn't worry too much about it. There are more important things for you to be spending your time on right now.
yeah, I'm moving on for now but to me it looks fine with that fix, at various port sizes etc., everything is smooth and centered. Thanks for your help.
 

TheouAegis

Member
I can't remember the hwole discussion, but there's also the rounding method of using int64() instead of floor(), ceiling() or round().
 

TheouAegis

Member
int64() rounded off differently than the other functions. I think there was an issue with negatives, though, so I don't know. I think it was on the old forums.
 
M

MrPerson561

Guest
simple fix would probably be to draw your sprite with floor(y) as an argument.

other than that there are a loooooooooooooot of things you could do to prevent this. all good or bad for different reasons
I'm pretty sure I'm having exactly the same problem. I tried x+=round(hsp) and y+=round(vsp) and it worked, except that rounds my movespeed too I think, so I'm either going too fast or too slow. What are some of the other things you could do to prevent this?
 
S

seanm

Guest
Well I'm assuming your resolution is quite low, to the point where one pixel moves your sprite a large amount.

You could keep track of a virtual position and only update your players real position when the virtual position crosses over into a new integer.

You could try just making sure your speed variables are always integers (no decimal points)

You could scale all of your assets up, thus making a single pixel move the sprite half as far.

I mean there is a ton of stuff you could do. Unfortunately you're just going to have to debug your own game and see what works best for you. Try and find the source code of a game that doesnt have this problem from somewhere.
 

TheouAegis

Member
Draw everything to a custom surface and render the surface? This ain't GM8 though, so maybe it doesn't work like that anymore.
 
Top