this is a very interesting and usefull bit of code actually...
at the start of your draw script you need to write..
- Code: Select all
char* key = GetKeyState();
then in order to see if a key is pressed use...
- Code: Select all
if(key[KEY_LEFT]==1)
{
xpeed-=2;
}
if(key[KEY_RIGHT]==1)
{
xpeed+=2;
}
then to set the speed back to 0 use...
- Code: Select all
if(key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
{
xpeed=0;
}
this is how its done
if you want to get a keyboard key, you need to use [KEY_w] lower case keys instead of capitals, you can find all of them in the game-editor documentation.
(go to help then documentation)
to restrict these to if its NOT jumping you need to use a jumping variable.. or if jump is 0 for example. (if jump is 0 the player cant jump so is probably jumping)
so..
- Code: Select all
if(jump!=0)
{
//codes here
}
the use of != makes it say.. if jump is not equal to 0.
savvy
(+1 if this helps)