Tower Defence Tutorial in Pygame | Part 9 - Upgrading Turrets

Поделиться
HTML-код
  • Опубликовано: 25 июн 2023
  • In this Python tutorial I code tower defence game using the PyGame module. I'm going to add a file containing data for different levels of turret and use this to upgrade the placed turrets. Each upgrade makes the turret stronger by reducing cooldown between shots and increasing the turret's range.
    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

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

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

    I'm learning a lot from your videos Russ. Thank you for these amazing videos. I've started doing a new game project. I would love to share it with you after my project is finished. I hope you get what you deserve. Good Luck! :)

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

      That's great to hear, thanks! Will be interesting to see your project once it's finished

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

    love your vids !

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

    thank you so much.

  • @deafmettle
    @deafmettle 11 месяцев назад +3

    Hey Russ. I love these videos and the way you build things up step by step. When you get to the end, you should mention something about code optimisation. Rather than repeating the same code in different places, you should aim to write it once and call it multiple times. That way, your code is easier to maintain. Speaking from experience where I had to debug a code base where the same mistake had been copied into about 10 different places 😱

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

      Thanks! It's a good point about optimisation, keeps the code tidy and like you say, it avoids mistakes being spread as easily. I try to refactor my code as I work on it, to see if sections can be simplified or turned into a function that can be called instead of pasting code, although even after that there's probably always room for improvement :)

  • @wingielee
    @wingielee 11 месяцев назад +3

    experiencing this error and couldn't locate where its emerging from ;
    File "E:\programs\pygame apps\tower\tower.py", line 170, in
    create_turret(mouse_pos)
    File "E:\programs\pygame apps\tower\tower.py", line 62, in create_turret
    new_turret = Turret(turret_sheet,mouse_tile_x,mouse_tile_y)
    File "E:\programs\pygame apps\tower\turret.py", line 24, in __init__
    self.animation_list = self.load_images(self.sprite_sheets[self.upgrade_level - 1])
    TypeError: 'pygame.surface.Surface' object is not subscriptable

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

      It means that the self.sprite_sheets variable is an image rather than a list. Double check that you have updated the argument names and are passing the list of sprite sheets rather than an individual image and that should fix it.

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

    First