Hello! I'm a noob at python and pygame, also forgive for possible english mistakes, i'm actually from Brasil. I'm creating a plataform game using tilemaps and loading it with Richard's Jones tmx library, and i have come across a "bug": When i'm moving my character around, he goes faster to the left and down directions. First, i thought it was an error with my code, but after making differents test's using 20-scenes.py, written by Richard Jones, i've realized that this problem ocurrs with his game. If you press both the left and the right arrows together you will see that the caracter has the tendency of going left, also all the objects (Bullet, enemy, Player...) can't have a speed bellow 20 pixels/second (in my game, you can't set a speed bellow 31 pixels/second) otherwize it can't move to the right direction. What is the source of the problem? How do i fix it?

to be honest, once i saw your code *not* in code tags, i didnt even read your first few paragraphs, ill read them when i see that you added code tags, check my signature for new users info on code tags.

metulburr wrote:to be honest, once i saw your code *not* in code tags, i didnt even read your first few paragraphs, ill read them when i see that you added code tags, check my signature for new users info on code tags.

Well I have never bothered with TMX as usually write a tile loader to fit my own needs but...

The problem with the player favoring left when pressing both left and right sounds like it is just part of your key/event handling. I handle this by creating a list of direction keys as they are pressed and popping the key from the list when it is released. The player's direction is always the last element of the list. The minimum speed thing sounds like a rect issue. Rects can only hold integers, so if you add a fractional amount directly to the rectangle coordinates, it will be truncated/ignored. If you require speeds that would entail your location to get changed by fractional pixels, you will have to store the data in another object that can hold floats (probably just a list).

Mekire wrote:The problem with the player favoring left when pressing both left and right sounds like it is just part of your key/event handling.

That's why i posted my enemy object, to show that the problem has nothing to do with key/event handling

Mekire wrote:The minimum speed thing sounds like a rect issue. Rects can only hold integers, so if you add a fractional amount directly to the rectangle coordinates, it will be truncated/ignored. If you require speeds that would entail your location to get changed by fractional pixels, you will have to store the data in another object that can hold floats (probably just a list).

Yeah, that would explain it, if it wasn't for the fact that to the left and down directions the minimum speed acctually is 21 pixel/second. Another thing is that doesn't matter the speed, the objects go faster to the left and down directions aniway

31 pixels a second still yields a value over 1 so you can still add it to the rect. 30 pixels per second however yields a value under 1. If you try and change a rect coordinate by a fraction of a pixel in one direction, it won't change. In the other it will.