getKeyText Issue

Game Editor comments and discussion.

getKeyText Issue

Postby RobH » Thu Jan 05, 2006 7:54 pm

I am trying to code a feedback which evaluates the keyboard input. I have searched the forums and the tutorial and have made it nearly work, but am now stumped.

This is supposed to play a cheering sound if you press A and an oops sound if you press any other key. I can only get oops to run. I pirated code from the turorial and created a txtguy actor to see what the return data looks like and the key names appear on screen as expected.

I am new to C and am guessing this is a data type issue. Thanks for any help!

Rob

The code is:
Code: Select all
int keyCode = getLastKey();

if(getKeyText(keyCode) == "A"){
PlaySound2("data/cheer.wav", 1.000000, 1, 0.000000);
           }
else{
PlaySound2("data/oops.wav", 1.000000, 1, 0.000000);
    }


strcpy(textguy.text, getKeyText(keyCode));
RobH
 
Posts: 2
Joined: Wed Jan 04, 2006 2:51 am
Score: 0 Give a positive score

Postby makslane » Thu Jan 05, 2006 8:07 pm

You can use getLastKey to test without use getKeyText:

Code: Select all
if(getLastKey() == KEY_a)
{
   //Your code here
}


If you need test the string, use the strcmp function:

Code: Select all
if(strcmp(getKeyText(keyCode), "A") == 0)
{
   //Your code here
}
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

getKeyText Issue

Postby RobH » Thu Jan 05, 2006 9:20 pm

Excellent - thanks for the help!
RobH
 
Posts: 2
Joined: Wed Jan 04, 2006 2:51 am
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest