Complete Tower Defence Tutorial in Pygame From Scratch
HTML-код
- Опубликовано: 8 июн 2024
- In this Python tutorial I code a tower defence game using the PyGame module. The video goes through the full process from scratch, creating the map, the turrets, enemies and their waypoints.
Code & assets on github: github.com/russs123/tower_def...
Credits for assets used:
Tileset: www.kenney.nl/assets/tower-de...
Turrets: zintoki.itch.io/ground-shaker
Heart: nicolemariet.itch.io/pixel-he...
Coin: totuslotus.itch.io/pixel-coins
Timestamps:
00:00:00 Intro
00:06:27 Create Enemy
00:16:23 Waypoints & AI
00:31:10 Load Level Map
00:46:45 Placing Turrets
01:02:51 Adding Buttons
01:17:48 Animations
01:30:57 Aiming and Firing
01:47:28 Upgrading Turrets
02:00:16 Automatically Spawn Enemies
02:14:59 Game Mechanics
02:27:14 Game Over Handling
02:49:38 Finishing Touches
This is a combined version of my tower defence tutorial series for those who prefer one longer video with chapters!
Thanks for putting this all in one vid, I like to watch these from start to end in 1 sitting generally
You're welcome!
Making a tower defense game using pygame in my advanced coding class, this tutorial helped A BUNCH! Glad you uploaded it all in one.
Thank you for putting these videos up on the internet, they make my summer break a lot more intresting with some games!
Thanks, glad you liked them :)
Hey russ ,
lately i wanted to get into programming and game dev i picked up the basics of python and i randomly watched your 2 years of game dev video which really inspired me
I am currently watching your old tutorials and I'm learning alot
Thank you so much for your help and inspiration
That's great to hear! Good luck on your game dev journey :)
@@CodingWithRuss thank you sm,
I have an idea for a tutorial if you don't mind
It's a simple 2d hack and slash game with ai for enemies
Hi Russ! Your videos are great, I'm just getting into coding and I'm really enjoying making games, I've followed 3 of your tutorials so far, I think Battle and this TD ones will be the ones I try to work on the most, I really likes games of these two styles. You mentioned to ask for a tutorial on Tiled if we are interested, well I'm interested! If you could somehow add in a way to make the computer not necessarily follow a pre-defined route too that would be great. The best TD I ever played was one where you are free to place your toweres how ever you like, so you make the monsters go through a maze and pass as many towers as possible as many times as possible.
Thanks for all the tutorials, you helped me a LOT :)
Glad to hear that!
I enjoyed these and learned so much!
Awesome! Thank you!
Thanks, this video was super helpful! 🙏
Glad to hear it!
"Hmm, maybe I will finally stop fuzzing around and procrastinating learning to code, trying to make games for fun and motivation *think*" Russ: Here, bro! 🤘
(Not just the typical random comment, legit problem and HOPEFULLY the solution lol 😬😆)
Haha thanks! Sound like good timing :)
@@CodingWithRuss Yesss Boss! Gimme more, gimme more! 😀
Never mind one of your older videos helped :)
hey Russ your videos are really helpful and made me grow alot in programming I just wanna ask that can you make a video on different types of camera's in pygame (from scratch) i've been struggling with camera's in pygame thank you
I've been trying to make a 3d Geoscape like the original Xcom, would love a video like that :D
Oh...
Real Nice...
A masterpiece...
Thanks! Glad you like it
@@CodingWithRuss
You are welcome and I thank you.
I like this tutoirla
10 mins in and your already in my top 3 😂
Nice! 😎
Really good tutorial! This can really be expanded and tuned by tweaking the constants & enemy_data.
I also found a bug when you kill all enemies on the final level (i.e. win) and the game interprets this as 'wave finished' and tries to run world.process_enemies() - which throws index out -error. I solved it by adding a check if world.level > Total_levels inside check_level_complete...
Ah good catch! And thanks for providing the fix
Hi Russ! Thanks for this Tutorial. But can you make a video about Tiled so I can know how to use it? Thanks :)
Hi Russ, I just wanna start by saying that your tutorials helped me so much with game development and Python in general. I was wondering if you have any tips on how to remember all this stuff, there's so much to learn and I just keep on forgetting everything. Thanks.
Thanks, glad you found them helpful! As far as remembering this stuff, it just comes down to practice. When you type it out over and over again, you start to remember the syntax and the patterns. But at the same time you don't need to remember everything. I regularly use the pygame docs while I work on games to check the syntax of a particular function so that may help you as well.
@@CodingWithRuss Thanks so much
@@CodingWithRuss And sorry to bother you but, I have another question. When you make a game or anything in Python. How do you draw the sprites/characters? Do you use AI or do you have a designer?
Like your character for the platformer was amazingly drawn
@@user-br4im8hd9f I don't actually make my own sprites, I'm not very good at it :) I use open source assets from itch.io. There's lots to choose from there. Same with sound effects, I google free ones rather than make my own.
when i run the enemy image load paragraph it said that the format is not supported...
hi russ, thankyou for making this video as it has helped me a lot in my coding journey. But i need some help to implement a feature in this game. I want to make the turret track the enemies as they are moving even whilst the turret is in cooldown instead of the turret snapping towards an enemy once it can shoot. Any help is appreciated.
dw i got it working.
Thanks for the tutorial!
I have noticed one thing you missed with the fast forward button you change the speed of almost everything except the enemy spawning intervals meaning while the game is fast forwarded the enemies have bigger gaps in between each other making the game way easier when using the fast forward button. The fix is very simple in the main file where the enemies are spawned spawn_cooldown has to be divided by world.game_speed.
Ah I totally missed that! Good catch and thanks for providing the solution as well.
@@CodingWithRuss one question can you provide me with the tile map you used i cant seem to make one that looks like your i dont mean the map/level i mean the custom tile map you somehow got
thanks...
No problem
Hello there. I wanna ask if i draw my own map and i do the waypoints manualy. Can it break my game?
It should be OK, but you can give it a go and hopefully it works fine
So its okay to not write the codes to the tiles map?
i dont get it, what is normalize?
my enemy doesn't travel on the right trail for some reason.
how do you find the code on github???
It should be linked in the video description. That will take you to the repo which has all the folders and different code files that you can download
@@CodingWithRuss how can I find the full game code. Like what folder(s) is it in?
not working, i tried everything, but it doesnt work
personal bookmark: 1:20
Dude, how old are you?
31:11 (self note DW about this)