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

Комментарии • 58

  • @CodingWithRuss
    @CodingWithRuss  11 месяцев назад +10

    This is a combined version of my tower defence tutorial series for those who prefer one longer video with chapters!

  • @digitalbear8809
    @digitalbear8809 11 месяцев назад +6

    Thanks for putting this all in one vid, I like to watch these from start to end in 1 sitting generally

  • @Beckers0115
    @Beckers0115 6 месяцев назад +1

    Making a tower defense game using pygame in my advanced coding class, this tutorial helped A BUNCH! Glad you uploaded it all in one.

  • @goiksou5225
    @goiksou5225 11 месяцев назад +2

    Thank you for putting these videos up on the internet, they make my summer break a lot more intresting with some games!

  • @MrGzar-ec1bh
    @MrGzar-ec1bh 10 месяцев назад +4

    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

    • @CodingWithRuss
      @CodingWithRuss  10 месяцев назад +1

      That's great to hear! Good luck on your game dev journey :)

    • @MrGzar-ec1bh
      @MrGzar-ec1bh 10 месяцев назад

      @@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

  • @bjjintahiti
    @bjjintahiti 6 месяцев назад

    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.

  • @Ashen_0
    @Ashen_0 11 месяцев назад +1

    Thanks for all the tutorials, you helped me a LOT :)

  • @jeanrussell9248
    @jeanrussell9248 11 месяцев назад +1

    I enjoyed these and learned so much!

  • @VimpiiYT
    @VimpiiYT Месяц назад

    Thanks, this video was super helpful! 🙏

  • @maxfrischdev
    @maxfrischdev 10 месяцев назад +2

    "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 😬😆)

    • @CodingWithRuss
      @CodingWithRuss  10 месяцев назад +1

      Haha thanks! Sound like good timing :)

    • @maxfrischdev
      @maxfrischdev 10 месяцев назад

      @@CodingWithRuss Yesss Boss! Gimme more, gimme more! 😀

  • @ElfabetGD
    @ElfabetGD 11 месяцев назад

    Never mind one of your older videos helped :)

  • @tectoboom2627
    @tectoboom2627 10 месяцев назад

    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

  • @fargoretro
    @fargoretro 10 месяцев назад

    I've been trying to make a 3d Geoscape like the original Xcom, would love a video like that :D

  • @SkyFly19853
    @SkyFly19853 11 месяцев назад +1

    Oh...
    Real Nice...
    A masterpiece...

    • @CodingWithRuss
      @CodingWithRuss  11 месяцев назад +1

      Thanks! Glad you like it

    • @SkyFly19853
      @SkyFly19853 11 месяцев назад +1

      @@CodingWithRuss
      You are welcome and I thank you.

  • @tingyiyang7274
    @tingyiyang7274 3 месяца назад

    I like this tutoirla

  • @granpajestaz292
    @granpajestaz292 8 месяцев назад +1

    10 mins in and your already in my top 3 😂

  • @Nuohis13
    @Nuohis13 11 месяцев назад +1

    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...

    • @CodingWithRuss
      @CodingWithRuss  11 месяцев назад

      Ah good catch! And thanks for providing the fix

  • @WeirdStrictSmurfBoblox
    @WeirdStrictSmurfBoblox 7 месяцев назад

    Hi Russ! Thanks for this Tutorial. But can you make a video about Tiled so I can know how to use it? Thanks :)

  • @user-br4im8hd9f
    @user-br4im8hd9f 11 месяцев назад +1

    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.

    • @CodingWithRuss
      @CodingWithRuss  11 месяцев назад +1

      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.

    • @user-br4im8hd9f
      @user-br4im8hd9f 11 месяцев назад

      @@CodingWithRuss Thanks so much

    • @user-br4im8hd9f
      @user-br4im8hd9f 11 месяцев назад

      @@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?

    • @user-br4im8hd9f
      @user-br4im8hd9f 11 месяцев назад

      Like your character for the platformer was amazingly drawn

    • @CodingWithRuss
      @CodingWithRuss  11 месяцев назад +1

      @@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.

  • @jhuor3154
    @jhuor3154 Месяц назад

    when i run the enemy image load paragraph it said that the format is not supported...

  • @MastrViper
    @MastrViper 5 месяцев назад

    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.

    • @MastrViper
      @MastrViper 5 месяцев назад

      dw i got it working.

  • @evisminecraft4714
    @evisminecraft4714 10 месяцев назад +2

    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.

    • @CodingWithRuss
      @CodingWithRuss  10 месяцев назад

      Ah I totally missed that! Good catch and thanks for providing the solution as well.

    • @KiwiEdits.
      @KiwiEdits. 6 месяцев назад

      @@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

  • @alperklc7782
    @alperklc7782 10 месяцев назад +1

    thanks...

  • @enterdom998
    @enterdom998 7 месяцев назад

    Hello there. I wanna ask if i draw my own map and i do the waypoints manualy. Can it break my game?

    • @CodingWithRuss
      @CodingWithRuss  7 месяцев назад

      It should be OK, but you can give it a go and hopefully it works fine

    • @enterdom998
      @enterdom998 7 месяцев назад

      So its okay to not write the codes to the tiles map?

  • @QuantumPlusInfinity
    @QuantumPlusInfinity 3 месяца назад +1

    i dont get it, what is normalize?

  • @reidymcsteady2131
    @reidymcsteady2131 2 месяца назад

    my enemy doesn't travel on the right trail for some reason.

  • @JGSstudios
    @JGSstudios 6 дней назад

    how do you find the code on github???

    • @CodingWithRuss
      @CodingWithRuss  6 дней назад

      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

    • @JGSstudios
      @JGSstudios 6 дней назад

      @@CodingWithRuss how can I find the full game code. Like what folder(s) is it in?

  • @progaming-vs9df
    @progaming-vs9df 2 месяца назад

    not working, i tried everything, but it doesnt work

  • @jmeib
    @jmeib 8 месяцев назад

    personal bookmark: 1:20

  • @szilardszita7276
    @szilardszita7276 8 месяцев назад

    Dude, how old are you?

  • @original_box
    @original_box 6 месяцев назад

    31:11 (self note DW about this)