Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, VoroneTZ, 1 invisible), 1,578 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pausing program until a key is struck #309930
02/11/10 23:30
02/11/10 23:30
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
I am sure I am missing something obvious:
I an using Lite-C Commerical 7.8
I need the program to do nothing until any key is pressed.
I have tried:
while(key_any == 0){wait(1);}
but the program just continues. Leaving out
the "wait" causes a crash. this is part o0f the introduction
to a Reaction Time program so it is important
to me. Help is greatly apprciated. Please give me a subject heading if this is in the manual. Thank you in advance.


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet
Re: Pausing program until a key is struck [Re: carlpa] #309932
02/11/10 23:37
02/11/10 23:37
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
You can look for freeze_mode in the manual:
Code:
function pause()
{ 
	if(freeze_mode == 2) // all frozen??
	{
		freeze_mode = 0; // go on
	}
	else
	{
		freeze_mode = 2; // pause everything
	}
}



But you should rather think about how your game runs.
In case you dont want to stop everything.

You could for example set a variable (for example "myPause")
that holds all your function you want to suspent.

you could indert

while(myPause==1){wait(1);}

in any while loop of actions or other functions,
to stop them while the variable is set.

----

wait is an instruction, stat stops a function for x frames.
So if you have a while-loop that is running continiously,
you need a wait in there, else the function
will block the game (as it takes up all the time, not waiting
for others)

Inserting a wait is a bit like opening a different "Thread".
You can let functions run in paralel then.
They process as long as they dont return or pause when
reaching a wait command.

Re: Pausing program until a key is struck [Re: Damocles_] #309934
02/12/10 00:00
02/12/10 00:00
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
Thank you. Actually, I want everything to stop to allow the subject to read the instructions. However, a single key press should allow the next set of instructions, etc., until the test begins. Nothing is running during the presentation of instructions. This will be used in cognitive testing of neurological patients.

Namely does freeze_mode =2 allow for recognizing a key press?


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet
Re: Pausing program until a key is struck [Re: carlpa] #309935
02/12/10 00:07
02/12/10 00:07
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
What about? (pseudo-code)

function resume
{
if(freeze_mode == 2) {freeze_mode =0;}
}

function show instructions
{
on_anykey = resume;
INSTRUCTIONS.....
freeze_mode = 2;
etc..
All instructions seen
on_anykey = NULL;
}


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet
Re: Pausing program until a key is struck [Re: carlpa] #309936
02/12/10 00:16
02/12/10 00:16
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
Does not work. freeze_mode = 2 seems to disable the keyboard.

Help


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet
Re: Pausing program until a key is struck [Re: carlpa] #309937
02/12/10 00:29
02/12/10 00:29
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
Think I got it. Thanks


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet

Gamestudio download | chip programmers | 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