daaball.blogg.se

Pygame checkbox
Pygame checkbox








pygame checkbox

When creating rectangles we will take a two step approach. There is a lot more that can be done with all of these so if you get the urge to delve deeper I would recommend investigating PyGame Draw. The methods we will look at here we will only cover in an introductory manner. There is a library called gfxdraw which gives you more control over your drawing but it's a bit more involved so we won't cover it here in this introductory tutorial. Shapes are pretty easy so let's start with those. This makes it easier to tinker with colours later on (which is very common when you're polishing your game and trying to get things just right).

pygame checkbox

In the sample code above we have saved the colour into a variable but it is possible to use the colour directly within a function call for a shape or text if you want.Įven though we can use the colour directly it is best practice to save all your colours into variables at the top of the script and then just to use the variables. It is possible to create about 16.5 million colours which should be plenty for anyone. # What do you think this colour might be?.We set three values (each between 0 and 255) which represent the amount of RED, GREEN and BLUE in the colour. It's how we set the background colour for the window. You've already seen this format in the basic template. We will stick to the easiest method for this tutorial but be aware that there are others. There are a few ways in which we can do this.

pygame checkbox

When creating text and shapes (and a few other things) we need to define their colour.










Pygame checkbox