1
You need to use elif for your second conditional, not just if. If I role-play as your computer real quick with my self.rect.x value to something less than zero, this is what I say:
if (self.rect.x < 0):
self.rect.x = SCREEN_WIDTH
Oh, OK! self.rect.x is less than zero, so I'll set it equal to SCREEN_WIDTH! Onward to the next line!
if (self....
1
The solution in my case was simple, check if the tile is 'None'. If yes, then pass it, but if not, transform it to a larger size. This is the full code that should be used:
class TiledMap:
def __init__(self, filename):
tm = pytmx.load_pygame(filename, pixelalpha=True)
self.width = tm.width * tm.tilewidth
self.height = tm.height * ...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
pygame × 364python × 258
collision-detection × 46
sprites × 24
2d × 17
rotation × 10
vector × 9
input × 9
collision-resolution × 9
opengl × 8
tilemap × 8
rpg × 8
keyboard × 8
camera × 7
game-loop × 7
optimization × 7
image × 7
physics × 6
animation × 6
game-mechanics × 6
software-engineering × 6
3d × 5
mathematics × 5
rendering × 5
graphics × 5