Skip to content

PF: dev_0.0.2, Egg Selection

Boy this was sure a brain buster of an addition for sure.

As seen in the last dev blog, the egg selection screen was quite lackluster. Actually, all it even had was the eggs and a simple text box saying what egg you chose (and not even the name of the egg, just the number in the list.) I wanted to change that, so I took to work implementing a new info screen that showed the description of the eggs and their sprite just above it.

First I would like to say that for now and until I have a good base for the game to run on, I will only be implementing three eggs: red, blue, and rainbow. I will still implement all of the other egg colors, but for now I want to focus on making the rest of the game without having to stress over making 9 characters.

Now that that’s out of the way, the fun stuff!

(Sorry for the glitched colors, the gif program did that to it.) …and here it is! Let me say, figuring out how to get text to wrap around like that in pygame was tough. Pygame’s internal text rendering engine doesn’t recognize line break characters (\n) so I had to improvise.

Pygame has a function built in for all of it’s font objects called size, which means that I can give this function a string that I want to know the size of on the screen with a given font, and pygame will give me the height and width in pixels for that text were it to be rendered. I used this to check the size of a line of text by adding a character one by one; once it got too long, I cut the string. I made sure that I cut the string on characters such as spaces, periods, commas, and other punctuation so that a word will not be cut in half.

It’s a fairly beefy class at 100 lines, (though many of them are comments,) so if you want to check it out for yourself I have the source code for the whole game on GitHub.

I also added a few more folders to the file structure since last time.

│   └───egg_info
│           blue.json
│           rainbow.json
│           red.json
    │   ...
    │       down_arrow.png
    │       up_arrow.png

There are now a new couple of folders in the resources folder: egg_info and gui. egg_info is where all of the different attributes of the eggs are going to be stored such as their descriptions, their playfulness, and other factors that I will add later on. gui is where I will keep all of the files used for the gui.

Other than that, that’s it for this development blog! I realized that this blog is being posted on a Saturday, just like the last one, so why don’t we make these blogs a regular Saturday thing? (For me it’s actually 1AM Saturday but the day still counts for me.) These blogs really do help me recap how far I’ve gotten, and where I still need to go. Thank you for reading, and I’ll see you next week!


Leave a Reply

Your email address will not be published. Required fields are marked *