Pygame Tile Based Game Tutorial: Tilemaps

preview_player
Показать описание
In this video, we'll discuss tilemaps. We'll learn how we can create them using Tiled, as well as how we can parse them into pygame.

Music:
Pokemon Gold/Silver/Crystal - Violet City, Azalea town

#pygame #tiled #gamedev
Рекомендации по теме
Комментарии
Автор

I tried to teach my son some coding, he loves drawing games on paper and this shows in easy steps how to use pygame. He can spend the rest of his life frustratedly scrolling through stackoverflow, but I'm excited how you explain how you start from zero making something appealing and repeatable.

rubixsolution
Автор

man, I've always thought that making tile-based games was a pain due to having to take each tile and cut it out by inserting it into the folder with the number that tiled assigned. This tutorial completely turns the table! thanks!

dicember
Автор

this is the same method i was already using except i had to manually input the tile ids in the csv. glad that i dont have to rewrite the entire game... again.

zurrty
Автор

Great explanation of how to build a tile base map for a python game. That tile app was very helpful.

brianmehrman
Автор

I guess I'm a little late but this is still informative. Thank!
Also, if you havn't used it, enumerate() makes those 'for' loops much prettier.

apalladiumk
Автор

everything works for me until the part where you use the spritesheet. How can I do it without the sprite sheet (im new to pygame so...) PLEASE HELP (great video btw :D)

loicharvey
Автор

Great video, I am trying to do something similar, however I will not use the spritesheet, The problem is that it takes to long to load the game.

saulvilchez
Автор

I don't use python but you made it interesting, I use rust. But it's seems the same infact I use tiled

iamgabrielsoft
Автор

You got my like and my subscribe fairly easy!👌

GodotEnjoyer
Автор

I got an import error: cannot import name 'Spritesheet' from 'spritesheet', also pygame has no init, QUIT and KEYDOWN, I don't know if you could help me find out why I get those

TorikoGZ
Автор

Amazing video, I have a question though. When loading the tile images you say that it creates a Tile object (7:34), but my code doesn't seem to recognise that object, it simply says that "name 'Tile' is not defined". Do I need to define a Tile object elsewhere beforehand? If so, please explain how. Thanks, and again great video!

Edit: Hold on I've found the Tile object code, should have paid more attention! Finding what I did wrong

Edit 2: Whoops, I had Tiles named something else! Fixed it.

BlueBear
Автор

Thanks man! I Just made the map and its kinda getting late sa tomorow i am going to follow this wonderful tutorial. I am curently making a 2d game in pygame so ye

brhvoicu
Автор

This is a good tutorial and works well for the tutorial but I'm having trouble transferring it over to a real game. When trying to implement it into my own game with a larger map and where I will need the tiles to scroll/move I don't see exactly how we are suppose to do that with this code. It looks as though all the tiles get drawn once right at the beginning and that's it. Has anyone had a similar problem and solved it?
EDIT: I noted around 9:28 you said I would have to store them in a separate list and draw them every frame could you explain this a bit more please?

jamestogher
Автор

Is there a reason you didn’t use pytmx? Also could you show how you use 2 levels. I assume it’s similar to your menu video. But i struggle with over elaborate level switches that are buggy. I’d love to see your solution.

danwalker
Автор

I’m enjoying your videos, may I you combine the Menu system videos with your pytmx videos so that it feels like 1 game.

danwalker
Автор

I had closed the tilesets option at the bottom right by mistake in the tiled app how to get it back anyone please respond fast

vamsipreetham
Автор

This code is amazing but have a question:
how could I implement collisions for tiles in a selected layer (i've used your code but made a multi-layered map)
as I want to get my character to collide with certain layers but i don't know how to make it so when it loads the tile map layer that it gives each tile a rect that the player will collide with to save time and lines of code

joewhitters
Автор

Hoenn, Sinnoh and Kalos music Johto Music

SMCwasTaken
Автор

i didnt quite get the file name thing,

thenamewhowillknockksidown
Автор

I have a question. I have like lots of different pictures or tiles that don't have names. What do I do here? in the json file, it doesn't specifically say any names about the tiles. It says something like this:

{ "columns":18,
Project\/Grounds 1-100\/Block-Land-16x16\/World-Tiles.png",
"imageheight":1392,
"imagewidth":288,
"margin":0,
"name":"Mario Tileset",
"spacing":0,
"tilecount":1566,
"tiledversion":"1.10.2",
"tileheight":16,
"tilewidth":16,
"type":"tileset",
"version":"1.10"
}


I just went to the tile set in the tile editor and exported the tile set as a json file. I don't know what to do here. Notice how each tile doesn't have a name. And even if I do have names, should I just cite like 200 of them all?

for row in map:
x = 0;
for tile in row:
if tile == '0':
self.start_x, self.start_y = x * self.tile_size, y * self.tile_size;
elif tile == '1':
tiles.append(Tile('Map/World-Tiles.png', x * self.tile_size, y * self.tile_size, self.spritesheet));
elif tile == '2':
tiles.append(Tile('Map/World_Tiles.png', x * self.tile_size, y * self.tile_size, self.spritesheet));

I'm confused.

servantofourlordjesuschris