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
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,055 guests, and 7 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
How to set "Ignore_Key_Repeat"? #214928
07/08/08 09:34
07/08/08 09:34
Joined: Jun 2008
Posts: 91
C
Coisox Offline OP
Junior Member
Coisox  Offline OP
Junior Member
C

Joined: Jun 2008
Posts: 91
Lets say I make a sport game, 100 meters hurdle. If player tapping the keyboard faster, the character in the game will run faster. If the player holding the keyboard, it will be counted as single press.

This is my best solution but too much of work:

Code:
var a_been_pressed = false;
var b_been_pressed = false;

function handle_key_a()
{
	a_been_pressed = true;
	while (key_a) wait(1);
	addPlayerSpeed();
	a_been_pressed = false;
}

function handle_key_b()
{
	b_been_pressed = true;
	while (key_b) wait(1);
	addPlayerStamina();
	b_been_pressed = false;
}

while (game_running)
{
	if (key_a && !a_been_pressed) handle_key_a();
	if (key_b && !b_been_pressed) handle_key_b();
	wait(1);
}

Or any better solution?

Re: How to set "Ignore_Key_Repeat"? [Re: Coisox] #214931
07/08/08 09:39
07/08/08 09:39
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
it's not too much work... this will work fine. i had even larger code for taping keys and it worked just fine so as will this code...



Ubi bene, ibi Patria.
Re: How to set "Ignore_Key_Repeat"? [Re: croman] #214932
07/08/08 09:46
07/08/08 09:46
Joined: Jun 2008
Posts: 91
C
Coisox Offline OP
Junior Member
Coisox  Offline OP
Junior Member
C

Joined: Jun 2008
Posts: 91
Oh really... In OpenGL, we have the IGNORE_KEY_REPEAT function. Simply call this function and everything is ok.

I haven't try yet but I think we can <include opengl.h> and just call this function. What do you think? Will it works? Will it brings any conflict with the game engine in future? Or will it makes our compiled .exe much bigger?


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