Add tilemap
This commit is contained in:
commit
5d90f719cb
31
cafe.tmx
Normal file
31
cafe.tmx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map version="1.8" tiledversion="1.8.2" orientation="orthogonal" renderorder="right-down" width="20" height="20" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||||
|
<editorsettings>
|
||||||
|
<export target="cafe.json" format="json"/>
|
||||||
|
</editorsettings>
|
||||||
|
<tileset firstgid="1" source="../cafe1.tsx"/>
|
||||||
|
<layer id="1" name="Warstwa Kafelków 1" width="20" height="20">
|
||||||
|
<data encoding="csv">
|
||||||
|
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,
|
||||||
|
7,8,10,10,8,8,8,10,10,8,8,8,10,10,8,8,8,10,8,12,
|
||||||
|
13,10,16,17,10,8,10,16,17,10,8,10,16,17,10,8,10,9,10,18,
|
||||||
|
13,8,10,10,8,8,8,10,10,8,8,8,10,10,8,8,8,10,8,18,
|
||||||
|
7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,12,
|
||||||
|
7,8,10,8,8,10,8,8,10,8,8,10,8,8,10,8,8,10,8,12,
|
||||||
|
7,8,9,8,8,9,8,8,9,8,8,9,8,8,9,8,8,9,8,12,
|
||||||
|
7,8,10,8,8,10,8,8,10,8,8,10,8,8,10,8,8,10,8,12,
|
||||||
|
13,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,18,
|
||||||
|
13,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,18,
|
||||||
|
7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,12,
|
||||||
|
7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,12,
|
||||||
|
7,8,10,8,8,8,10,8,8,8,8,8,8,10,8,8,8,10,8,12,
|
||||||
|
7,10,9,10,8,10,9,10,8,8,8,8,10,9,10,8,10,9,10,12,
|
||||||
|
7,8,10,8,8,8,10,8,8,8,8,8,8,10,8,8,8,10,8,12,
|
||||||
|
13,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,18,
|
||||||
|
13,8,10,8,8,8,10,8,8,8,8,8,8,10,8,8,8,10,8,18,
|
||||||
|
7,10,9,10,8,10,9,10,8,8,8,8,10,9,10,8,10,9,10,12,
|
||||||
|
7,8,10,8,8,8,10,8,8,8,8,8,8,10,8,8,8,10,8,12,
|
||||||
|
25,27,27,27,27,27,27,27,27,28,29,27,27,27,27,27,27,27,27,30
|
||||||
|
</data>
|
||||||
|
</layer>
|
||||||
|
</map>
|
9
cafe1.tsx
Normal file
9
cafe1.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<tileset version="1.8" tiledversion="1.8.2" name="cafe1" tilewidth="32" tileheight="32" tilecount="30" columns="6">
|
||||||
|
<image source="../Downloads/cafe1.png" width="192" height="160"/>
|
||||||
|
<tile id="9">
|
||||||
|
<properties>
|
||||||
|
<property name="chair" value=""/>
|
||||||
|
</properties>
|
||||||
|
</tile>
|
||||||
|
</tileset>
|
29
tiles.py
Normal file
29
tiles.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import pygame
|
||||||
|
import pytmx
|
||||||
|
|
||||||
|
pygame.init()
|
||||||
|
|
||||||
|
display = pygame.display.set_mode((640,640))
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
|
gameMap = pytmx.load_pygame("cafe.tmx")
|
||||||
|
|
||||||
|
while(True):
|
||||||
|
|
||||||
|
clock.tick(60)
|
||||||
|
keys = pygame.key.get_pressed()
|
||||||
|
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if(event.type == pygame.QUIT):
|
||||||
|
quit()
|
||||||
|
|
||||||
|
if(keys[pygame.K_ESCAPE]):
|
||||||
|
quit()
|
||||||
|
|
||||||
|
for layer in gameMap.visible_layers:
|
||||||
|
for x, y, gid, in layer:
|
||||||
|
tile = gameMap.get_tile_image_by_gid(gid)
|
||||||
|
if(tile != None):
|
||||||
|
display.blit(tile, (x * gameMap.tilewidth, y * gameMap.tileheight))
|
||||||
|
|
||||||
|
pygame.display.update()
|
Loading…
Reference in New Issue
Block a user