Creating a Mario Maker style game in Python
Creating a Mario Maker style game in Python with a level editor, transitions, enemy behaviour, animations, menus and a player camera. It's a really chunky project.
If you want to support me: / clearcode
(You also get lots of perks)
Social stuff:
Twitter - / clear_coder
Discord - / discord
Timestamps:
000:00:00 - intro
00:01:48 - Introduction and editor
00:11:06 - Editor origin and support lines
00:45:47 - Changing the mouse cursor
00:49:32 - Creating the menu
01:43:36 - Creating the level tiles
02:11:56 - Level drawing logic
02:18:37 - Drawing the terrain
02:54:55 - Drawing the water
03:05:04 - Tile animations
03:24:17 - Deleting tiles
03:32:11 - Adding objects
04:11:13 - More on objects
04:23:19 - Previewing items in the editor
04:48:25 - Creating the editor sky
05:20:46 - Exporting the editor data
05:56:24 - Fixing some drawing issues
06:01:45 - Creating the level transition
06:20:25 - Creating the terrain and the player (in the level)
06:36:02 - Animating the level tiles
07:05:05 - Adding other objects
07:35:04 - Player movement
08:14:28 - Adding player graphics
08:27:47 - Creating the player camera
08:40:05 - Creating the shell enemy
09:05:58 - Creating the tooth enemy
09:22:49 - Adding player damage logic
09:31:28 - Creating the level sky
09:57:27 - Adding sound
10:08:12 - Finishing up
Sourcefiles are available here: github.com/clear-code-project...
Пікірлер: 295
You can get my pygame course here: www.udemy.com/course/learn-python-by-making-games/?referralCode=A80FECE8C76096E01111
@brandonjacksoon
Жыл бұрын
I'm not a pygame gamedev but I will buy it to support you. You are a cool person with clear and cool tutorials. Thanks!
@N0OBB
Жыл бұрын
getting all of the graphics is hard, especially the terrain 😓 EDIT: WHYYYYYYYYY ARE THERE SO MANY graphic/land GRAPHICS
@guilhermecampos8313
Жыл бұрын
I bought it and just finished the frooger game! Are you making or planing to make more courses?
@tuscanland
Жыл бұрын
I just signed up for Kinoppi, thank you!
@UnleashedEntomber
Жыл бұрын
Wow! you have udemy course! will enroll for sure
The amount of effort you put into these tutorials is astonishing
@DaBallsMan
Жыл бұрын
When did that adjective start existing 💀
@dkoorse
Жыл бұрын
@@DaBallsMan I never have seen it, but I understand it somehow
@catsouls4714
Жыл бұрын
@@DaBallsMan earth-shattering, dumbfoundingly, staggering
@DaBallsMan
Жыл бұрын
@@catsouls4714 took 3 months for bro to reply 💀
@KDYinYouTube
27 күн бұрын
@@DaBallsMan I learn that adj before the common one
My jaw dropped when I realized that you were literally narrating a video COHERENTLY during 10 hours of coding. I kept checking the video length because I thought I was just looking at it wrong. You are a legend dude. Hats off!
I can't imagine how much time you spend on this AWESOME tutorial. You are helping to community a lot. Best.
these are the most in-depth but easy to follow videos I've been able to find. Your work is astounding and appreciated!
Just reading the name of this video is insane! Thank you for all the work you put into these videos, they truly are fantastic!
i have just finished the introduction into pygame and that has helped me understand code so i can now follow you're harder and more complex tutorials such as this one thank you so much for the amount of time and effort you put into making these it helps out a lot since i am learning how to code.
This is simply amazing. I can't imagine how much effort you put into these tutorials. Thank you so much for your content, I've been learning a lot about advanced programming topics with you!
Thank you so much for the tutorial. So enjoyable to follow along and write code. This channel delivers probably the best Pygame related tutorials I have found on KZread this far.
Your tutorials are amazing! I'm quite familiar with pygame so I end up skimming mainly, but the fact that you go into so much detail is fantastic if I forget something. I love your venn diagrams for explaining things conceptually before jumping into code. The way you draw on the screen to explain code is great too! But even better than that, you make sure to mention details that others don't, like how something may affect your performance and how to tweak something if I want to do it a little differently. If I wasn't completely broke I would definitely donate to your Patreon for all your amazing content, you definitely deserve it!!
I just wanted to say, Thank You! Your tutorials have seriously been helpful. I've been working with books and other dry material. So again, Thanks.
Holy crap... this took me a month to get thru but well worth it. Thank you so much for these projects... I have learned so much (usually by making mistakes and spending an hour to fix it). If you follow along pay attention... steal your focus away for a second and you miss something important. Big thanks again! On to the next one....
I really appreciate your hard work and I look forward to supporting you as much as I can:)
Amazing video as always, the quality of the tutorials is top notch. Keep it up! :D
awesome tutorial, i've made some games before but this is really helpful in understanding the different pygame built in class methods, thank you !
Holy crap you uploaded this at the right time because I was actually working on my own (fairly flawed) level editor. Thanks for the time save clearcode, you absolute legend!
@ClearCode
Жыл бұрын
It took so long to get the level editor right! Hope it will help :)
@N0OBB
Жыл бұрын
@@ClearCode i can learn from this and try to create my own (edited) version of it
@davidfilep1106
5 ай бұрын
Oh my god. You are actually a human who did not born "speaking" python. Everytime I watch your videos I'm thinking "How the fuck is this guy so good?!" It feels good to see it takes time for even you to get things right and working. Of course nobody is gonna upload a video about something they did not figure out yet but some of these tutorials really take my will to code or even live away lol. Whilst it has tremendous educational value it also makes me feel like I'm dumb. Keep it up mate!@@ClearCode
Awesome course! Thanks Clear Code!
Keep it up bro. Sick content with simple explanations!
Great video again! I can't wait to watch and imply all these :)
I was eager for this video! Thank you so much!
I thought the thumbnail looked familiar. You are using the same asset pack I am using in my tutorial for a platformer, but in Java. Nice work man!
Great video as always! I love your content! In the "get_current_cell" method in your editor, an alternative option to solve the coordinate problem, could be to just use floor division. That way, you dont have to use an if-statement, and the code would look a bit cleaner.
For those wondering why the pearl does not always spawn (around 9:00:00) for some versions of Python or pygame (In Python 3.11.2 and pygame 2.5.2), do NOT use the groups()[0] as a Pearl parameter to get the all_sprites group. For exemple pass it explicitly through the Shell arguments from Level. It seems the groups() does NOT keep the ordering, hence all_sprites is not always [0].
@quilmatic
4 ай бұрын
thanks for sharing! I was wondering why the pearls wouldn't spawn consistently.
@dafxer
4 ай бұрын
True, I found this odd sprite group ordering bahaviour in PYdew Valley tutorial kzread.info/dash/bejne/hmh9upVvo7PFYMY.html, when creating and displaying apples on the trees. It took me some time to find why apples was sometimes rendered and sometimes not.
@dafxer
4 ай бұрын
So there are 2 solutions, first is explicitly pass all_sprites, and second is to override pygame.sprite.Group and add name parameter and self.name attribute like so: self.all_sprites = pygame.sprite.Group(name="all_sprites") In this scenario, you can target respective group not by self.groups[0], but with use of for group in self.groups: if group name == "all_sprites" : .... and so on :-)
@TriggerHappyRC1
3 ай бұрын
Thank you! This should have a lot more upvotes...
@blackholesun4942
3 ай бұрын
Thank you I had the same issue
Only one word 'AMAZING'
Your videos are wonderful. You have done a very good job. Well done!!!!
excellent tutorial, I hope that soon I will be able to master all the knowledge that you teach
Thank you so much for the tutorials.
Fantastic work. Bravo
nice and excellent tutorial. clearly and elaborate.
@ClearCode
Жыл бұрын
Thank you so much :)
Years ago I was asking to make games some old IT guy at my school recommended python I didn’t think it had the capability but you’ve shown true commitment
You are crazy... It's an awesome tutorial and you prolly put your whole soul in it ! GG
Bro, this is awesome 😎💥
Thank you very much. I am in love with your channel
Well Done! Thanks!
clear code you're the best !
Thanks Clear Code!
These videos are amazing
Awesome! Thanks! You are the best ;)
wow you deserve so much more
Thank you for this video
I really wish I could financially support you!!! Your channel is goldmine for programming.
I'm looking for this man
You're incredible.
Respect to you and thank you.
10 hours???? I LOVE YOU
Hello Christian, just stumbled upon on this course and I immediately bought your two courses on Udemy 🙂 Thank you for this great course. I am a Python veteran (I use it since 1997) and I have develop some mini games with PyGame, but seeing your approach on some solutions is a great resource! Please, make more content on Godot (as your other Udemy course does) which I think is growing very strong! Ciao!
@ClearCode
Жыл бұрын
Hey, thank you so much, I will make lots of Godot stuff once version 4 is out. Once that is out I will also retire the Godot udemy course, so I'm afraid you won't get much use out of that one. (you can get your money back for 30 days)
cool artstyle
Thanks Cris for another incredible tutorial, your hard work is much appreciated. Just one question, how do I save the level so I can keep working on it or playing it another day? In other words, how do I make level 1, then 2, etc.?
Re belicooo! Saludo desde Colombia
Finally you post new video😂
This is the third long tutorial of yours I follow and I really enjoy them. The quality is great. One thing I noticed so far, if I may, is that using the modulo operator would simplify the code and the explanation. For exemple here, around 37:00, the grid can be done with: for col in range(cols): x = (self.origin.x % TILE_SIZE) + (col * TILE_SIZE) pygame.draw.line(self.display_surface, LINE_COLOR, (x, 0), (x, WINDOW_HEIGHT)) and same for rows (no need for the "offset_vector")
@ClearCode
5 ай бұрын
I should have also used it for the animations! My brain somehow doesn't like modulo, one of my new years resolutions is to use it more :D Also, glad to hear you like the tutorials :)
I clicked on the video looking for bronze, and I found it was gold. the perfect tutorial
Eu adoro seu conteudo cara! Parabens pelo seu trabalho!!! (Portuguese)
Coder Space and you are the best
respect for this video god damn
Great!!! thanks!!!
New suscriptor 👍🏻
Amazing tutorials pls dont stop... i know its a lot of time and effort.. but...
CRAZY!
really helped me a lot to learn about working with gui. next up please make one for pygame with moderngl (opengl bindings for python)
bruh your going to be making some kids happy :D
We want more pygame tutorials!!
hey, please, tell us about surface opacity (smooth appearance and disappearance). I didn't find any information on this on the internet. Thank you.
if this is the quality of the free tutorial, I wonder how amazing the udemy course would be
I noticed something interesting around 1:54:40: In the get_current_cell() method this is what I did before looking at your solution: col, row = distance_to_origin // TILE_SIZE #(vector integer-divided by a scalar) col, row = int(col), int(row) #get rid of float I then noticed that I did NOT have the double (0, 0) cell you got by doing "int(x / TILE_SIZE)". And indeed, the '//' is also called 'floor division' so the result gets rounded down. Sure enough: int(-10.71 // 64) = -1 ; whereas int(-10.71 / 64) = 0 So the '//' is a pretty elegant solution to fix the issue there.
@quilmatic
4 ай бұрын
I also noticed this as well, thank for sharing!
wow, didnt know that python is capable of this! slamming a like
OK, nice one - sat through the whole thing. Everything works except the "bg" palms keep popping on the foreground during the gameplay portion(workd fine in the editor), for some reason. Can't say I picked up exactly 100% but definitely improved my overall understanding of the topic.
As a suggestion for the future projects: City building game, survival game or something like Foreger.
@ClearCode
Жыл бұрын
next one will be Doom :)
@chigstardan7285
Жыл бұрын
@@ClearCode I would love to see how you explain raycasting to make doom render environment other tutorials just seem to rush
1:55:49 you can avoid if statements by using math.floor. The floor function will round down to minus infinity which will round down -0.5 to -1 for example.
@yisus
2 ай бұрын
I did that part using integer division and I didn't have to use if statements def get_cell(self, pos): return (pos[0] - int(self.origin.x)) // TILE_SIZE, (pos[1] - int(self.origin.y)) // TILE_SIZE
Hey mate, i love your videos and follow them along. I learned so much through your videos but i sometimes keep struggling to find the right way to think about stuff. i'm not copy & pasting your stuff i always google if i don't understand something but if i have to do something like this from scratch by my own it's really hard. do you have any tips how to get there faster? or is just doing and time will tell?
@limeedhot
Жыл бұрын
i learned python by just following these then branching off a little bit i kept getting errors and then i googled up what they meant and then yes time will get you there you said this 4 months ago and i did not realize this until i wrote the comment i hope you have learned python
Why are you so awesome?
For anyone wondering how to save and load maps, I've made a bit changes to the code so you can save and load your maps: def load_grid(self): grid = {(6, 3): 4, (7, 3): 4, (7, 4): 4, (8, 4): 4, (9, 5): 4, (10, 5): 4, (11, 5): 4, (12, 5): 4, (13, 5): 4, (14, 4): 4, (13, 4): 4, (12, 4): 4, (11, 4): 4, (10, 4): 4, (9, 6): 4, (9, 7): 4, (10, 7): 4, (6, 8): 2, (7, 8): 2, (8, 8): 2, (9, 8): 2, (10, 8): 2, (11, 8): 2, (12, 8): 2, (8, 6): 8, (12, 7): 8} for element in grid.items(): current_cell, object_id = element[0], element[1] if EDITOR_DATA[object_id]['type'] == 'tile': self.canvas_data[current_cell] = CanvasTile(object_id) self.check_neighbors(current_cell) def save_grid(self): res = {obj[0]: obj[1].tile_id for obj in self.canvas_data.items()} print(res) I binded these to keys to make them work, the save_grid just prints out the current grid that you can save as you want and the load_grid loads the grid to the editor, it is not much but I hope I was able to help someone.
@8-bitavatar696
Жыл бұрын
Appreciate this. I sort of got it working..I think. You put both of these methods in the Editor Class and the key bindings in the loop method?
@Sekiraw-911
Жыл бұрын
@@8-bitavatar696 The objects won’t be saved, so you need to make a method for that similar to this and save that result into a different .pickle file and on the load, you read them both
@Sekiraw-911
Жыл бұрын
@@8-bitavatar696 You can store the values in .pickle files and read from that
@Sekiraw-911
Жыл бұрын
@@8-bitavatar696 if you send me and email or something I can send you the upgraded version
@8-bitavatar696
Жыл бұрын
@@Sekiraw-911 I sent ya one, thanks.
Thanks!
@magickaito
9 ай бұрын
Just figure out how to donate and I really want to say thank you for your pygame tutorials. I really enjoyed learning from them. Keep up with your great works!!
@ClearCode
9 ай бұрын
Thank you so much! And super happy to hear that you enjoy the tutorials :)
很棒! (it means great ,awesome)
Is there a pyhton code which is able to detect some colors around a point determined on an image.For example it will say that "there is yellow color at a 2 cm distance from your point." Thanks
really amazing, the best tutorial I've ever seen.thanks, Christian. but I want to mention a small bug, when I'm running the game in a not full screen window, of course in the playing level mode, if I try to move the window, the game would turn into a sky mode, only the player with the sea, no other objects. it seems the player has fallen down in loop. can you found out whats the problem? thanks
its the best
It would be amazing if you released an blooper series where for some time you are being frustrated doing bug fixing/hunting
pixel frog really made a good assets, i'm using too
What do you use to record/doodle?
Found the tutorial so useful for my current project. Could you help with how to attack and have a health bar
38:52, could you use %64 to find the offset? Like 128 becomes 0, 259 becomes 3? That seems easier to me.
@pollefevre817
Жыл бұрын
I was trying to find a comment speaking about it because it was itching me a bit :D
Experiencing some weirdness with the animations. Idk if it's a Linux thing, or what. The animations seem to cycle through almost randomly. For instance the idle animation of tooth is just odd. I can't figure out why. I tried your code from the project too. Same thing. Great tutorial btw. I love you take a second to explain WHY we are doing what we are doing
I love ur videos, and I greatly appreciate them! Can you do a Pac Man game next? Thank you in advance.
Thank you for the grate work. How can i save and load the maps i create?
Hello Clear code. In first thank you for the video ! How can I get sprites sets with the coding convention A [...] ABCDEF. Do I have to do everything by hand? How did you do it?
Dude you are a genius + cool guy, thanks!
python is really great
I have another error where from 2:28:10 and onwards , it gave me an error saying key error: 'X' , I've copied the code and everything seems right but it still gave me the error. The error says 'NoneType' object is not subscriptable
Just a question, where do you get all these images for the characters, environment, etc??
@ClearCode
Жыл бұрын
opengameart and itch.io have lots of resources you can use for free.
@migasgt638
Жыл бұрын
@@ClearCode Tysm! Ur videos are awesome btw
😮buen video
Amazing can’t wait to tackle this. What laptop would be best for these kind of projects? I’m really wanting to buy a macbook , one with 16gb ram and 1tb storage
@alvarocubi
Жыл бұрын
Even with a very cheap laptop of much lower specs that you mention you would have no problem running these type of projects, don't worry
@d4rksoci3ty
Жыл бұрын
@@alvarocubi cool thank you Álvaro
Hey! Great video, I've used you for all my learning on pygame and managed to create my own project almost entirely on my own thanks to you! I've been following along this video and just needed a little clarification on one thing: what is the self doing that we keep calling? Where is it coming from and why are we using it? Is it just a variable? Or a way of running the commands! Anyone that knows help would be greatly appreciated!
@griffin-leonard
Жыл бұрын
When you have a class in Python, self refers to that class from within the class itself. For example, if I make an instance of a class called Example, I'd write something like: obj = Example() To call the class's draw method, I'd write obj.draw() I could write something like Example().draw() But if I'm inside of another class method, like update, you call it using self because there isn't a specific instance of Example yet to call. So I'd write self.draw() Self can access attributes (variables stored in that object, usually declared in the class's __init__ method) and methods (functions belonging to a class, which will almost always take self as the first argument) If you're still confused look up a video on Python classes or object oriented programming (oop)
I an new to python watched both videos introduction and this one now I know how to make a editor and level but I still don't know how to save the map and player status can u make a video for this one how to save and run a map and in game player save status
does anybody have the problem that the mouse button's don't register. I can manage to move the screen with my middle mouse button, but when clicking on the menu tiles nothing happens. I can't select any of the tiles neither change the palm trees. Been looking in to it but can't find the problem.
hey, awesome video. an idea: could you not use a modulus operator to do the same as you do here 14:52? in sted of line 53-55 you could just use: originOffsett = self.origin originOffsett.x %= TILE_SIZE again. awesome video!
Bro this is awesome and also can u tell me whats the cool music on the start
@ClearCode
Жыл бұрын
It is called "on the offensive" by Ted Kerr / Wolfgang, you can find it here: opengameart.org/content/8-bit-theme-on-the-offensive
I WISH THERE'S A CHANNEL LIKE THIS BUT ABOUT DATA
@ClearCode
Жыл бұрын
working on it...
@duytrkhanh
Жыл бұрын
@@ClearCode OMG thank you, I love your content so much, I'm looking forward to it.
I think you should do a behaviour tree implementation for enemy AI tutorial with pygame
What program did you use for drawing on the screen? Or is editing magic ;) ?
@ClearCode
Жыл бұрын
The app is called Epic Pen :)