Pygame Platformer Part 9: Using Spritesheets

preview_player
Показать описание
Loading graphics using spritesheets.

In each video in this series, we'll add another feature to our platformer until we have a full game experience with graphics, animations, sound, and much more!

Code for this part:

Other helpful links:
Рекомендации по теме
Комментарии
Автор

Thank you for sharing all this knowledge with us! It is a very generous act on your part!

lgbonfim
Автор

Great series! Thanks for all your hard work!

livingstone
Автор

Thank you so much for these videos Chris they have been a great help.

I would like to know how to loop over the .xml file though and get the dimensions and position data automatically

5:37

markg
Автор

I get an error message that python couldn't open img. Looks like this :pygame.error: Couldn't open

Mohawk
Автор

what if i dont have xml file with my spritesheet

vaibhavpandey
Автор

Getting this error: I followed everything to a T and got a missing attribute error. Game object has no attribute spritesheet. So how do we go about giving it this attribute?

aaronsanders
Автор

I've got a question:
There is a error message in the file "sprites.py" at "self.spritesheet =

The error message is"Traceback(most recent call last): pygame.error: Unsupported image format". How could i fix it?

junzhu
Автор

When we are on a platform, the collision detects the edge of the black Spritesheet, is there any way to make the rabbit falls when it exceeds from 1 pixel the platform edge ?

sawiix
Автор

Hi, this is a great video but what if I am using multiple sprite sheets, what would I do in this situation?

littleyoshifan
Автор

I have a question about what would we do if we were not to use a sprite sheet and just images

ech_exe
Автор

Doesn't the bunny still have collision on the places where the background used to be?

Brocolimanx
Автор

I'm using your tutorials for a school project, and i want to change the bunny to a bunny who is wearing a witches hat. I already adapted the bunny but do not know how to place the adapted version back in the game. Can you help?

p.s.
Автор

KidsCanCode How would you go about using single images, rather than a sprite sheet? I am following this tutorial but I am not using the same images, and my images don't have a sprite sheet form.

liamdodson
Автор

Thanks for the helpful videos Chris.

Do you have any tips on how to find out the dimensions of a spritesheet that does not include an xml file? Cheers

lukalyptus
Автор

Hi, if I just want to load a single image and not a sprite sheet where do I put these two commands:

img_dir = path.join(path.dirname(__file__), "img")
player_img = pygame.image.load(path.join(img_dir,

My doubt is if I put these two commands in settings sprites or main to load a single image

nunoesteves
Автор

Hi, I getting an error message after copying the code exactly. I've re-watched the video and I can't figure out what the problem is. The error message is in the "sprites.py" file on the line where it says "image.blit(self.spritesheet, (0, 0), (x, y, width, height))". The error is "SyntaxError: invalid syntax". I am using pycharm, but I don't know if that matters. Thanks!

edit:
I downloaded the copy of the file you provided in the description, and I realized I was missing a bracket after I defined get_image

EthanZemelman
Автор

Hi, so i ran into a problem again, this time its subjected to the import of the image from the spritesheet, when i entered the code to replace the cube with the bunny i got an error message saying that "image not defined", so i went on, thinking that i can go back later, entered the next line of code to get rid of the black background of the bunny and the transform line of code, and then i got this error:
Traceback (most recent call last):
File "G:\Programmering\Atom\PlatformGame\main.py", line 161, in <module>
g.new()
File "G:\Programmering\Atom\PlatformGame\main.py", line 39, in new
self.player = Player(self)
File "G:\Programmering\Atom\PlatformGame\sprites.py", line 22, in __init__
self.image = self.game.spritesheet.get_image(614, 1063, 120, 191)
File "G:\Programmering\Atom\PlatformGame\sprites.py", line 14, in get_image
image.blit(self.spritesheet, (0, 0), (x, y, width, height))
UnboundLocalError: local variable 'image' referenced before assignment

anyone who can help is a hero

Moldaq
Автор

First of all thanks for the tutorials, they are great. Is there a way to implement animated spritesheets?

ImEmaRose
Автор

Came here to learn how to use an XML file in pygame. Left super dissapointed that it was used as a reference map...instead of it's actual intended use.

Dr.Cosmar
Автор

I have a sprite I'm using that has black how would I remove the background black of the png without it causing my sprite to lose black?

KenwickVenture