0
\$\begingroup\$

I used a 16x16 sprite pack to make a 640x640 map in pygame:

enter image description here

The problem is that everything is extremely tiny. How could I go about making the expected "JRPG" look, like this for instance:

enter image description here

I have tried so far to double the size of the map tiles using pygame.transform.scale(tile,(32,32)) but that makes everything look terrible:

enter image description here

Here is how I am rendering the map:

import pygame
import pytmx
from pytmx.util_pygame import *

class tileRender:
    def __init__(self,filename):
        tm = pytmx.load_pygame(filename)
        self.width = tm.width * tm.tilewidth 
        self.height = tm.height * tm.tileheight
        self.tmxdata = tm

    def render(self,surface):
        ti = self.tmxdata.get_tile_image_by_gid
        for layer in self.tmxdata.visible_layers:
            if isinstance(layer,pytmx.TiledTileLayer):
                for x,y,gid in layer:
                    tile = ti(gid)
                    tile = pygame.transform.scale(tile,(32,32))
                    if tile:
                        surface.blit(tile,(x * self.tmxdata.tilewidth, y * self.tmxdata.tileheight))

    def makemap(self):
        temp_surface = pygame.Surface((self.width,self.height))
        self.render(temp_surface)
        return temp_surface

Is there a way of "zooming in" on the sprites in order to get the expected look?

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

You need to offset the tiles with the scaled size, not the original size. Currently you render at (x * self.tmxdata.tilewidth, y * self.tmxdata.tileheight), but instead you want to render at (x * 32, y * 32).

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .