[pygame] creepy movement caused by gravitation

[pygame] creepy movement caused by gravitation

Postby kostik » Wed Jul 31, 2013 12:11 pm

This isnt my code but my code is almost the same with the same problem...when player is on the platform the movement of player becomes realy creepy....when player is on the platform, collision is happening and player.rect.x changes to old x position before collision(look at the code)....collision happend because of gravitation pulling on the player...and because this collision nonstop happening player has creepy movement...do anybody know how to fix it??
http://programarcadegames.com/python_ex ... _jumper.py
Last edited by metulburr on Thu Aug 01, 2013 3:15 am, edited 1 time in total.
Reason: edited title
kostik
 
Posts: 13
Joined: Tue Apr 16, 2013 10:26 am

Re: creepy movement caused by gravitation

Postby Mekire » Thu Aug 01, 2013 2:22 am

Ugghh... really starting to hate the examples on that site. Not well written. I'm not positive I know what you mean by "creepy movement," but I know what the problem is. When checking collisions against arbitrary objects, you can't just reset to the old location on collision.

Say my player's speed is 6 (which it is in this game) pixels per frame. Then let's say he is 5 pixels away from a wall. If we reset to the old location on collision and I try to walk toward that wall, I won't be able to get any closer (and 5 pixels is extremely noticeable). You need to check for collisions using while loops that decrement by single pixels until it is either found exactly how far you can move, or determined you can't move at all.

-Mek
User avatar
Mekire
 
Posts: 821
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: [pygame] creepy movement caused by gravitation

Postby kostik » Thu Aug 01, 2013 8:20 am

yes exactly!! sometimes the gap between the player and object is huge
kostik
 
Posts: 13
Joined: Tue Apr 16, 2013 10:26 am


Return to Game Development

Who is online

Users browsing this forum: Google [Bot] and 1 guest