Python Forum

Full Version: Pygame 2d game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need help, I am writing a 2D game in the library pygame, I need to add monsters and logic to monsters who attack the main character, I know that I need a class and register the logic in the main cycle, but I don’t know how to implement it. I ask for help. stuff on https://github.com/Maximk301/2dgame
If they are just walking towards your main character then the logic for that is to move them towards the character until they are close enough to attack (Whatever that may be). Then check for collision, if so, then reduce player health. If zombies collide with characters weapon then reduce their health, or kill them, etc. This is the basic concept. To do this is slightly different based on topdown, side scrolling, etc. game play, but it is basically the same. You can check our tutorials which include the enemy class. Part 1 through 8 is a series creating a vertical scrolling space shooter. The logic can be mostly adapted for a side scroller. The enemies section is part 6.