I think that a more performance friendly way of filling the surfaces with color would be to use the "special_flags" argument of Surface.fill() as it will only fill non-transparent pixels with the color that you want. Iterating pixel by pixel might be slow in the context of a bigger game. Great video on masks!
@ClearCode3 жыл бұрын
oh damn, I totally forgot that fill also has special flags... that would have been very useful :D
@StarFury22 жыл бұрын
If some are confused what guys are talking about: new_obstacle_surf.set_colorkey((0, 0, 0)) new_obstacle_surf.fill('orange', special_flags=pygame.BLEND_RGBA_MULT) does the same thing as that 'for' loop with 'get_at' and 'set_at' methods, but much more efficiently. Though latter gives you clue about useful get_at / set_at methods.
@wouterbosch45712 жыл бұрын
I dont understand what exactly you would put down for this as the special_flags argument to achieve this. Could you explain?
@Persona-jt4qvАй бұрын
58:30 In this case, since you want to color only the set bits of a mask, all with the same color, you can simply do it while creating the surface from the mask: new_surf = mew_mask.to_surface(setcolor = 'red') to obtain the same result without checking manually every pixel of the surface, and for those interested, the Mask.to_surface method has a few useful params: - surface: Surface to draw mask onto - setsurface: Use this surface color values to draw set bits - unsetsurface: Use this surface color values to draw unset bits - setcolor: Color to draw set bits - unsetcolor: Color to draw unset bits - dest: Surface destination of where to position the topleft corner of the mask being drawn Btw great video and you genuinely deserve more views
@alwaysalegend633 жыл бұрын
We want more of this kind of game Dev people
@theadventurousprogrammer64492 жыл бұрын
How do you not have millions of views... This course was amazing! If you did more content, I'd for sure buy your course.
@EpicGamerX2 жыл бұрын
Hey you haven't uploaded in a month but I just wanted to say your tutorials are perfect! Don't give up I am sure your content will be noticed, because you actually explain the code rather than have us remembering and your explanations are excellent!
@subarunatsuki19022 жыл бұрын
Yeah, he is awesome!
@marcusberge83782 жыл бұрын
Its actually scary how much bettert than every other youtuber, you are at explaining pygame problems!
@mikechavannes53572 жыл бұрын
This is one of the best videos I have seen on masks in pygame. Thank you very much for putting this together. You explained the concepts extremely well!
@umanglunia21943 жыл бұрын
47:40 - we could also enlarge the mask surface/shrink the original surface and blit with the same center, and that should work I think Great video Clear Code... You are one of my favorite youtubers :)
@ClearCode3 жыл бұрын
good idea to enlarge the surface although that would also remove holes inside the surface. Super glad you like it :)
@kyawmying22410 ай бұрын
last two min is really difficult part.Thank you so much.Your video is really great
@iammaxpetrov2 жыл бұрын
Great guide, an interesting topic very well explained. Thank you very much for this, you did an amazing job!
@sylvanfranklin69043 жыл бұрын
I really wish you got more attention, this content is not 30k- it’s 1mill at least
@doiman65913 жыл бұрын
О, спасибо тебе за видео! Смотрел у тебя The ultimate introduction to Pygame и это очень крутой видос, спасибо тебе за него И да, я знаю, что ты не говоришь по-русски, мне просто хочется написать этот комментарий на родном языке =)
@ZgavY3 жыл бұрын
Privet
@Foxtro3 жыл бұрын
lol thanks to yt translation I can read your comment
@param47223 жыл бұрын
Finally a new vid
@jimmyslaughter62623 жыл бұрын
Your tutorials are amazing!! Can you do a tutorial on dialog boxes for text based cutscenes? Like in RPG/visual novel games?
@elainemisteria83093 жыл бұрын
THANK YOU
@Kokoz402 жыл бұрын
Quick question: How did you do that at 20:16 where you wrote "offset_" on both sides?? Btw awesome videos, I really enjoy them. Very very helpful too. Especially for a self-taught like me. Keep up the great work and wish you all the best :)
@nialninyesiga-og2fq3 ай бұрын
The Cat in the begining looked like spider-mans pet
@ZimmoYT3 жыл бұрын
Great video
@SkyFly198533 жыл бұрын
Very useful.
@anthonydrakefordshadow4 ай бұрын
Hi, I have a mask question. Can masks be used for player cosmetic choices and if they can, would this remove the processing burden associated with masks if the mask was not responsible for detecting collisions at all?
@michaelhall2265 Жыл бұрын
In part 1 when you add if "pygame.sprite.spritecollide(player.sprite,obstacle,False): (rect detection)" it stops working on the left side of the a.
@dakshdubey38522 жыл бұрын
Hi Clear Code I just wanted to ask so is the whole "shape" of the mask a rectangle with 1s and 0s? By the way your vid is awesome!
@ClearCode2 жыл бұрын
yes, the whole shape is still a rectangle, and thank you :)
@dakshdubey38522 жыл бұрын
@@ClearCode Thank you so much, you helped me with my code!!!!
@big123lak10 ай бұрын
So if you take the difference of the top left points of the images before the mask , then if any coordinates of one mask added by the offset equals any point on the other mask it’s overlap after 3 hours this is only logical conclusion I can come too but if the original image has a lot of transparency and one is much smaller it still feels like it doesn’t make sense if it already knows the masks coordinates all the offset is the difference of top left which always equals so how do you calculate which coordinates are within overlap idk all I know is add the masks in overlap and the difference in coordinates
@VectorByte8 ай бұрын
I tried to make player mask collide with masks in a list problem is that the player mask only collides with first mask in the mask list
@pascalbouillon17132 жыл бұрын
How can I have Collisions between a mask and a spritegroup ( Its An Enemy and Bullets)
@mrdc33 жыл бұрын
Clear Code, In your previous videos, I asked some additional questions. Could you answer them?
@mrdc33 жыл бұрын
@@TuIipe ok cool! Question 1: how would I add scrolling to the overworld? How would I write save states? How do I make the images and where are the font for the “Level 1, Level 2, etc. and how would I assemble them?
@kelsierii47473 жыл бұрын
@@mrdc3 Im not the best person to answer these but since no one else has yet Ill try to give you some where to start. 1 I dont know if theres a better way but for scrolling I usually create a variable called scrollX, then, everytime the character is about to leave the screen, I make the character stop walking and add scrollX -speed of the character, at last, for every obejct in the game (enemies, background (it has to be long), partciles) I draw them at their true X +scrollX. 2. I havent done this one in a while but the easiest way I know is to create an empty folder somewhere and save some object with the save information to it, using the pickle library. 3. pygame has font rendering in itself, with fonts that come with pygame, but you can use others you install, Id look for a tutorial but it is rather a simple process to render text on a pygame display. Hope this helped.
@mrdc33 жыл бұрын
@@kelsierii4747 But I still dont know which scroll_x variables to put, I already have it defined in level. I could easily copy it, but for the overworld I would need to replace some variables, that is what I am confused about. I am referring to Clear Code’s mario-style platformer
@vivat-3 жыл бұрын
Bloxy, you should join the Clear Code Discord Server! It has people who can help, when you need it. Try it out: (It is in the description of this video)
@mrdc33 жыл бұрын
@@vivat- That would be a good option!Will do!
@TasteDaRDX3 жыл бұрын
Hello Christian, thanks for another excellent video. I combined the masks with your Grand Theft game to keep the car inside the track, which got buggy when the player rotates. How do I fix it? Thanks again
@Choco79411 ай бұрын
You would have to create a new mask whenever the player rotates which could be quite performance-intensive. Hope this helps
@mohammadkamran97272 жыл бұрын
hi just wanted to know how do u get/make those neat sprites that you use in ur vids can u make a vid for it thanks! (btw love ur vids ♥)
@ClearCode2 жыл бұрын
thank you :) Most of the artwork I get from opengameart.org which has a ton of free material (there is an artist called Kenney there that makes really good stuff) and I occasionally also use Adobe Photoshop and Illustrator to make some things myself
@mohammadkamran97272 жыл бұрын
@@ClearCode tysm
@maipaksana16672 жыл бұрын
Please make a tutorials of ghost game 🙏
@Cookie-mv2hg2 жыл бұрын
Hi, I was once making a game where I stopped at trying to identify if the screen is colored(other than white) per frame. I was thinking iterate through each pixels per frame but it's making game super heavy. Can this be done in pygame too?
@subarunatsuki19022 жыл бұрын
Did you find the answer?
@mohiuddinsyed16843 жыл бұрын
Why not use the walrus operator instead of calling the mask function twice to print it.
@Wall_E-Lego_Edition Жыл бұрын
Quick question: I tried implenting the sprite collision into my game, but it is really laggy. Any tips?
@ClearCode Жыл бұрын
do you mean it got slow after a mask collision? Usually a good idea is to do a sprite collision and then a mask one but if you struggle with sprite collisions something else went wrong entirely.
@Wall_E-Lego_Edition Жыл бұрын
@@ClearCode I think I meant mask collision. But don’t we have to always check for collisions when the player is walking on the tiles?
@ClearCode Жыл бұрын
oh you want to create a platformer? For the floor you would need a constant collision check but a rect based one should be fine
@mrdc33 жыл бұрын
Hi
@Mjngg029 ай бұрын
28:15
@eek93132 жыл бұрын
Excuse me☝️, can't we just make a simple application like Facebook with Pygame😅! Please Suggest me...🙏
@big123lak10 ай бұрын
Jesus Christ the offset is hard to understand the offset makes literally no sense is it just easy to remember to use the difference of the top lefts ?? Then it can calculate the overlap using the masks and difference of the toplefts