Creating a Zelda style game in Python [with some Dark Souls elements]
HTML-код
- Опубликовано: 21 май 2024
- A Zelda-style RPG in Python that includes a lot of elements you need for a sophisticated game like graphics and animations, fake depth; upgrade mechanics, a level map and quite a bit more.
Thanks for AI camp for sponsoring this video. You can find the link to their summer camp here: www.ai-camp.org/
If you want to support me: / clearcode
(You also get lots of perks)
Social stuff:
Twitter - / clear_coder
Discord - / discord
Timestamps:
0:00:00 - intro
0:02:30 - Project setup
0:06:52 - Level setup
0:28:38 - Creating the player
0:49:47 - Creating the camera
1:11:30 - Graphics
1:56:00 - Player animations
2:30:26 - Weapons
3:04:20 - UI
3:44:03 - Magic setup
4:00:19 - Enemy creation
4:57:00 - Player-enemy interaction
5:32:50 - Particles
5:56:25 - Spells
6:26:35 - Upgrade system and menu
7:24:26 - final fixes & sound
Related tutorials:
Introduction to pygame - • The ultimate introduct...
Using Tiled with pygame - • Creating a Mario style...
Debugging in pygame - • Debugging in Pygame
Project files:
github.com/clear-code-project...
Pastebin files:
pastebin.com/u/ClearCode/1/MB...
Artwork by Pixel-Boy and AAA
pixel-boy.itch.io/ninja-adven...
Just made my first “hello world” in my python class. Guess it’s time to make Zelda now
I think it should be better if you learned the language first. I talk for experience, doing something without understanding/remembering how to do it by yourself is kind of useless and is going to make you lose lots of hours
@@crops1646 he's being sarcastic bro
@@aperture0 you're probably right but maybe someone else could see this comment and believe it's a great idea
@@crops1646 ah I see your point
@@crops1646 hey i want to be a programmer what language should i study first?
It's honestly mind-boggling that we get this kind of content for free and that well put up together. I can't thank you enough for your work and passion to spread your knowledge! Keep it up, you're great
I agree
So true!
yup.
True that!
Thnx @Clear Code
AI Camp here - we are so proud that we sponsored this great video. Cannot wait for the summer to happen to see what people will create!
Thank you
There are 256 subs right now, why must I be the one who has to ruin such a perfect binary number??
@@harmitchhabra989 leo?
I'm actually in awe to see such a video so well put together. Thank you for sponsoring this!
@@WolfsInk You are mostly welcome!
I can't believe what I am seeing. Just a few weeks ago I nearly gave up in frustration for lack of quality pygame tutorials, specifically for a Zelda style RPG. Then I found your channel and I started on your course at Udemy. I said to myself, I only wish he'd do Zelda. AND OMG here we are. Thank you very much, You have a real knack for knowing your audience... And your devotion to teaching has changed my life.
It seems like you manifested this lesson.
How did it go? Did you make one
@@Drake00000010 A bit of a delay. I had some life stuff happen so I am just now finishing it up. A fantastic tutorial on par with all of his really great content.
@@K5RTO Which is his course on Udemy that you are referring to? Even practically in the year 2024, after some changes, is it worth it? I'm still new to the area, I have some questions
Who has the audacity to Dislike videos like these? It's truly insane that you can offer a free informative, educational video and somehow that's a bad thing.
I found your channel by chance with this video and in two days I managed to follow you step by step and actually create the game. You can't even imagine how I happy I am right now!
Thank you very much man, this project must have been really heavy so really thank you so much for doing it and sharing it here!
This channel is actually underrated, he is also the one who made tutorial to make minecraft in Python.
Great tutorials, keep it up
I thought this was a 7 min video at first :D I was not expecting a programming video when I clicked it, but thank you very much for creating this. It must have taken a lot of work and I appreciate it very much.
I didn't even look at the time, I didn't even see it's 7 fucking hours long.
@@The_True_Mx_Pink im assuming you arent a programmer lol thats pretty normal for a tutorial
@@MaxwellJWhite You are correct
Same I thought it's just vidoe of somone making pygame zelda than a entire tutorial
What version of python is this
This was a terrific introduction to pygame, the only thing that we forgot to add was a player death mechanic but I'm taking on the challenge on my own and feel well prepared to do so. Thank you so much!
Well, to be fair, he did point it out. Reason he didn't implement it is because it's easier to test your game mechanics if you don't also have to worry about not dying.
can you ask with, passwork of file
I can ask with, passwork of file if I really wanted to. But, can YOU? That's the real question.
This looks incredible, can't wait to dig into it. Agree with the other comments I'm seeing, this is the *exact* tutorial for PyGame that I've been desiring for a few years now.
This channel is by far the greatest coding channel judging by the deliverance of information, keep up the good stuff!
Looking forward for more of your great pygame tutorials!
What version of python is this
Thank you so much for the pygame walkthrough! I blew people away in my intro to python class and I only turned in milestone 1 for my project. Which was having collisions working without any of the camera. I am so grateful for your explanations. Keep it up!!
Oh Wow, the amount of work you put into your videos is overwhelming. Your channel is extremely underrated. Keep it going!
I am going through the side scrolling videos now, and I can’t wait to get to this one. Looks amazing!!!
i had alot of "importing" errors until i realized i need to (ctrl+s) save each of the modules before running the main module for the updated code to work. great video. i learned quite a bit about pygame. thank you :)
As a python enthusiast and huge fan of LoZ/DS games, I'm greatly looking forward to watching this. My first major project a few years ago was creating an old-school text adventure that runs in the CLI, and I created a simple animated dungeon map that can be called from within (using pygame). I've been planning to whip up some sort of 2d adventure game like this next - can't wait to dig in.
After a couple weeks, I FINALLY finished this tutorial. I had gone through a pygame textbook that was pretty outdated and this introduced me to so many concepts that the book didn't have. Thanks so much for this amazing tutorial!
can i make this with a 4gb ram laptop?
@@dragonriderjohann7683 sure you can
PLS NAME THE BOOK
@BitDifferent
Kwispy cream do you still have the code ? I tried recreating it but it always shows the error
This is insanity, i've never seen a tutorial like this.... incredibly impressive. I wish I had this a few years ago, it's not so helpful to me now (especially at this length) but if anyone is a beginner this is great!
When I started learning Python on my own, I knew the basics but had no idea how to apply what I learned. This project is helping me because many abstract concepts are now solidifying inside my mind. Thank you so, so much for the great content you put out and for your patience, you are an EXCELLENT teacher, really! The effort you put into being thorough in your explanations is greatly appreciated!
Hey there! Just finished this tutorial among other you have uploaded. Just off to say you make really good resources for people to learn new things. Keep it up and THANK YOU.
Wow! This is fantastic! This channel and the Coding with Russ channel are right up there with this type of content and tutorials. Thank you so much for this, it is very much appreciated. The time and effort you have put into this, its astounding! :)
These are the best tutorials one can find, thanks for the great content!
I've been watching this a little bit every day and I finally reached the end of the video. This was really cool, and I loved the end result!
This is absolutely amazing. Instantly subscribed. I’ve always wanted to create a game like this style using Python, this is great! Thanks for posting, awesome job
This is amazing, and I can't believe I haven't subbed yet. I'm going to be modifying this code for an online-rpg style project I'm working on. Thanks so much for the great tutorial!
I saw you mentioned making this video a while back, I didn't think it would be like this! You've really outdone yourself!
I don’t give a shit.
This was such an amazing project! I really wanted to start making adventurous games such as Pokémon and I have to say this tutorial covers already so much amazing what you did! You are amazing!
Really impressive training session!! Great work, my friend!
Genius and philanthropist, you just make my day and the world better, congrats and cheers from France
More projects like these will be amazing!
Fantastic work. Very appreciative of this free content that you provide, and it's done so professionally. Thank you!
Just came out of a Uni CS class where our final project used PYGAME. I can actually understand a lot of what you're doing and it's impeccable. Absolutely love this! Warms my LOZ nerd heart!!
I really appreciate you leaving your mistakes in. It makes a beginner coder like me feel better about myself when I make errors.
Thank you for the amazing pygame tutorials, you are really underrated.
Incredible the quality of your work and sharing this with the whole world for free!!! We can't thank you enough!
You are on of the most underrated RUclipsrs on the platform. Thank you for your content.
For a moment i thought this is just a project made by a team of professionals, the second moment i realized this is a WHOLE tutorial
Holy crap this is next level dude!! Keep up the good work!!
@Florian D. True, python and pygame are great to make games as a side project, but professionaly i would never use pygame. Don't get me wrong I love pygame.
@@foxtro484 what would you recommend then? particularly for C++
@@purpleplantain374 yeah java or c++ is mostly used for making games
What version of python is this
@@loganwow Maybe It Python 3 python 2 is abit too old
You are so my favourite coder on RUclips. I cant believe that this is so much better and CHEAPER (free) compared to school coding classes.
Keep up the good work!!
Suggestion: pls do another tutorial is python ursina??
Omg this was some next level effort. Dont know if I'll ever come to get to this tutorial, but thanks for doing it!
I am glad to see there are always talents people like you who willing to produce such quality and FREE courses for all, this is meaningful, splendid, and much appreciated! Please produce more quality courses, for the whole industry and humanity.
Dude, you are just awesome! Very impressive what you build here. Isn´t it awesome that programmers are able to make the inner child live forever this way? :-)
I think new coders would also benefit from seeing how you divided each pack into your local files because your file locations are integral to your code, but we download them differently from PixelBoy. So as we code, we sort through a lot of things that you have preorganized. Seeing how you have them organized in each file would be helpful in the setup intro part of your vid.
I am a new coder and sorted through those exact problems
I experienced this as well! I love the tutorial,
yeah im stuck i cant even find the rock.png in the pixel boys file
Trust me guys with just a little messing around their is no problem in coding you guys can’t figure out!! I’ve followed so many tutorials since then made 20+ games and became a pygame master and the main thing I’ve taken away from all this was how to problem solve!! You guys got this!!
@@WhatsNextFamso how’d you get your own tile for the rock.png
I’ve enjoyed your tutorials the most , been learning a lot and made 2 games so far, thanks a lot !!!!!!
Finally, I've made the first production with python thanks to you Clear Code! It took me like a month to finish this and I kinda understood how to make a game with python. It helped me a lot to improve for myself. Thank you Again!!
Sir, I just wanna tell you that you. have changed my life with software, and I admire your teaching style more that anyone's. Thank you for putting out amazing content and never failing to help us.
Just finished the entire tutorial! Wonderful! Thank you so much for putting this together and teaching pygame.
I’m almost done, I’m thinking of adding new levels. Hell, I might post them on my GitHub
Another amazing tutorial, thank you so much for all the work you put out here!
This is so great! I can't wait until I can get on this level of programming and can follow along with this and genuinely understand it!
what a legend, creating zelda in python. can't even imagine doing that with or without motivation
I’m an hour in and I can say this: yes, a lot of this is going over my head right now because I don’t have a good enough grasp of Python classes, but WOW. Your presentation is impeccable… perfect pace, great examples, and the logical flow is really helpful. Incredible resource.
What version of python is this
@@loganwow Python 3, I would assume 3.9+
To anyone feeling the same struggle: try watching his other videos in conjunction with this one. Such as the Super Mario video from a year ago and "Creating a platformer in Pygame". If your problem isn't simply understanding Pygame, but programming in general, I suggest practicing with simpler concepts first such as importing libraries, making functions and executables or even simple lists.
I´ve already watched that on Patreon it was amazing!
Very cool project. It was very interesting to see your working-process!
I love the game and the art!
I made it through the whole thing. Thanks a million!
I'll be honest many times I skipped the announce for the sponsor but I video at this quality can't be rewarded enough, and it's free ! massive thanks to you I've been here for a long time and I am always amazed by the games and logic that you come up with.
Took quite a bit longer than 7.5 hours but successfully completed over a weekend. Thank you so much for this! Looking forward to following along with your other guides
I was wondering how it was possible for such quality content to only have 500 views, but then I realised that I had caught this video just shortly after it had released.
The value of what you're giving the world simply can't be overstated, sir. You're an example of the kind of person that spends their time uplifting others and it's a pleasure to learn from you
Thank you so much for your kindness ! Sharing this tutorial made me love this ! I hope you publish as time goes on... Tysm!
What you do is incredible!
Excellent tutorial! Would you be interested in making up a tiny follow-up video to show how to code:
1) a game over "state" upon player death
2) a level "reset/retry" option after the player dies
3) how to load a new level upon clearing an "objective"
Integrate his overworld code from the mario platformer tutorial. Beware though, it resets the exp and menu settings every level... not been able to get the ui and upgrades into the game class yet so they stay with the player each level...
@@mattowen1812 i know I’m late to the party here, but i may have figured out a solution to this. Let me know if you’re still stuck
@@thatguy-cf5gs Hi. What was your solution eventually? I think I put all player variables I want to persist in a dictionary in the settings file.
Alternatively, a method that passes current_exp to a new_exp variable then create level function with the new_exp passed in.
I did this with my metroidvania here with the weapons the player has when swapping levels (or rooms in this case) m.ruclips.net/video/KhVwVFdolJs/видео.html
Here at the second it came and already know its gonna be awesome
Really appreciate this tutorial! Even though it is pygame related, it contains such great insights into how a project should be structured with as little hardcoding as possible.
This one should be watched, no matter if you are into creating games or not.
What a great tutorial. I have never programmed in python and this most likely will be my first one because it’s awesome! This was also my first SuperThanks$ here on RUclips. I’ve never seen such amazing work being freely presented. 👏🏻
this tutorial is fantastic!
As a fan of both Zelda and Dark Souls, I was ecstatic to find this tutorial. Clear Code, your ability to teach complex concepts in an easy-to-understand manner is truly impressive. Your dedication to providing high-quality, free educational content for aspiring developers is greatly appreciated. I can't wait to start working on my own Python-based RPG using the skills I've learned from your tutorial. Thank you for your hard work and for sharing your knowledge with the world!
An absolutely amazing tutorial. It's very thought provoking in a sense. Kudos to everyone who made it to the end :)
Thank you so much for your generosity in sharing this with us!
Can't wait to give this a shot and learn. I've been interested in a Zelda clone but Most are super old /outdated.
You deserve much more subs 😃😃
This is a really cool video, thank you very much for making it! It helped me very much understanding pygame, so a big thank you!
Finished your tutorial, thank you so much for the detail, I know this had to take forever to make, but it was worth it, IMO
It's Awesome
Just as a heads up to help those of you starting, theres way more than 7.5 hours of tutorial here. With bug fixing, exercises and working on theory discussed its probably closer to 18. To help you time box, you should double the minutes in each section to estimate how long each section will take.
Awesome content and well explained. Perfection!
this is amazing! thanks for helping me learn to code, I love your content!
I'm at 2:56:43 right now, so I don't know if it'll be fixed later in the video, but because of the Y-sorting draw of the sprites, the weapon is overlaping the underneath sprite while the player is overlaped by the sprite, I think that to fix this, we should create another group of visible sprites, that will be drawn above all
If you enjoy this tutorial check out my pygame course: www.udemy.com/course/learn-python-by-making-games/?referralCode=A80FECE8C76096E01111
Already own it :)
I have finally reached the end! Thank you very much for all of that hard work :)
Mind boggling man i hope this stays for ever ❤️❤️
Это очень крутая работа!!!! Спасибо тебе большое за проделанную сложную работу. Уже потерял надежду и думал, что это невозможно на Python.
Согласен. Многие почему-то думают, что Python годится только для каких-нибудь простеньких приложений.
yes i love python so much
Hey !
So im a mac user and i got stuck during the graphic part of the video (around 1:50:00), the probleme was that i was getting the worng sprites for the objects (getting statues instead of trees, etc.).
After a bit of testing i undestood that the Mac os walk function doesnt "walk" throught the directory in the correct order so the list we're creating(image_surf) is unsorted.
If u're struggling with the same issue, define a new list to get every images from the walk function, then sort it and iterate angain throught the sorted list.
def import_folder(path):
surface_list = []
sorted_list = []
for _, __, img_files in walk(path):
for image in img_files:
sorted_list.append(image)
sorted_list.sort()
for img in sorted_list:
full_path = path + "/" + img
image_surf = pygame.image.load(full_path).convert_alpha()
surface_list.append(image_surf)
It works now, i can keep enjoying your tutorial :)
Hey, I run into the same problem as you did, but I wouldn't ever solve it on my own. Thanks a lot for your help!
Thank you so much! I was stuck on this too on Mac
why can't i run?
"pygame.error: Unsupported image format"
OMG thank you! I was trying to figure this out by looking at the object csv files and seeing why they didn't match the ones in the video. I have to imagine it would've taken me a long time to consider that the walk() function was a possible culprit.
I think there's a shorter way to solve the issue. Just add the line img_files.sort() inside the first for loop, like so:
for _, __, img_files in walk(path):
img_files.sort()
for image in img_files:
I had the same issue, also on mac. The basic sort() was not sufficient for me as I standardized the naming of the files to be n instead of 0n. 0.png, 1.png, 2.png instead of 0.png, 01.png, 02.png etc. I did this because if you had hundreds of files you would have odd names such as 001.png, 002.png and even worse if you were to have thousands or more files.
Any how I put this in a try, except block:
files = sorted(files, key=lambda file_name: int(file_name.split('.')[0]))
Absolutly awesome! Thanks for sharing!
This is the coolest project I have seen!!!
Its funny to me, as a child it was always magical and beyond my scope
As a adult in college, it was still magical and beyond my scope
Now, nearly 28, it's STILL magical and out of my scope 😂 but there's a lot of cool resources like this video to teach me it's not /as/ crazy as I always believed ❤
This is such an amazing tutorial! Will you be able to do a dialog box and npc interaction video?
Amazing, 7 hours of footage! Thanks a lot!
Much love 2 you. I spent an entire day going through everything and trying to understand it.
How is this free?
Please keep up this amazing work
Thanks man, what a great tutorial! I had one big issue at the beginning: I got some error messages after setting the sprites in the row and col index and it took me some time to find out that, In my case, the graphic import at 16:31 did not work at all. I had to move the grapics folder to the code folder and get rid of the "../" part in path in both, tile.py and player.py.
I did the same thing, and it took me a little bit to figure it out. The "../" drops back one directory before going to the graphics directory. If you put your code in its own "code" folder instead of in the main folder, it loads the graphics files just fine. Next you need to sort out this error:
File "../Zelda Tutorial/code/main.py", line 23, in run
self.screen.fill('black')
TypeError: invalid color argument
I put standardized color tuples into settings.py and tossed in a line importing those settings into debug.py.
or u can just remove one of the dots
i solved it by adding another "/.." to the path
Because the reference folder is one level deeper, so it looks like this
"../../graphics/test/rock.png",
Im returning two folders instead of one
Been watching this video for weeks (I am taking my sweet time) and will be watching it for longer, and I have to say I have never been more excited for a coding tutorial
Amazing content, and very clear presentation.
For the player animations this line of code "self.image = animation[int(self.frame_index)]" always causes an error called "IndexError: list index out of range". Does anyone know a reason or a mistake I might have made?
Edit: I have now fixed it, it was cause when i was giving a file path for the animations I didn't put a slash at the end
Thank you so much, I had the exact same issue
I have this specific mistake too; what file path for the animations are you referring to? the player’s?
First of all, thank you for your tutorial! You have done a great deal of work:)
But when I see some of the decisions you made, my eye twitching a little...
The game is absolutely unscalable (may be you will rewrite it later in the video I have seen only an hour of your tutorial yet) . You call update method for all visible objects when in fact only player has update method. You check collisions with all obstacles when you can check only with objects in small area around player. And it absolutely blew my mind when you decided to sort all objects before drawing at each frame!!! When the only thing which changes the relative position is player!
I think that you at least have to tell people that there is a better way to write your code:)
To be more constructive. The usual way to deal with collisions is geohash. You have to store your collidable objects in a hashmap with rounded coordinates as keys. Then you have constant complexity of computing collisions.
And you can store static objects in sorted group apart from dynamic then at each step you will have to sort only dynamic object which are present on the screen. Keeping in mind that you usually have way more static objects than dynamic, it will be a significant reduce in computational complexity.
This concerns me as Im following this for a project due Tuesday, hoping to pick up bits to add to my game, but Im not sure it will be worth it for scalability issues. I've noticed a problem with a lot of things in Pygame tutorials being limited to just what they are doing with not much explanation on the ability for scalability. If you know of anything please let me know
What a great tutorial, thank you so much for putting this together and offering it for free. A real gift to coders getting started with python game creation.
You are blowing my mind for a completely guide. Thanks very much for your sharing knowledge
Screw it, I'm learning Python.
bool('You can do it!')
Does someone know how Clear Code gets these perfect sized graphics? I can only get those small ones that looks awful when I maximize the width and height.
1. Make sure you find good looking assets. Opengamearts and itch.io both have some really good (and free ones) but you do need to look for a bit
2. You can use a pixel scaler (lospec.com/pixel-art-scaler/) that can increase the size of an art asset without losing quality (for pixel art).
3. What also helped is that I set my screen scaling to 250% so that my 4K screen works more like 720p screen, which does make things look better. Obviously that doesn't work for actual games so make sure to focus on step 1 and 2
Hope that helps :)
@@ClearCode Yes it does, thanks! :D
omg, here are some really nice content! thanks for the nice video!!
Wow, this is next level! There are some points where I'd solve things differently. E.g. the repetitive if statements in order to assign a value to a variable could've been solved more elegantly using dictionary indexing. And adherence to PEP-8. Small stuff like that. But the presentation is on a level worthy of admiration. The way you explain everything as you go, providing sufficient context or explanation so the audience knows at every moment what you're doing and why. How you break the project into pieces and how you tackle them in succession without losing track of the goal. It's obvious a ton of preparation went into this, way in excess of the almost 8 hours of resulting video. And this is just one of many such videos you've put out so far. Thanks for such great tutorials!
What kind of software/IDE did you use?