Page 1 of 1

Quality Editing 1 : Pause game

PostPosted: Wed May 05, 2010 1:06 am
by Maxeditor
Hello all

I think the Game Editor has a lot of potential, I'm actually working on a platform shooter and it's gonna be awesome !

My problem comes to do those things that are so simple in C, but seems surprisingly complicated in GE.

I guess it's because the commands and libraries are different from a standard C program.

I'd really like if somebody can lighten me on the following things

- When the player loses a life in my game, he's pulled back to a memory actor ( last checkpoint). But the transition is either instantaneous ( move screen to location real fast) or
the player sees the screen moving backward. I would like to stop the game to show messages like "you died" or some crap and have the player pull ENTER to respawn. I
tried using the PauseGame() fonction but I can't find a way to disable pause by pressing a defined key. In regular C, I would've done something like this :

pausegameon();
char in;
int out;
do
{
scanf("%c",&in);
out = in; // this should transfer the char in the ASCI equivalent code
}
while(out != 13) // i'm not sure which ASCI code ENTER is... but you get the picture
pausegameoff();

but this seems impossible, there must be another way in GE to identify ASCI codes. I saw sscanf() in the fonctions, I guess it should work the same way I showed here.

So anyway, I'll keep it to this, if anybody can post a loop that works to pause game until a specific key is pushed, it would be greatly
apreciated thank you all.

Oh and here's here's a peak at my game

Re: Quality Editing 1 : Pause game

PostPosted: Wed May 05, 2010 2:11 am
by makslane
The PauseGameOn() function pauses the game but keep receiving keyboard and mouse events.
You can do something like:

1) When the user wants to pause a game, Create your "pauseActor"

2) On the Create Actor Event of the pauseActor add a Script Editor Action with the following code:

PauseGameOn();

3) On Key Down event of the pauseActor, add a Script Editor action with the following code:

PauseGameOff();
DestroyActor("Event Actor");

Re: Quality Editing 1 : Pause game

PostPosted: Wed May 05, 2010 8:00 pm
by Maxeditor
Tx for advice,

using a pause actor is a great idea. I didn't actually use the PausegameOn() fonction after all.

Instead, i did a CreateActor event for the pause actor that disables the events I want to stop with EventDisable so this way I can play a background music and still have
some events working. then a KeyDown event like you said to restart with a new life from last checkpoint. It works pretty good, I think I'll use
such pause actors more often. It's alot simplier than trying to code it directly.

If I want to put story lines into this or something, I think it's a great way to do so !

Tx makslane

Re: Quality Editing 1 : Pause game

PostPosted: Wed May 05, 2010 8:22 pm
by DST
Using objects or classes as functions is a great idea. Not only can it help keeps all the relevant code together, but it allows you to manage algorithms more sensibly.

Most of use do it in small ways all the time, but few of us actually think in this way.

Consider how you may have an event to handle, say, a boss level, and you make all these checks to tell the game what to do differently in a boss level than a normal level. But that means that during the normal level, it's checking to see if its a boss level all the time. And the code is all scrambled together.

However, by making the level itself into an actor, and creating and destroying that actor....and then having a bosslevel actor that inherits events from normal level actor, you will be working on any given level with a collection of code that pertains to ONLY that level. Redundant questions aren't asked because the answers are implied in the CreateActor of that object.

And what's even better, is that you can develop routines for handling things. Instead of twenty if statements to end a level or menu depending on the current state of variables, you can have one method, by which all levels end. You don't have to go chase down other variables in other scripts, because they're all inside that actor. The actor dies, the level is done. End of story. You create the actor, it creates the level. No more need to reload the game each time the player restarts a level.

Making functions into actors is not something that we normally see. It's not the way most of us think.

But it's a great idea.


Max, i think your pause method is a great idea. By shutting down variables, you can have ingame pause menus and other things, and by having a actor to control that (instead of just script), you can keep tight control over it.......The key is that it's planned early on in the game. Most things become much simpler to implement if you plan them early on.

Another area that most of us could use a lesson or two in. :P