It took A LOT of work, but I finally got everything working!
- I added a title and game over page. It took white a while to figure out, but I ended up being able to do it with many changes. First I made a scene manager, which lets me have multiple different scenes as classes, allow scenes to change to other scenes, and generally have much cleaner code. I made a scene manager class that stores a current scene. It has a method
go_towhich changes that scene variable and runs certain scene methods (more on that later). I then made aSceneclass with several methods:handle_events,update,render,on_enter, andon_exit. Theon_entermethod runs after the scene is switched ingo_to, and theon_exitmethod before. I run theupdate,handle_events, andrendermethods in the main game loop from on the current scene of the manager:
self.manager.scene.handle_events(pg.event.get())
self.manager.scene.update(self.dt)
self.manager.scene.render()
- This ultimately leads to me being able to have the title page (class
TitleScene) and the game over screen (GameOverScene). - I also started using a GUI library. When I made the
TitleScene, I realized that I wanted it to have a button to play the game. At first I wanted to implement my own button but then I gave up because it would’ve been WAY too much work for a project that would use one or two. Thus, I foundpygame_guilibrary. It made UI creation relatively easier. The hardest part was figuring out the theming specifications, as it uses this custom JSON file format. At the end I was able to figure it out, but it was kind of weird and the documentation wasn’t much help. I was able to get a score display working by making a label and then updating the label when it changed. - Other changes: I made the background of the main game
cornfowerblueto test the score display; pipes are drawn underneath the floor to make it look like they are coming out; I am using a public domain font from Open Game Art but I might change it.
The hard work is paying off!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.