Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
using a back/pause options #296724
11/02/09 16:29
11/02/09 16:29
Joined: Sep 2009
Posts: 22
Boca Raton, Florida
M
MarcsVision Offline OP
Newbie
MarcsVision  Offline OP
Newbie
M

Joined: Sep 2009
Posts: 22
Boca Raton, Florida
i would like to have a key that pauses the game and brings up a panel. my problem is not bringing up the panel when i hit the key, i dont know how to make the panel go away when i hit the key again.

can someone explain how to make panels or functions turn on and off with the stroke of a key.

Thanks Alot!

Re: using a back/pause options [Re: MarcsVision] #296728
11/02/09 16:44
11/02/09 16:44
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
You can use a variable that holds the state of the game...
Code:
var game_paused = 0;



So when you press 'pause' you can check this variable and act accordingly...
Code:
function PausePressed()
{
if(game_paused == 0) // game not paused
{
// show pause menu
set(pnl_pause_menu,SHOW);
game_paused = 1;
}
else // game already paused
{
// hide pause menu 
reset(pnl_pause_menu,SHOW);
game_paused = 0;
}
}



Re: using a back/pause options [Re: DJBMASTER] #296731
11/02/09 16:53
11/02/09 16:53
Joined: Sep 2009
Posts: 22
Boca Raton, Florida
M
MarcsVision Offline OP
Newbie
MarcsVision  Offline OP
Newbie
M

Joined: Sep 2009
Posts: 22
Boca Raton, Florida
Thanks alot, i will see if it works for me and let you know how it turns out.

Re: using a back/pause options [Re: DJBMASTER] #296749
11/02/09 18:25
11/02/09 18:25
Joined: Sep 2009
Posts: 22
Boca Raton, Florida
M
MarcsVision Offline OP
Newbie
MarcsVision  Offline OP
Newbie
M

Joined: Sep 2009
Posts: 22
Boca Raton, Florida
i might be a little confused. how do i call this pressed function?

where do i place "if (Key_P)" to make the function be called once the P key is hit and off again when pressed a second time?

thanks again

Re: using a back/pause options [Re: MarcsVision] #296785
11/02/09 22:42
11/02/09 22:42
Joined: Sep 2009
Posts: 22
Boca Raton, Florida
M
MarcsVision Offline OP
Newbie
MarcsVision  Offline OP
Newbie
M

Joined: Sep 2009
Posts: 22
Boca Raton, Florida
I wrote the scirpt as told and it runs with no syntak errors. but the game doesnt pause nor does my menu panel show when i hit the space bar. this is what i have in my scirpt:

var game_paused = 0;

function press_paused ()
{
if (key_space) {game_paused = 0;}
if (game_paused == 0)//game not paused
{
set(menu_pan, SHOW);//show menu panel
game_paused = 1;
}
else //game paused
{
reset(menu_pan, SHOW);//hide menu panel
game_paused = 0;
}
wait (1);
}

What am I doing Wrong?

Thanks

Re: using a back/pause options [Re: MarcsVision] #296806
11/03/09 05:41
11/03/09 05:41
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
hi, you have put the key call to 'press_paused' inside 'press_paused' so it can't start, lol. Functions can't start themselves, they have to be called from another function.

You can use the main function to do this. You also don't need the wait(1);.
Code:
var game_paused = 0;

function press_paused ()
{
if (game_paused == 0)//game not paused
{
set(menu_pan, SHOW);//show menu panel
game_paused = 1;
}
else //game paused
{
reset(menu_pan, SHOW);//hide menu panel
game_paused = 0;
}
}

void main() // first function that is run when game loads
{
on_space = press_paused; // set space key to use press_paused.
}



Re: using a back/pause options [Re: DJBMASTER] #296883
11/03/09 17:34
11/03/09 17:34
Joined: Sep 2009
Posts: 22
Boca Raton, Florida
M
MarcsVision Offline OP
Newbie
MarcsVision  Offline OP
Newbie
M

Joined: Sep 2009
Posts: 22
Boca Raton, Florida
thanks alot for all your help DJBMASTER, im very new to Lite-C. In fact this is the first programming I ever did. the code work perfectly. and im sure i will have alot more questions as I continue to learn, lol.

Thanks Again.

-Marc

Re: using a back/pause options [Re: MarcsVision] #296981
11/04/09 06:11
11/04/09 06:11
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
no problem. Did you complete the Lite-c Workshops? If so, then you could try going through the AUMs. That will get you really familiar with the engine.

Re: using a back/pause options [Re: DJBMASTER] #296990
11/04/09 08:51
11/04/09 08:51
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Code:
function press_paused ()
{
toggle(menu_pan, SHOW);//hide menu panel
}

void main() // first function that is run when game loads
{
on_space = press_paused; // set space key to use press_paused.
}



this is a hell of a lot easier! look up Macro's in the manual laugh

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: using a back/pause options [Re: Helghast] #296995
11/04/09 09:48
11/04/09 09:48
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
or

Code:
function on_space_event()
{
	while (key_space){wait (1);}
	
	toggle(menu_pan, SHOW);
}




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1