Crystal Space
Welcome, Guest. Please login or register.
July 24, 2014, 04:48:06 pm

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8228 Members
Latest Member: Leandes
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  Game States in CS.
« previous next »
Pages: [1] Print
Author Topic: Game States in CS.  (Read 3006 times)
lib.lib
Guest


Email
« on: April 03, 2006, 01:38:13 pm »

How do you handle game states in CS ?? I tried to think about something but i failed.
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: April 03, 2006, 01:42:12 pm »

How do you handle game states in CS ?? I tried to think about something but i failed.

Crystal Space is a 3D engine and as such is not aware of game states (and shouldn't be).

Exactly what do you mean by 'game states'? What do you want to do exactly?

Greetings,
Logged
lib.lib
Guest


Email
« Reply #2 on: April 03, 2006, 02:55:22 pm »

This is more design pattern question than CS question. I just wonted to know how people handle game states using CS. For example "Main Menu"  "Actual Game"  "Or different game inside game Tongue "   

Just so i can build this things separatelly and then use in a game as a one.


Imagine two classes with different keyboard input even response. And i just want to switch betwen them without eny problem.
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: April 03, 2006, 02:58:11 pm »

This is more design pattern question than CS question. I just wonted to know how people handle game states using CS. For example "Main Menu"  "Actual Game"  "Or different game inside game Tongue "   

Just so i can build this things separatelly and then use in a game as a one.


Imagine two classes with different keyboard input even response. And i just want to switch betwen them without eny problem.

I generally use a Screen or State class in which I have functions for handling events and updating screen. Then in the main event handler I delegate the events to the active screen.

Greetings,
Logged
lib.lib
Guest


Email
« Reply #4 on: April 03, 2006, 03:27:50 pm »

Delegate. You means something like.

State class inherits from csBaseEventHandler. State got it's own HandleEvent member which calls HandleEvent of currently active state classes ?

In this case it is possible to build game states tree. And on top of it one StateManager that handles updating screen and else things that have to be done once per game cycle.
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #5 on: April 03, 2006, 03:31:49 pm »

Delegate. You means something like.

State class inherits from csBaseEventHandler. State got it's own HandleEvent member which calls HandleEvent of currently active state classes ?

In this case it is possible to build game states tree. And on top of it one StateManager that handles updating screen and else things that have to be done once per game cycle.

Yes, something like that although I didn't let it inherit from csBaseEventHandler as I think that is a bit overkill.

Greetings,
Logged
lib.lib
Guest


Email
« Reply #6 on: April 03, 2006, 04:00:41 pm »

How can i delegate HandleEvent and in the same time resolve this event in current class ??
In case class inherits from csBaseEventHandler.( why this is overkill  is it going to slow down my app significantly ? )?

bool HandleEvent (iEvent &event)
{
//here saend this event for every active state class

//-----------------------

//can i do it like this ??
       csBaseEventHandler::HandleEvent

}
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #7 on: April 03, 2006, 04:03:03 pm »

How can i delegate HandleEvent and in the same time resolve this event in current class ??
In case class inherits from csBaseEventHandler.( why this is overkill  is it going to slow down my app significantly ? )?

bool HandleEvent (iEvent &event)
{
//here saend this event for every active state class

//-----------------------

//can i do it like this ??
       csBaseEventHandler::HandleEvent

}

Um? I don't understand your question. You just handle events in your main application class (which inherits from csBaseEventHandler) and then in that handler you delegate the event to your current state (state->HandleEvent (event)).

Greetings,
Logged
lib.lib
Guest


Email
« Reply #8 on: April 03, 2006, 04:09:02 pm »

But in my case one state can contain other states. I wont to resolve this event for this state and delegate event further.

For example OnKeyboard for this state when "esc" is pressed returns to previous state, and in the same time in different active state "esc" is painting picture on the screen.
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #9 on: April 03, 2006, 10:01:36 pm »

But in my case one state can contain other states. I wont to resolve this event for this state and delegate event further.

For example OnKeyboard for this state when "esc" is pressed returns to previous state, and in the same time in different active state "esc" is painting picture on the screen.

Yes, that's normal. I suppose that the keyboard event handler function in the specific state will have to do its specific thing.

Greetings,
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.144 seconds with 14 queries.