PyGame Platformer Game Beginner Tutorial in Python - PART 5 | Adding Enemies

preview_player
Показать описание
In this Python tutorial I code a Platformer Game using the PyGame module. I'm going to cover the creation of enemies

Note, sprites and sounds are open source:

Check out my other PyGame tutorials:
Рекомендации по теме
Комментарии
Автор

As always, your tutorials are great, and easy to understand, thank you!

soupnoodles
Автор

I just enjoy watching these tutorials. You know when you say to your maths teacher "Yeah but Miss when will I ever use the 'abs()' function or the '//' floor operator. Booom this is it. A lot of other YouTubers use the Modular operator to flip Counters but the maths just does my head in.

garthwhitelum
Автор

i am getting this error:
Traceback (most recent call last):
File "C:\Users\Dino\PycharmProjects\main.py", line 221, in <module>
world = World(world_data)
File "C:\Users\Dino\PycharmProjects\\main.py", line 177, in __init__
blob = Enemy(col_count * tile_size, row_count * tile_size)
File "C:\Users\Dino\PycharmProjects\\venv\lib\site-packages\pygame\sprite.py", line 115, in __init__
self.add(*groups)
File "C:\Users\Dino\PycharmProjects\\venv\lib\site-packages\pygame\sprite.py", line 133, in add
self.add(*group)
TypeError: pygame.sprite.Sprite.add() argument after * must be an iterable, not int

dinadi
Автор

I used my own sprite for the enemy which isn't symmetrical, how can I get the enemy to change directions when it moves back and forth?

sekka
Автор

And what if I have, only one sprite moving?

ЄвгенРостиславовичМотрич
Автор

Hello, love ur vids. Could you tell me how to slow the enemies movement down?

xbrothers
Автор

There's still no limit for me on how many times i can push the jump button while my guy is in the air. Is this covered in a later video?

Grayhome
Автор

Great tutorial loving it so far!

I have a problem though maybe i can get some help here

My player sprite has a different rect size to the actual player image, so when I walk into the mobs, the player dies when it seems it is still quite far away.
I managed to create a secondary pseudo hitbox which I use with the collision with the tiles from the previous vid with colliderect() which works, but the same tactic can't be used here because the spritecollide() function takes the original player rect - I cannot pass my altered pseudo hitbox.

Please help!

googlyeyedhorsecrap
Автор

I'm new to python, and I have a question: is there a reason the blobs are made sprites instead of rectangles like the player? What would happen if all of the objects are rectangles/ sprites? What difference would it make? Thank you.

chungyanchow
Автор

can you teach me how to slow down the speed of enemies?

huiyeekee
Автор

Hey do I have to use a editor or can I use idle? For these tutorials

yotiis
Автор

How do you avoid collision with the screen width?

ishakantak
Автор

From where did you got those all Images?
I want to put my custom Images

rlspino
Автор

I get this errorTraceback (most recent call last):
File files\My Platformer.py", line 175, in <module>
world = World(world_data)
File files\My Platformer.py", line 142, in __init__
enemy_group.add(enemy)
NameError: name 'enemy_group' is not defined

saichamarthy
Автор

could you tell how to increase the speed of the enemies

arhambegani
Автор

What if I want the enemies to be animated?

knightmare
welcome to shbcf.ru