Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, Quad, VoroneTZ, 1 invisible), 623 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Using the keypad numbers #268120
05/27/09 14:01
05/27/09 14:01
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
Hello,

I have developed a small project where the player has to guess a number from 1-9.

I can enter the code using the keyboard numbers from 1 to 9 but nothing happens when pressing the numerical keypad numbers.

I have the num_lock on. Why does this not work?


I am using key_pressed and the scan code as below
///////////////////////////////////////////////////////////////////////
var answer;
var correct_answer;
answer = int(random(9)) + 1; //choose number 1-9
correct_answer=answer+1;//this is for the corresponding scancode

var guesses=3;


action check_key
{
while(guesses>0)
{
if(key_pressed(correct_answer))
{
//access granted
//trigger door open
}
else
{
//buzzer
//reduce guesses by 1
}
wait(1);
}
}
///////////////////////////////////////////////////////////////////////



Does the keypad not work as the keypad values are

1 = end
2 = cursor down
3 = page down
4 = cursor legt
5 = null
6 = cursor right
7 = home
8 = cursor up
9 = page up


would appreciate an explanation

thanks,

Rob


Re: Using the keypad numbers [Re: robertbruce] #268208
05/28/09 06:12
05/28/09 06:12

M
mercuryus
Unregistered
mercuryus
Unregistered
M



Try this small proggy to check the scancodes of the keys:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

var	gv_key;

PANEL* 	pan_info = {	
	digits 10, 20, "Keycode last pressed: %3.0f", *, 1, gv_key;
	flags = VISIBLE;	
}

void main(){	
	
	// loop till infinity (or ESC was pressed)
	while(1){
		gv_key=key_lastpressed;
		
		switch(key_lastpressed){
			case 71: 	beep(); 
					break;
			case 72: 	beep(); 
					break;			
			// ...
		}
		
		wait(1);
	}
	
}


Re: Using the keypad numbers [Re: robertbruce] #269670
06/04/09 06:10
06/04/09 06:10

M
mercuryus
Unregistered
mercuryus
Unregistered
M



Try this demo:

Code:
// author: u.seifffert / gameus!de
// date:   06.2009
// 3DGS, lite-c 7.7x
// open source
///////////////////////////////
#include <acknex.h>
#include <windows.h>
#include <default.c>
///////////////////////////////

// shows the keystate of the numberkeys and the numpad keys (if numlock is activated)
// VK_NUMPAD0, VK_NUMPAD1, ... you find declared in windows.h


var gv_keystate[10];

PANEL* pan_info = {
	digits = 20,20,"Press the number keys or the keys from the numpad (while numlock is active)", *, 0, 0;
	digits = 20,40,"key 0 %3.0f", *, 1, gv_keystate[0];	
	digits = 20,50,"key 1 %3.0f", *, 1, gv_keystate[1];
	digits = 20,60,"key 2 %3.0f", *, 1, gv_keystate[2];
	digits = 20,70,"key 3 %3.0f", *, 1, gv_keystate[3];
	digits = 20,80,"key 4 %3.0f", *, 1, gv_keystate[4];
	digits = 20,90,"key 5 %3.0f", *, 1, gv_keystate[5];
	digits = 20,100,"key 6 %3.0f", *, 1, gv_keystate[6];
	digits = 20,110,"key 7 %3.0f", *, 1, gv_keystate[7];
	digits = 20,120,"key 8 %3.0f", *, 1, gv_keystate[8];
	digits = 20,130,"key 9 %3.0f", *, 1, gv_keystate[9];
	flags=VISIBLE;
}

void main(){
	while(1){
		gv_keystate[0]=(abs(GetKeyState(VK_NUMPAD0))>1 || key_0); 
		gv_keystate[1]=(abs(GetKeyState(VK_NUMPAD1))>1 || key_1); 
		gv_keystate[2]=(abs(GetKeyState(VK_NUMPAD2))>1 || key_2); 
		gv_keystate[3]=(abs(GetKeyState(VK_NUMPAD3))>1 || key_3); 
		gv_keystate[4]=(abs(GetKeyState(VK_NUMPAD4))>1 || key_4); 
		gv_keystate[5]=(abs(GetKeyState(VK_NUMPAD5))>1 || key_5); 
		gv_keystate[6]=(abs(GetKeyState(VK_NUMPAD6))>1 || key_6); 
		gv_keystate[7]=(abs(GetKeyState(VK_NUMPAD7))>1 || key_7); 
		gv_keystate[8]=(abs(GetKeyState(VK_NUMPAD8))>1 || key_8); 
		gv_keystate[9]=(abs(GetKeyState(VK_NUMPAD9))>1 || key_9); 
		wait(1);
	}
	
}




Re: Using the keypad numbers [Re: Anonymous] #450639
04/19/15 21:10
04/19/15 21:10
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Thank you laugh


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com

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

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