Nov-15-2020, 05:57 PM
I'm not using pytmx - but this has been helpful for me to be able to see calculations in creating an isometric map.
I'm having trouble making my tiles blit properly with offsets like you did above. Without the offsets, they look just like OP's problem.
With the offsets added (I'm sure I'm messing up xD - do they get set to rect.x and rect.y?) - I don't see any tiles at all.
Here is my non-working implementation of your code:
As of now, I've manually entered all of the values for ease of testing:
Tile Width = 62
Wile Height = 32
Display Width = 2976 (for this map)
I appreciate any thoughts or feedback you may have!
I'm having trouble making my tiles blit properly with offsets like you did above. Without the offsets, they look just like OP's problem.
With the offsets added (I'm sure I'm messing up xD - do they get set to rect.x and rect.y?) - I don't see any tiles at all.
Here is my non-working implementation of your code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class Tile(pygame.sprite.Sprite): def __init__( self , image, x, y, spritesheet): pygame.sprite.Sprite.__init__( self ) self .image = spritesheet.parse_sprite(image) self .rect = self .image.get_rect() # Get offsets x_offset = ( 2976 / 2 ) + ( 62 / 2 * (x + 1 )) - ( 62 / 2 * (y + 1 )) y_offset = ((y + 1 ) * 32 ) + ( 32 * x) # Set offsets for rect self .rect.x, self .rect.y = x_offset, y_offset # Rotate image self .rotated_image = pygame.transform.rotate( self .image.convert_alpha(), 45 ) def draw( self , surface): surface.blit( self .rotated_image, ( self .rect.x, self .rect.y)) |
Tile Width = 62
Wile Height = 32
Display Width = 2976 (for this map)
I appreciate any thoughts or feedback you may have!