PyGame Scrolling Shooter Game Beginner Tutorial in Python - PART 8 | AI

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

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

  • @CodingWithRuss
    @CodingWithRuss  3 года назад +5

    Part 9 is now uploaded and I show how to load levels into the game: ruclips.net/video/5VSzZu5904c/видео.html

    • @l0nefighter509
      @l0nefighter509 3 года назад

      Where do I save my images to be able to access them within python. When I tried to load my images it said that they weren’t saved in the same directory, can you explain that to me?

  • @권남수-o3v
    @권남수-o3v 3 года назад +6

    Thank you Mr.Russ for your passionate effort.
    I'm a South Korean and used to be a teacher of English.
    Due to your devotion I am very happy to study game code though old (born in 1953)

    • @CodingWithRuss
      @CodingWithRuss  3 года назад

      Hi, glad to hear you are watching the videos and finding them useful. Never too old to learn :) If you have any trouble with the code then ask in the comments and I will try to help. I also upload the code on github (in the video description) so you can always check that if there are any errors in the code

  • @memegod9999
    @memegod9999 3 года назад +8

    I've never seen a tutorial that's fun and educational at the same time. this guy is a legend. keep it up!

  • @FRAMEDSKATEKREW69
    @FRAMEDSKATEKREW69 Год назад +2

    I can't believe im done with part 8
    honestly, its been amazing completing this tutorial.
    Even when I am tired from work I still want to keep staying up to keep watching lol

  • @myozimandis
    @myozimandis 3 года назад +4

    Clever workouround for enemy's vision and ai in general, this is great material, thanks a lot you're awesome Russ

    • @CodingWithRuss
      @CodingWithRuss  3 года назад +1

      Thanks, I had a few different ideas for it but that was the solution I was happiest with!

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

    this tutorial series only gets better. amazing work, Russ. I watched your "Ultimate pygame intro" at clear code a couple of months ago and it taught me a lot, and for sure helped me to understand these tutorials very easily. huge fan of your work!

  • @ericzhang6253
    @ericzhang6253 2 года назад +1

    you deserve plenty more attention, these tutorials have inspired me to create my own games and still do after a year watching you, very easily to follow along and learn all the logic behind the game

    • @CodingWithRuss
      @CodingWithRuss  2 года назад

      Thank you! I'm glad to hear the tutorials are still useful

    • @ericzhang6253
      @ericzhang6253 2 года назад

      @@CodingWithRuss They are by far the best tutorials I have seen in anything coding related

  • @LeaStark63733484
    @LeaStark63733484 3 года назад +3

    Love this playlist! Watching you has helped me alot... However two things I have no figured out yet is :
    1) How to limit the ai from "seeing the player through a block"
    2) how to keep the ai from walking off the end of a platform.

    • @CodingWithRuss
      @CodingWithRuss  3 года назад +2

      Thanks! The AI is fairly basic so both of those things could be added in. I considered them when initially making the game but didn't want the code to get too complicated. I had some ideas for how to implement those features though, if you want to try and add them in:
      1)The AI "vision" only checks for collision with the player, but instead it could also check for collision with all tiles. Then by checking the distances to the objects in the AI's vision (player or tiles), you can determine whether the player is behind a wall or in front of it.
      2) The AI already has a section for doing a collision check with tiles in front of it and it turns around if it detects that. So you could do a similar check for an earth tile under the AI so if it there is no tile in front to stand on, it turns around

  • @davysabbe3341
    @davysabbe3341 3 года назад +7

    Great stuff again! I just did a small tweak to make it so you don't "pick up" the Health box when the player is at full HP. :-)

  • @HostileOTB
    @HostileOTB 3 года назад +3

    been working through these videos aha cant wait to see the final result

    • @CodingWithRuss
      @CodingWithRuss  3 года назад +1

      Good stuff! Hopefully all making sense so far.

    • @HostileOTB
      @HostileOTB 3 года назад +1

      @@CodingWithRuss When is part 9 coming out if you don't mind me asking?

    • @CodingWithRuss
      @CodingWithRuss  3 года назад +1

      @@HostileOTB Just uploaded it now :)

  • @itcode2803
    @itcode2803 3 года назад +2

    Can't wait for the scrolling background

    • @CodingWithRuss
      @CodingWithRuss  3 года назад +1

      Yea that is going to be done in the next couple of videos. I wanted to get everything else working first with the player and enemies etc, which is nearly done now

  • @johnandlisalinderman6238
    @johnandlisalinderman6238 3 года назад +2

    Man per usual great stuff I am now pausing and writing code and testing my way and I am not far off of the way you are doing it but..... I always revert to your way just so I am following along :)
    10 thumbs up my friend

    • @CodingWithRuss
      @CodingWithRuss  3 года назад

      Glad to hear it! Working it out for yourself is definitely the best way so sounds like you've got a good approach to it :)

    • @johnandlisalinderman6238
      @johnandlisalinderman6238 3 года назад

      @@CodingWithRuss yes thanks to you I am getting a clearer approach on things I just need to start making my brain think about logic to help me know what I need and what to add ... You rock man

  • @jesterc.6763
    @jesterc.6763 3 года назад

    I cant believe that you just gave me the ability to create Metal Slug.

  • @akshatnayak119
    @akshatnayak119 3 года назад +2

    Thank you for the work u r doing Russ!

  • @fipj
    @fipj 3 года назад +1

    Congratulations. Your tutorials are perfect.

  • @insert9124
    @insert9124 3 года назад +2

    Works like a charm

  • @NewGamer98
    @NewGamer98 3 года назад +2

    My man. U the bossss keep on it bro

  • @proyectsjr
    @proyectsjr Год назад +1

    Thank you very much friend, the tutorial has been very helpful to me. Keep up the good work.

  • @basedboat4921
    @basedboat4921 3 года назад

    Great tutorial, I recently discovered your channel because I procrastinated for a school project, and for what I had in mind I used a few aspects from the platformer game and was able to do quite well. So I hereby thank you.
    Another thing is that, pygame is really well done. For example the draw "functions" etc. are super simple and I think your tutorials make pygame simple and intuitive. (Sorry if this comment isn't that well written I'm short on time atm :P)

    • @CodingWithRuss
      @CodingWithRuss  3 года назад

      Thanks, glad to hear this helped with your project! 😀

    • @basedboat4921
      @basedboat4921 3 года назад

      @@CodingWithRuss thank you!

  • @Dash-mio
    @Dash-mio 3 года назад +1

    Great vid russ! thx

  • @АнтонНазарук-щ5с
    @АнтонНазарук-щ5с 2 года назад +1

    Thanks for the lesson!

  • @johnstarfire
    @johnstarfire 3 года назад +1

    great. I like the vision solution. you can use elif too...

    • @CodingWithRuss
      @CodingWithRuss  3 года назад

      Thanks Giovanni, glad you liked it! And that is a good suggestion about elif.

  • @diveshkumar8025
    @diveshkumar8025 3 года назад

    I can build Many Projects by help of your Project, your project is very Intuitive. thanks for great content.

  • @jesterc.6763
    @jesterc.6763 3 года назад

    Thank you o much for this dude. You are a God.

  • @ezzeldin101
    @ezzeldin101 3 года назад +2

    Hi dude I wanted to say thank you💖

    • @CodingWithRuss
      @CodingWithRuss  3 года назад +1

      No problem, I'm glad you liked the tutorial :)

  • @rhxie2466
    @rhxie2466 3 года назад

    I finish this part , finding that enemy's bullet can kill another enemy. Fun:D

  • @LoganadoLakings
    @LoganadoLakings Год назад +1

    There is a problem in mine. Whenever i enter the enemies vision, they always die and never shoot. I tried making sure that every line was correct but the error kept happening. Is there a way to fix this?

  • @clashtheflash2198
    @clashtheflash2198 2 года назад

    Thank you Mr Russ for the tutorials

  • @bbjjaden9413
    @bbjjaden9413 3 года назад +1

    Finally !!!!!

  • @maganabiyev2111
    @maganabiyev2111 Год назад

    huge thanks

  • @trailsanddales4356
    @trailsanddales4356 3 года назад +1

    FAB THANKS

  • @saury0626
    @saury0626 2 года назад

    Can you make a tutorial where if the enemy died we can update point / record, or even better that they drop item after they died. I tried to do it myself but i got into an infinity loop since i dunno where to put a stop / or run just once my update record method. Thanks

  • @Ray-sb8qi
    @Ray-sb8qi 2 года назад

    i need help the vision cone is only active when the guy is idle and it flickers

  • @Crafted_pic
    @Crafted_pic 2 года назад

    I am unable to download the scv file
    But thanks to publish this vedio

  • @skya2161
    @skya2161 3 года назад

    What should I do if the enemies use different
    bullet image than the player?

  • @elderevil3203
    @elderevil3203 2 года назад

    Hello Russ, it's cool that player and enemies have the same class, but what if I want to add another type of enemies, like tank or mech, how different will it be from standard soldier?
    Or would it be easier to make a separate class for them?

    • @benmcwhirter4566
      @benmcwhirter4566 Год назад

      I assume the images and info in the enemy = Soldier () line would change.

  • @quanvuinh20
    @quanvuinh20 3 года назад

    Good ider 👍

  • @Adam-TheLiftedKing
    @Adam-TheLiftedKing Месяц назад

    Hey adding self.Updateanimaitons(0) seems to cause my code to crash whenver I idle but it seems my code is the same as yours im confused why this is causing an issue. I managed a fiix for it but Inow once you adding shooting i got the same error: TypeError: updateAnimations() takes 1 positional argument but 2 were given

  • @StormwreckerOfficial
    @StormwreckerOfficial 2 года назад

    Hi, again! I was wondering how to deal with "invisible" hitboxes on pygame. There's a blank space around my player and my enemies, and since I have a tile-based collision on them, collisions get messed up by that. Is there maybe a built-in pygame function that ignores the blank space and checks for collision only for the image part of the rectangle?

    • @CodingWithRuss
      @CodingWithRuss  2 года назад +1

      Hello. Yes there is functionality for that in pygame. it's done using masks. I don't have a tutorial specifically on masks but I have used them once on a previous project, which may help you: ruclips.net/video/t1zTvpxHKCU/видео.html

    • @StormwreckerOfficial
      @StormwreckerOfficial 2 года назад

      @@CodingWithRuss Thank you for getting back to me! The video explains masks really good. Does it still work with tile-based collisions? My player's collision with ground tiles also gets affected by the blank rectangle, but I can't stop using tile-based collision in that instance. How would this get fixed?

  • @hamzanadeem3580
    @hamzanadeem3580 Год назад

    i was following the tutorial and was having trouble with adding the enemy into a group. when i added them i was only able to hit 1 enemy and no more. Can you help?

  • @opst1x89
    @opst1x89 3 года назад

    when I call the "ai" function on the enemys for some reason it affects the player's jump, it makes it low and fast! and the enemys doesn't have any gravity...

    • @opst1x89
      @opst1x89 3 года назад

      NVM I fixed it, I accidentally typed player.vel_y in the move function! now the jump is good and the gravity works good!!!! GOD TUTORIALS🔥🔥🔥🔥

    • @CodingWithRuss
      @CodingWithRuss  3 года назад

      @@opst1x89 Good to hear you got it fixed, it is often these little typos that cause headaches! :)

  • @nayunayu4265
    @nayunayu4265 2 года назад

    the ai_moving_left = not ai_moving_right is causing me some trouble
    its giving me this error UnboundLocalError: local variable 'ai_moving_right' referenced before assignment
    how do i fix this? thanks for the help

    • @nayunayu4265
      @nayunayu4265 2 года назад

      i found the problem, i just made a typo lol

    • @CodingWithRuss
      @CodingWithRuss  2 года назад

      It means you haven't defined (created) the variable ai_moving_right yet. Compare against the complete code for this section and see if you have any missed code or a typo for ai_moving_right

  • @connorganahl2694
    @connorganahl2694 3 года назад

    The enemy takes the dmg and dies when it attacks me(the player) instead of other way around, how could I fix this?

    • @CodingWithRuss
      @CodingWithRuss  3 года назад

      Did you find the fix? It sounds like you have a typo in the code and the enemy's self.health is lowering rather than the target. Check the code linked in the description to see what it should be like

    • @connorganahl2694
      @connorganahl2694 3 года назад

      @@CodingWithRuss I found the fix thank you!

    • @khare8587
      @khare8587 2 года назад

      @@connorganahl2694 What was the fix?

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

    i wanted my enemies to stop only when they reach to the ends also i wanted their momement to be random so i changed my ai class to this
    def ai(self):
    if self.alive and player.alive:
    #check if the ai in near the player
    if self.vision.colliderect(player.rect):
    #stop running and face the player
    self.update_action(0)#0: idle
    #shoot
    self.shoot()
    else:
    if self.idling == False:
    if self.direction == 1:
    ai_moving_right = True
    else:
    ai_moving_right = False
    ai_moving_left = not ai_moving_right
    self.move(ai_moving_left, ai_moving_right)
    self.update_action(1)#1: run
    self.move_counter += 1
    #update ai vision as the enemy moves
    self.vision.center = (self.rect.centerx + 75 * self.direction, self.rect.centery)
    if self.move_counter > TILE_SIZE:
    self.update_action(0)#0: idle
    self.idling = True
    self.idling_counter = random.randint(75,200) #this is min, max time for the enemies to stop at the ends
    self.direction *= -1
    self.move_counter *= -1
    else:
    self.idling_counter -= 1
    if self.idling_counter

  • @BeRaikwal
    @BeRaikwal 3 года назад

    does anyone here use sublime text for python? if yes then please can u tell me how to enable python cuz it always shows some error to me while I use sublime for python...Help me please and yes amazing tutorial as always and AI is new this time in the game so i love it

    • @cosmo8874
      @cosmo8874 2 года назад

      i use sublime text, but for me it came with python preinstalled. i dont really know how to help you sorry

  • @joeybrasil7384
    @joeybrasil7384 3 года назад

    I can only thank...

    • @CodingWithRuss
      @CodingWithRuss  3 года назад

      You're welcome, glad you like the tutorial :)

  • @MOKAREVIEW647
    @MOKAREVIEW647 3 года назад

    There a bug in this game

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

    🧑‍💻