Jump to content
  • Advertisement
Sign in to follow this  
jamesss

Switching between GameStates And Stop Rendering?

This topic is 3787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all , have a problem when i switch between game states. the problem is if player lost the game, we tell the gamestate manager game over so go to MenuState. but when i enter game again The player is still lost the game. how should i disable this? if(playerlost){ GameManager->SetState=GameManager->GAMESTATE_MENU; } if(GetInput->MouseDown(0)){ GameManager->SetState=GameManager->GAMESTATE_GAME; }

Share this post


Link to post
Share on other sites
Advertisement
Let me see if I understand your problem...
A player looses, the game goes to the menu state. The player then starts a new game, but the game is in the same "lost" position as before the menu was entered.

If so, what you'll need is some sort of initialization step between exiting the menu and starting the game. This could be done as a function that you call before changing to the game state, or as a third "initialize" state which the menu state goes. That state initializes the game and then proceeds onto the game state.

Share this post


Link to post
Share on other sites
Quote:
Original post by jamesss
hi all , have a problem when i switch between game states.
the problem is if player lost the game, we tell the gamestate
manager game over so go to MenuState. but when i enter game again
The player is still lost the game. how should i disable this?


if(playerlost){
GameManager->SetState=GameManager->GAMESTATE_MENU;
}

if(GetInput->MouseDown(0)){
GameManager->SetState=GameManager->GAMESTATE_GAME;
}
An obvious solution would be to clear the 'player lost' flag at some point, such as when switching from the 'main menu' state to the 'game' state.

A perhaps better solution (but one that might require significant alterations to your design) would be to take an object-oriented approach. That is, when the player selects 'new game' from the main menu (or whatever), a completely new 'game' object is created with a fresh, new state.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!