Pygame RPG Tutorial #1 - Pygame Tutorial

Поділитися
Вставка
  • Опубліковано 20 січ 2025

КОМЕНТАРІ • 291

  • @Haku_Hatake
    @Haku_Hatake 3 роки тому +60

    Gonna be 100% honest with you. The way you are programming this game is perfect! Use of classes allows for easy reuse of code. And having a config script keeps the main script clean and organized! I love it! 😍

  • @Cjajfbf82938
    @Cjajfbf82938 3 роки тому +13

    Thanks! I just finished this part and I just searched for "How to make a RPG in python" and found you. You have my sub.

    • @ShawCode
      @ShawCode  3 роки тому +2

      Thanks for subscribing!

  • @alicemystery5520
    @alicemystery5520 3 роки тому +14

    This series is happening at he right moment. I am just past the basics and needed something fun to do.

    • @ShawCode
      @ShawCode  3 роки тому +3

      Nice, I hope you enjoy the series!

  • @ShawCode
    @ShawCode  3 роки тому +19

    Want to make mobile apps with python? Check out this video --> ua-cam.com/video/7oMNqAE_OVE/v-deo.html
    I hope you found the first tutorial in this series useful! If you would like to see the next tutorials, then be sure to SUBSCRIBE so you don't miss out! Also, be sure to share this video with anyone who would find it useful!

  • @Nolo1357
    @Nolo1357 2 роки тому +6

    Very excited to revisit pygame. We made a game on it in college but I can't remember much. I'm getting into programming again and am thrilled to have come across such a nicely formatted tutorial series. Thanks man!

    • @ShawCode
      @ShawCode  2 роки тому +2

      Thanks, and good luck with learning it again!

  • @jetspray3
    @jetspray3 2 роки тому +1

    15:00 I came over from another video to get a better explanation of that and you did a perfect job.

  • @shintori2808
    @shintori2808 2 роки тому +2

    I’m a few videos in and I realy have to say thank you. Seeing this stuff implemented and you explaining it as you do it, is fway more useful than any py basics. This is making this stuff click for me like nothing else has. Thank you very much.

    • @ShawCode
      @ShawCode  2 роки тому

      Glad you're finding it useful, thanks!

  • @yoguri0
    @yoguri0 8 місяців тому

    I'm using these videos to learn python for a school project, and they are perfect! I only discovered this channel today but I hope you come back! Thank you!!!!!

  • @a_8764
    @a_8764 2 роки тому +3

    Your code has a very clear and easy to follow structure to it, compared with other pygame tutorials I've seen.

  • @Gigglewoof
    @Gigglewoof Місяць тому

    Hey there! This is one of my most favourite tutorials. You are concise and explain everything in the perfect amount of detail. One tip for you is to use Vscode (visual studio code) since the software automatically tells you if there are any bugs or things missing. Thanks for the tutorial.

  • @KamuraGhost
    @KamuraGhost 3 роки тому +2

    This is exactly what I needed. Not saying I'll ever make a game using pygame, but it is good practice to program a game from scratch outside of an IDE/program. Thanks for this tutorial.

  • @findstr.s-hi-c._w
    @findstr.s-hi-c._w Рік тому +2

    the most valuable thing in programming i think is:
    the yx,or xy loop.
    y=0
    x=0
    end=10
    while y != end:
    x=0
    while x != end:
    x=x+1
    y=y+1
    you can use it for grids,files ,anything that uses columns and rows.
    and loop trough them.
    ofc in 3d,you also add z.
    now its not useful by itself.
    but add in string-substitution ,the split(),and strip() methods,+ reading/writhing files, and lists[][].
    and you have a whole lot of power in your hands.
    i also use os.system("dir /b c:\location > file.txt"), a lot on windows ,to scan directories.
    this is a CMD command.
    and then use the yx/xy loop to get its contents like so:
    file=open("file.txt","r"")
    for lines in file.readlines():
    lines=lines.strip()
    list=lines.split("delimiter")
    for word in list:
    word=word
    file.close()

  • @icecreamer124
    @icecreamer124 3 роки тому +1

    Wow a new series. The last one I watched was your kivy tutorial and it was amazing

    • @ShawCode
      @ShawCode  3 роки тому

      Thanks, hopefully you'll find this one just as good!

  • @mich8411
    @mich8411 3 роки тому +1

    You are a blessing...to the world , thank you very much...from South Africa 🇿🇦

  • @Jetster26
    @Jetster26 2 роки тому +1

    14:57 Timestamp!
    Also great tutorial. Love it!

  • @alanocdesarrollo9275
    @alanocdesarrollo9275 Рік тому

    Dude you really nailed it, this tutorial will help me a lot

  • @barbadosslimful
    @barbadosslimful 2 роки тому

    Dude - you are awesome! Look forward to watching more of your stuff.

    • @ShawCode
      @ShawCode  2 роки тому

      Thanks, I'm working on some new videos at the moment :D

  • @omegamotivation144
    @omegamotivation144 3 роки тому

    Been waiting for this! Great Vid!

    • @ShawCode
      @ShawCode  3 роки тому

      I'm glad you enjoyed it! The next tutorial in the series will be coming next weekend!

  • @pythonwithmark9276
    @pythonwithmark9276 3 роки тому +6

    Hello, I started to learn python last month and I feel that there is something wrong with my learning ways. Do you have any idea where can I enhance my Fundamental skills and also python skills. I cant think of an amazing and fun projects that can enhance my skills.

    • @ShawCode
      @ShawCode  3 роки тому

      I have a Python Basics series that teaches you the fundamentals of python. There are also challenges at the end of each video to test what you have learned: ua-cam.com/play/PLkkm3wcQHjT7Seo5VeYwEMNP4TEzr5rBu.html

  • @s.dh29
    @s.dh29 3 роки тому +1

    This should be ASMR lol, I love the sound of your keyboard!

  • @PHALOEDM
    @PHALOEDM 3 роки тому +1

    I have this problem at the end where line 2: code: from sprites import *: they say the from is the error but its the same as your code. What can I do.

    • @ShawCode
      @ShawCode  3 роки тому +1

      Could you please copy and paste your code for me to look at?

  • @angshappy3424
    @angshappy3424 3 роки тому +2

    I really admire that not only was the coding detailed and neat, but you explained it clearly and made it easy to understand :D although if you haven't done so already and are ok with me asking, could you possibly do an inventory available to the player once they collect items, as well as features that alter the players strength or stuff like that? For example: +2 luck or +8 crit damage

    • @ShawCode
      @ShawCode  3 роки тому +2

      Thanks! I won't be doing any more Pygame RPG tutorials, but an inventory system would probably just be a list in the Player class, and items are added when they are collided with. The player strength and crit damage would also just be variables in the player class, and the items in the inventory list could alter them.

  • @Jubileusju
    @Jubileusju 3 роки тому +1

    Hi, i'm trying tô make the character walk but i'm stuck, can you help me? I tried to create a def walk within the Player class and create a event.type within the def events

    • @ShawCode
      @ShawCode  3 роки тому +2

      We will be covering movement in the next video, coming this weekend. You have the right idea for the movement, good job!

    • @Jubileusju
      @Jubileusju 3 роки тому +1

      @@ShawCode thanks 😁😁😁

  • @Bay_den_vu_tru
    @Bay_den_vu_tru 6 місяців тому

    i don't know how Player class is used. I know self.all_sprites.draw(self.screen) somehow related to Player class, but i don't get it

  • @robocore417
    @robocore417 Місяць тому

    Спасибо тебе, мужик. Отличные видео. Всё понятно и структурно описано.

  • @abdou_belounis
    @abdou_belounis 8 місяців тому +1

    Thanks you , Keep up the Great work

  • @ghzich017
    @ghzich017 3 роки тому +14

    I WANT TO LEARN PYGAME THEN SUDDENLY YOU UPLOAD IT THANKSSS :))

  • @monkeyfunkel
    @monkeyfunkel 2 роки тому

    so i copied your code and it won't run, i think its because the import pygame on the main doesnt highlight ,like its not being used but it highlights on the sprites file, idk what to do

  • @argiepoul7457
    @argiepoul7457 3 роки тому

    Greetings from Greece, nice video, keep it up!

  • @gabrielbutucel9044
    @gabrielbutucel9044 2 роки тому

    hello , it says that modulenotfound for sprites
    how do i fix it?

  • @mikimiki9109
    @mikimiki9109 6 місяців тому

    How does self.all_sprites.draw(self.screen) works?

  • @novis1891
    @novis1891 3 роки тому +1

    Thanks bro
    Just i have a probleme when i run the code
    Pygame start buggind and doesnt answer

    • @ShawCode
      @ShawCode  3 роки тому

      What errors do you get?

  • @applesauce6644
    @applesauce6644 3 роки тому +1

    Question? When installing pygame through pip, I get an error where it says like the SSL module is not available?

    • @ShawCode
      @ShawCode  3 роки тому +1

      Please could you paste in the full output of the command?

    • @applesauce6644
      @applesauce6644 3 роки тому +1

      Here it is
      WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
      WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pygame/
      WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pygame/
      WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pygame/
      WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pygame/
      WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pygame/
      Could not fetch URL pypi.org/simple/pygame/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pygame/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
      ERROR: Could not find a version that satisfies the requirement pygame (from versions: none)
      ERROR: No matching distribution found for pygame
      WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
      Could not fetch URL pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

    • @ShawCode
      @ShawCode  3 роки тому +2

      @@applesauce6644 Did it say that the pygame requirement is already satisfied before the warning? Because that means that it is already installed.

    • @applesauce6644
      @applesauce6644 3 роки тому +1

      @@ShawCode Nope, it did this the first time I tried to install it. It says it cannot find the SSL Module in python/ there is an issue confirming the ssl certificate since its not there.
      I don't know what exactly it means haha. But I presume something that required is missing which is the SSL Module in python... But I don't know what an ssl module is lol

    • @ShawCode
      @ShawCode  3 роки тому +2

      I'm not really sure what the issue is, but you could try manually installing pygame with a wheel file. To install wheel files, check this link: stackoverflow.com/questions/27885397/how-do-i-install-a-python-package-with-a-whl-file. The pygame wheel file is here: pypi.org/project/pygame/#files

  • @alexisdurand4008
    @alexisdurand4008 3 роки тому +1

    Quick question not video related but I'm not allowed to speak in your discord is there like rules to agree or something?

    • @ShawCode
      @ShawCode  3 роки тому

      Thanks for joining! The server is paused at the moment, I'm just waiting a little while for various reasons before I open it again.

    • @alexisdurand4008
      @alexisdurand4008 3 роки тому

      @@ShawCode ok thank you

  • @MidnightAnimaI
    @MidnightAnimaI 3 роки тому +2

    Hi, great tutorial. Just one question: inside the while loop in g.main(), do self.events(),self.draw() and self.update() run in parallel? If not, how is it able to check for events, draw on the screen and update it all at the same time?

    • @ShawCode
      @ShawCode  3 роки тому

      Good question! They aren't in parallel, and I don't honestly know the exact reason why it works. I think it's to do with how Pygame itself works.

    • @MidnightAnimaI
      @MidnightAnimaI 3 роки тому +2

      @@ShawCode I’ve been thinking about it and I think it’s that all 3 processes run before the next frame is displayed, and you see the result of all 3 when that frame is displayed, so it’s more like an illusion that they all take place at the same time.

    • @graphitic5578
      @graphitic5578 2 роки тому

      @@MidnightAnimaI remember orders? the computer will read the whole block of code until there's ';' or '}' and generate from what the computer was instructed.

  • @rizdekd3912
    @rizdekd3912 Рік тому

    This is very clear and I can follow what's going on even though I'm not good with python or pygame. But, is there a place (website) where the entire code can be seen? I fear that I'll end up with errors/problems when I run the program and won't be able to go back and find where in the tutorial the specific code was presented to see what I mistyped.

  • @taylortheboiyt9098
    @taylortheboiyt9098 8 місяців тому

    Hey there great tutorial its perfect but im getting a error saying player has no atribute for 'self' and g.new apparent has a error

  • @sedenions
    @sedenions 3 роки тому

    while g.running():
    TypeError: 'bool' object is not callable

    • @ShawCode
      @ShawCode  3 роки тому

      Could you please copy and paste your code for me to look at?

  • @aycoded7840
    @aycoded7840 3 роки тому +1

    You seem very good at teaching this.

  • @SHARTICUS
    @SHARTICUS 3 роки тому

    SHARTICUS says: thanks for the tutorial!

  • @Rilshock
    @Rilshock 3 роки тому

    I’m getting the error:
    File “main.py”, line 56, in
    g.intro_screen()
    AttributeError: ‘Game’ object has no attribute ‘intro_screen’.
    Even though intro_screen is clearly defined as a function.

    • @ShawCode
      @ShawCode  3 роки тому

      Please could you copy and paste your code for me to look at?

    • @Rilshock
      @Rilshock 3 роки тому

      Mind if I send a pastebin of it?

    • @ShawCode
      @ShawCode  3 роки тому

      Sure!

    • @Rilshock
      @Rilshock 3 роки тому

      @@ShawCode update: I finally fixed it

    • @cyrixas8308
      @cyrixas8308 Рік тому

      @@Rilshock how

  • @benoldum118
    @benoldum118 2 роки тому +1

    "self.player = Player(self,1,2)" when I write this code ıt says me "NameError: name 'Player' is not defined"

  • @Santeoz
    @Santeoz 6 місяців тому

    How do you make a py file I think I'm lost 😅

  • @Adam-TheLiftedKing
    @Adam-TheLiftedKing 3 місяці тому

    Think I messed something up my code won’t run the game guess I’ll have to rewatch

  • @maxfrischdev
    @maxfrischdev Рік тому

    How ever young this fella is, really makes me regret wasting DECADES just playing games and wasting around, instead of asking myself "hmm, how to actually MAKE that myself?!"

  • @ТатьянаЧернышева-щ8ч

    This is good tutorial and hello from Russia.

  • @techwithgantavya6381
    @techwithgantavya6381 3 роки тому

    Yo Brilliant Shaw I love it

  • @cloudrelax6111
    @cloudrelax6111 3 роки тому

    omg I love it!!!! waiting for part two

    • @ShawCode
      @ShawCode  3 роки тому

      Thanks, the next video will be out this weekend!

    • @FruitJuic3
      @FruitJuic3 3 роки тому +1

      Can't wait!

  • @s.dh29
    @s.dh29 3 роки тому

    Ur tutorials are rlly helping thank u

    • @ShawCode
      @ShawCode  3 роки тому

      Glad you like them!

  • @daboxguy3848
    @daboxguy3848 3 роки тому

    Can you not use hex codes to change the colour? Also where did that "g" class come from?

    • @ShawCode
      @ShawCode  3 роки тому +1

      I'm not sure about hex codes, I've always just used RGB - try it out with hex! The 'g' object is just an instance of the game class.

  • @sirajbabajanov
    @sirajbabajanov 3 роки тому +2

    wow great,don't stoping , from Uzbekistan Khiva

  • @coldirty
    @coldirty 3 роки тому

    how did you run the game at the end what is the hotkey ?

    • @ShawCode
      @ShawCode  3 роки тому

      It depends on what text editor you are using. If you are using Sublime Text, press Ctrl+B.

  • @alexisdurand4008
    @alexisdurand4008 3 роки тому

    sorry quick question I'm french and I don't reall y understand what a sprite is can you help me please ?

    • @ShawCode
      @ShawCode  3 роки тому +1

      A sprite is basically just an object in a video game - for example, a character, or an enemy, or a sword or tree.

    • @alexisdurand4008
      @alexisdurand4008 3 роки тому

      @@ShawCode ok thank you

  • @itschris1881
    @itschris1881 3 роки тому +1

    amazing bro, love ya dude

  • @karlroe504
    @karlroe504 3 роки тому

    hello i keep getting an error to do with the sprite and the file dir

    • @ShawCode
      @ShawCode  3 роки тому

      What error do you get? Sorry for the late reply

  • @ragnarok3888
    @ragnarok3888 3 роки тому

    Woah woah woah bro I have been offline for a month and now u ARE MAKING RPG VIDEOS , DAMN RIGHT AM RIGHT WITH YOU BRO ,just have to take care of kivy and oop tutorials on your channel first

  • @TheGreatGamer64
    @TheGreatGamer64 Рік тому +1

    I have a problem. not sure if this is just because im using a different editor or something, but:
    Traceback (most recent call last):
    File "main.py", line 60, in
    g.new()
    File "main.py", line 24, in new
    self.player = Player(self, 1, 2)
    File "sprites.py", line 10, in __init__
    self.layer = PLAYER_LAYER
    File "AppData\Roaming\Python\Python311\site-packages\pygame\sprite.py", line 238, in layer
    if not self.alive():
    File "AppData\Roaming\Python\Python311\site-packages\pygame\sprite.py", line 215, in alive
    return bool(self.__g)
    AttributeError: 'Player' object has no attribute '_Sprite__g'
    Did i miss something?

    • @TheGreatGamer64
      @TheGreatGamer64 Рік тому

      nevermind, i fixed it.

    • @dn7949
      @dn7949 Рік тому

      @@TheGreatGamer64 I'm getting the same errors. How did you fix it?

    • @tropicalflame-sx2cg
      @tropicalflame-sx2cg 10 місяців тому

      How did you fix it? Having the same problem

  • @kaypathy
    @kaypathy 3 роки тому +2

    Very nice,i just started learning python and i wanted to ask,how do you know what to do without constantly having to look up tutorials?

    • @ShawCode
      @ShawCode  3 роки тому +1

      Thanks! Once you have understood the content in tutorials, you don't need to memorise - just use documentation for looking up classes and functions, etc.

    • @kaypathy
      @kaypathy 3 роки тому +1

      @@ShawCode interesting..i don't wanna be too dependent on tutorials ...thanks!

  • @chumpeduardo8396
    @chumpeduardo8396 3 роки тому

    Great video, but one issue I get is an attributeError that 'Game' object has no attribute 'playing'. Any way I can resolve this?

    • @ShawCode
      @ShawCode  3 роки тому

      Could you please copy and paste your code for me to look at?

    • @aviakali6715
      @aviakali6715 2 роки тому

      Hello, one year later - have you fixed this yet?

  • @FixDaily
    @FixDaily 3 роки тому

    Awesome work! Thanks for sharing!

  • @densharail
    @densharail 3 роки тому +1

    You're awesome
    Keep it up!

  • @jaysikotar9860
    @jaysikotar9860 3 роки тому +2

    Thanks bro such a great tutorial.

  • @FinesseMAN01
    @FinesseMAN01 2 роки тому

    Hello, where is the link to the code for this project?

  • @alexisdurand4008
    @alexisdurand4008 3 роки тому +1

    Didn't saw the video yet but seems awesome

    • @ShawCode
      @ShawCode  3 роки тому +1

      I hope you find it useful!

  • @axelboman9783
    @axelboman9783 9 місяців тому

    Thank you man you are a real legend

  • @vk2172
    @vk2172 3 роки тому +3

    I like the style of coding you're using. Makes a lot of sense to do it this way!
    I'm having a problem running the code, however. I feel like I've copied it exactly but I get a 'pygame window not responding' error when running. :^ (

    • @ShawCode
      @ShawCode  3 роки тому

      Thanks! Please could you copy and paste your code if you are still having this issue?

  • @Abdullah_0083
    @Abdullah_0083 2 роки тому

    Great tutorial man 🙂

    • @ShawCode
      @ShawCode  2 роки тому +1

      Glad you liked it!

  • @eyuelfrew705
    @eyuelfrew705 3 роки тому

    thank you bro.......can i use linux to convert python file in to apk???,,....
    linux or ubuntu???please

    • @ShawCode
      @ShawCode  3 роки тому +1

      Sure, check out this video: ua-cam.com/video/yr7n0C2tspI/v-deo.html

  • @jovideos7546
    @jovideos7546 8 місяців тому

    pygame window not appearing for me

  • @tanmaysalaskar
    @tanmaysalaskar 3 роки тому +1

    Helpful video 👍

    • @ShawCode
      @ShawCode  3 роки тому +1

      I'm glad you found it useful!

  • @allanimeworld2898
    @allanimeworld2898 3 роки тому

    Bro i was making snake game can you please tell me the logic of increasing the length of snake i don't understand it i watch many tuts they all increasing it by making list and i don't understand what eLse they do please tell me the logic and how to make it🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

    • @ShawCode
      @ShawCode  3 роки тому

      Well, you might have a list of snake body parts. When the head collides with the food, add to the list. Then iterate over that list, and draw a body part for each item in the list.

    • @allanimeworld2898
      @allanimeworld2898 3 роки тому

      Bro i inderstand it but please just tell me how can i set the other body parts just after head of snake and make them follow snake please tell me
      💓💓💓💓💓💓💓💓💓💓 from india

    • @ShawCode
      @ShawCode  3 роки тому

      You would need to get the coordinate of the last body part in the list and base the new part off of that.

    • @allanimeworld2898
      @allanimeworld2898 3 роки тому

      @@ShawCode oh thanks bro that one is last can you tell me how can i do this please tell me with code please

    • @ShawCode
      @ShawCode  3 роки тому

      What code have you got so far?

  • @29namankumar29
    @29namankumar29 3 роки тому

    Awesome video bro

  • @mori5733
    @mori5733 2 роки тому

    Hello ShawCode. Really great video. I'm extremely interested in game development and your video is really helpful. I started learning to code back in December 2021.Here's a thought that bothers me...I keep seeing different ways to write something and it messes with me sometimes because I want to learn to write something the cleanest and most efficient way possible if possible. I like your video because it teaches me to use functions and classes more which is what I originally thought was the best way after finishing a python basics tutorial. Do you have any thoughts on how I should write my code? 2, How long have you been coding before you made this video? I like to ask because it gives me a timeline for progression based on how long they've been coding since you seem so comfortable coding and teaching it.

  • @gurnkerk3826
    @gurnkerk3826 3 роки тому

    Hello Shaw!
    Great video and more advanced but cleaner code, perfect for my purposes!
    Do you have your assets and codes uploaded somewhere?
    If not I would definitely recommend doing that (if the assets are open source)!

    • @ShawCode
      @ShawCode  3 роки тому

      Hi, you can get the assets from the description of the 4th tutorial. Thanks!

  • @Mo-xx9gg
    @Mo-xx9gg 3 роки тому

    If a rectangle is 32 pixels by 32 pixels, is it a square?

    • @ShawCode
      @ShawCode  3 роки тому +1

      Yes

    • @Mo-xx9gg
      @Mo-xx9gg 3 роки тому

      @@ShawCode lol

    • @IxZOMBxI
      @IxZOMBxI 2 роки тому

      @@Mo-xx9gg squares can be rectangles as well.

  • @abd_cheese7353
    @abd_cheese7353 3 роки тому

    Hi, thanks for the tutorial. I'm getting an error however when I ran it:
    Traceback (most recent call last):
    File, line 55, in
    game = Game()
    File , line 11, in __init__
    self.screen = pygame.display.set_mode((WINW, WINH))
    NameError: name 'WINW' is not defined
    Although I am importing:
    import pygame, sys
    from pygame import *
    from config import *
    from sprites import *
    config and sprites are in the same directory as main, so it might be my text editor (I use atom). I've had issues with atom trying to access different files and such, but I dont know how to resolve them. my code is identical to yours, other than that, and i've tripled checked my spelling
    edit, seems like atom is trying to use an alternate directory. if i fix it, ill take down my comment, but until then, pls help cause im somewhat new to programming

    • @ShawCode
      @ShawCode  3 роки тому

      Is WINW and WINH defined in config.py? Sorry for the late reply

    • @abd_cheese7353
      @abd_cheese7353 3 роки тому

      @@ShawCode its no problem
      Yeah, everything was defined, I ended up copy and pasting everything from the imported files into the main script and everything worked fine. The thing is, when I tried it in atom originally, the files would not import, but when i tried it vscode with no changes to the directory or organizationor anything like that, the files imported but pygame would not

  • @yousefangox3022
    @yousefangox3022 3 роки тому

    when i try to install pygame it doesn't install what should i do

    • @ShawCode
      @ShawCode  3 роки тому

      When you try to install it, what happens?

    • @yousefangox3022
      @yousefangox3022 3 роки тому

      it says: pip is not recognized as an internal or external command.

    • @ShawCode
      @ShawCode  3 роки тому +1

      Watch this video: ua-cam.com/video/D9jct9L9Lcs/v-deo.html

    • @yousefangox3022
      @yousefangox3022 3 роки тому

      thank you

  • @xyzxyz6095
    @xyzxyz6095 Рік тому

    Kid ! You're awesome.

  • @200ksubscriberswithoutvide9
    @200ksubscriberswithoutvide9 3 роки тому +1

    Thank you very much for this video

    • @ShawCode
      @ShawCode  3 роки тому +1

      I'm glad you found it useful!

  • @DaLastMonster
    @DaLastMonster 3 роки тому

    Any tips on learning proficiently? Just follow tutorials?

    • @ShawCode
      @ShawCode  3 роки тому

      You should follow tutorials to help you understand a tool/language/library, but once you have learnt it, you should go and make your own projects.

  • @brok3n_bot
    @brok3n_bot 3 роки тому +2

    MY G, it is showing an error AttributeError: 'Player' object has no attribute '_Sprite__g' , Also do you need a discord I can make you one!

    • @ShawCode
      @ShawCode  3 роки тому

      Please could you copy and paste in where you instantiate the Player, as well as the Player class for me to look at? I've got a discord, you can join it!

    • @brok3n_bot
      @brok3n_bot 3 роки тому

      @@ShawCode File "d:\Sujay\python.rpg\main.py", line 58, in
      g.new()
      File "d:\Sujay\python.rpg\main.py", line 23, in new
      self.player = Player(self, 1, 2)
      File "d:\Sujay\python.rpg\sprites.py", line 10, in __init__
      self.layer = PLAYER_LAYER
      .py", line 239, in layer
      File "D:\Users\alokj\AppData\Local\Programs\Python\Python39\lib\site-packages\pygame\sprite.py", line 215, in alive
      return truth(self.__g)
      AttributeError: 'Player' object has no attribute '_Sprite__g'
      PS D:\Sujay\python.rpg> & D:/Users/alokj/AppData/Local/Programs/Python/Python39/python.exe d:/Sujay/python.rpg/config.py
      PS D:\Sujay\python.rpg> & D:/Users/alokj/AppData/Local/Programs/Python/Python39/python.exe d:/Sujay/python.rpg/main.py
      pygame 2.0.1 (SDL 2.0.14, Python 3.9.1)
      Hello from the pygame community. www.pygame.org/contribute.html
      Traceback (most recent call last):
      File "d:\Sujay\python.rpg\main.py", line 58, in
      g.new()
      File "d:\Sujay\python.rpg\main.py", line 23, in new
      self.player = Player(self, 1, 2)
      File "d:\Sujay\python.rpg\sprites.py", line 10, in __init__
      self.layer = PLAYER_LAYER
      File "D:\Users\alokj\AppData\Local\Programs\Python\Python39\lib\site-packages\pygame\sprite.py", line 239, in layer
      if not self.alive():
      File "D:\Users\alokj\AppData\Local\Programs\Python\Python39\lib\site-packages\pygame\sprite.py", line 215, in alive
      return truth(self.__g)
      AttributeError: 'Player' object has no attribute '_Sprite__g'
      PS D:\Sujay\python.rpg>

    • @ShawCode
      @ShawCode  3 роки тому +1

      Thanks. Please could you also paste in your player class? I think your error will be coming from a typo in there.

    • @brok3n_bot
      @brok3n_bot 3 роки тому +1

      @@ShawCode class Player(pygame.sprite.Sprite):
      def __init__(self, game, x, y):

    • @ShawCode
      @ShawCode  3 роки тому +1

      @@brok3n_bot Thanks - could you also paste in the rest of the class? I should have been more specific with what I wanted to see lol.

  • @karolispaulauskas7594
    @karolispaulauskas7594 2 роки тому

    Thank you! For the great video į just have One error it says: line 59, in
    while g.running:
    AttributeError: 'Game' object has no attribute 'running'

  • @easycodebasics
    @easycodebasics Місяць тому

    very nice, but File "c:\Users\autos\Desktop\vpython\main.py", line 53, in
    g = Game() why?/???/??/???????

  • @MiteshPatel-pt9fk
    @MiteshPatel-pt9fk 3 роки тому

    How did u learn python

    • @ShawCode
      @ShawCode  3 роки тому

      I learned it from internet tutorials! If you would like to learn, I've got a full python course from beginner to pro.
      Beginner Tutorials: ua-cam.com/play/PLkkm3wcQHjT7Seo5VeYwEMNP4TEzr5rBu.html
      Intermediate Tutorials: ua-cam.com/play/PLkkm3wcQHjT6FZegW_PL0lD3UBINcVSrX.html
      Advanced Tutorials: ua-cam.com/play/PLkkm3wcQHjT5096yBPNoRGpO1dSQN4m85.html

  • @nekaliev1398
    @nekaliev1398 3 роки тому

    shaw how many programming languages do you khow

    • @ShawCode
      @ShawCode  3 роки тому

      I know Python the best, but I also know Java, Javascript, as well as a little bit of C++

    • @nekaliev1398
      @nekaliev1398 3 роки тому

      @@ShawCode well shaw thanks from Tajikistan for the cute and nice video

    • @ShawCode
      @ShawCode  3 роки тому

      :D

  • @snowsol
    @snowsol 3 роки тому +1

    love the content. can you give me advice to succeed in programming plz i'm a beginner

    • @ShawCode
      @ShawCode  3 роки тому

      Thanks! Just make sure you understand the concepts of programming, and then start working on some projects!

  • @lilweezy8757
    @lilweezy8757 2 роки тому

    When I try to run the code, it says AttributeError: 'Player' object has no attribute '_Sprite__g'
    Edit: I fixed that, but when I try to run, it simply wont open

  • @IronwingTechHaven
    @IronwingTechHaven 2 роки тому

    Nice tutorial.

  • @rmt3589
    @rmt3589 3 роки тому

    Can you do a tutorial on how to make a 3d open world game, like an mmo?

    • @ShawCode
      @ShawCode  3 роки тому +1

      That might be a little too ambitious for Python - you would need to use C++ or C# to make a game like that!

    • @rmt3589
      @rmt3589 3 роки тому

      @@ShawCode Was afraid of that. I have those languages on my list, but I'm still learning python rn.

    • @ShawCode
      @ShawCode  3 роки тому +1

      Nice - Good look with learning them!

    • @rmt3589
      @rmt3589 3 роки тому

      @@ShawCode Thanks! I'll need it!

  • @md.billalhossain2375
    @md.billalhossain2375 3 роки тому

    Great
    Love for you ❤️

  • @realSPDRMNKY6
    @realSPDRMNKY6 3 роки тому

    should this exact code work using Visual Studio Code? because I am having an error that says: AttributeError: module 'pygame.display' has no attribute 'set_mode_'.
    I would love to figure out what I can do to fix this since I dont fully understand everything you did in the tutorial making it hard to debug myself.
    Thanks for the video though I appreciated it!!!

    • @ShawCode
      @ShawCode  3 роки тому

      Please could you copy and paste your code? If there is anything you don't understand, let me know :D

    • @TLM-Nathan
      @TLM-Nathan 3 роки тому

      Mine is telling me: 'int' object is not callable

    • @ripetov2
      @ripetov2 4 місяці тому

      @@TLM-Nathan remove the () after the said object

  • @kordaling
    @kordaling 3 роки тому +1

    8:52 , i'v watched the next 30sec at least 100 times, seems like i don't understand classes anymore.

    • @ShawCode
      @ShawCode  3 роки тому +1

      What don't you understand?

    • @kordaling
      @kordaling 3 роки тому +1

      @@ShawCode thanks for the reply. "Passing that game as an objet"
      If i understand, you can pass class variables into another class? If it's the case why not use a super class instead?
      and
      why you write __init__ at the end, right after that?
      Thanks Shaw!

  • @godlikeshivam3172
    @godlikeshivam3172 3 роки тому

    love you so much bro thank a lot

  • @t3st3d
    @t3st3d 2 роки тому

    nice tutorial

    • @ShawCode
      @ShawCode  2 роки тому

      Thanks!

    • @t3st3d
      @t3st3d 2 роки тому

      @@ShawCode your welcome

  • @salemhosam2715
    @salemhosam2715 3 роки тому +1

    Very beautiful♡

    • @ShawCode
      @ShawCode  3 роки тому

      I'm glad you found it useful!

  • @projectgame6128
    @projectgame6128 3 роки тому

    good job I suggest you add a following algorithm. (only if you think its better)

    • @ShawCode
      @ShawCode  3 роки тому

      Thanks for the idea, I might add it in!

  • @shrijitmittra4476
    @shrijitmittra4476 3 роки тому

    Hey bro, really good tutorial. Would be good if you have any link to the source code. Nice tut btw

    • @ShawCode
      @ShawCode  3 роки тому

      Thanks! I will be releasing the source code on GitHub once I have finished the series.

    • @shrijitmittra4476
      @shrijitmittra4476 3 роки тому

      @@ShawCode Ok, that's nice. :)

  • @Comentad
    @Comentad 3 роки тому +1

    Thank you

  • @ihig912
    @ihig912 3 роки тому

    At first of all i would like to thank you for this tutorial and secondly i have some questions.
    I got some errors and i just start to programing with python, i am just a newbie, so i decide to ask hopefully you can help me.
    Traceback (most recent call last):
    File "C:\Users\Blank\AppData\Local\Programs\Python\Python39\Main.py", line 60, in
    g.main()
    File "C:\Users\Blank\AppData\Local\Programs\Python\Python39\Main.py", line 47, in main
    self.draw()
    File "C:\Users\Blank\AppData\Local\Programs\Python\Python39\Main.py", line 38, in draw
    self.all_sprites.draw(self.screen)
    File "C:\Users\Blank\AppData\Local\Programs\Python\Python39\lib\site-packages\pygame\sprite.py", line 845, in draw
    newrect = surface_blit(spr.image, spr.rect)
    TypeError: invalid destination position for blit
    I dont now how to fix this.
    As i said im just a newbie but it seams like something mess up with my pygame version.
    I hope you can help me XD.

    • @ShawCode
      @ShawCode  3 роки тому

      What is spr.rect? It has to be a tuple, for example: (100, 100)

    • @ihig912
      @ihig912 3 роки тому

      ​@@ShawCode i checked it out and spr.rect is not a tuple so i made it to a tuple with the value
      spr.rect = (0, 0)
      and now i can run this program.
      Thank you bro you helped me alot

  • @renamethetools8879
    @renamethetools8879 3 роки тому

    Dude, I tried to write the code several times in the same way that you do it, and it keeps giving me the same error:
    Traceback (most recent call last):
    File "C:\Users\Frankie\Desktop\PYGAME\main.py", line 62, in
    g.main()
    File "C:\Users\Frankie\Desktop\PYGAME\main.py", line 48, in main
    self.draw()
    File "C:\Users\Frankie\Desktop\PYGAME\main.py", line 38, in draw
    self.screen(BLACK)
    TypeError: 'pygame.Surface' object is not callable
    >>>
    Thanks for your time and dedication bro.

    • @ShawCode
      @ShawCode  3 роки тому

      It should be self.screen.fill(BLACK) rather than self.screen(BLACK)