GetKeyState

Non-platform specific questions.

GetKeyState

Postby jazz_e_bob » Fri Oct 10, 2003 8:54 am

Can I please trouble someone for a demo of the usage of GetKeyState?

:)
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby makslane » Fri Oct 10, 2003 12:17 pm

Move a actor to left or right, when left or right keys pressed in "Draw actor" event

1) Create an actor
2) Add a "Draw actor" event
3) Add Script code

Code: Select all
char *key = GetKeyState(); //Get entire keyboard state

if(key[KEY_RIGHT] == 1) //Test if right key is pressed
{
  x = x + 5; //Move actor to right
}

if(key[KEY_LEFT] == 1) //Test if left key is pressed
{
  x = x - 5; //Move actor to left
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby jazz_e_bob » Fri Oct 10, 2003 12:21 pm

Cheers mate! 8)
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest