![]() ![]() But feel free to look around if you want it has most of the basic framework. The repo is quite behind from the current implementation have been meaning to push the recent changes to it for awhile now. Here is the code from one of the games I have been working on that demonstrates it. Have to give a shout out to the SFML book for the state management design (And pretty much the whole framework design). To manage it all I stick them into a Stack. I then create a new class for each of the states that define whatever they need to do. It basically just provides the functionality for changing from one state to the other and some other basic things that each of them needs like the update function, draw function, and event handling. Basically I will have a base state class that each different state inheirits from. I kind of go a different route for handling these. Thats correct basically the global state of the game (IE Titlescreen, menu screen, level 1, level 2, ect). The program flow is determined by the function pointer assignments made in the INIT and Delete functions. A function pointer for each of these is used to ensure that the appropriate function for the current state is being called. There are INIT, Delete, Event, Logic and Draw functions for level play, and for each menu in the game. being at a menu, then I use function pointers for this. If you mean whether a level is in play vs. Wanted to make a UI with sliders and stuff for it but just opted for a console instead since it seemed a bit easier.īut will definitely have to add in the step through frame by frame (Or even a few frames at a time) since I can definitely see where that would come in handy.Ģ) I'm not sure what you mean by 'state management'. Then I just added in a in game console window that I can bring up with '~' to test more in depth things like adjusting enemy hit points and speed or spawning a certain group of enemies. I have a few shortcut keys for certain things like turning on and off bounding boxes, getting a certain upgrade or ship, ect. A couple of bool variables control calls to the gameLogic() function, with the key commands 'p' (play/pause) or 's' (step) I find it useful to grant invincibility to the player (disable collision testing against weapons), so I can test without struggling to survive.įinally, it's nice to be able to pause animation and step through it frame by frame to examine details. Getting it to work just right has been a little tricky. I use a key command to automate testing this feature. One is hack bomb, which "hacks" all enemies within its blast radius so they are turned and fight on the players side. Just hit the level number at the start screen. I also enable a shortcut to the level I want to test. This makes testing the various weapon levels difficult, so I enable key 'u' to upgrade, and 'd' to downgrade the current weapon. ![]() In a game I'm currently working on the player has 8 weapons for which upgrades are purchased in an upgrade menu between levels. It's easy to add code for this in the EventHandler() function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |