Python Forum
[split] How to display isometric maps with pygame?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] How to display isometric maps with pygame?
#1
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:

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))
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!
Reply


Messages In This Thread
[split] How to display isometric maps with pygame? - by mattwins - Nov-15-2020, 05:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Isometric game pygame Tiled howardberger 1 713 Jan-31-2024, 10:01 PM
Last Post: deanhystad
  [PyGame] Cannot display anything inside pygame window the_gullwing 5 1,275 Dec-07-2023, 02:44 AM
Last Post: Benixon
  [PyGame] Isometric Movement on Tiled Map Josselin 0 2,410 Nov-02-2021, 06:56 AM
Last Post: Josselin
Thumbs Up [PyGame] Simple code for isometric 2D games ThePhi 1 15,425 Nov-17-2020, 12:58 PM
Last Post: mattwins
  [split] Apparently module has no attribute display? Angelo26 1 2,039 Mar-11-2020, 07:14 PM
Last Post: nilamo
  How to display isometric maps with pytmx? Piethon 18 10,211 Feb-19-2020, 04:33 PM
Last Post: nilamo
  [PyGame] How to Display pygame on SSD1351 screen kalihotname 0 1,918 Nov-11-2019, 07:32 AM
Last Post: kalihotname
  [split] Apparently module has no attribute display? Kolterdyx 1 2,871 Sep-09-2018, 05:14 AM
Last Post: buran
  [split] permission error on pygame install pyteach 7 8,306 Jan-23-2017, 11:00 PM
Last Post: pyteach

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020