Code for arrow keys
RUSES :: Part 1 :: Programming :: Coursework
Page 1 of 1
Code for arrow keys
This may be useful for people who are going to have a go at the maze game. It's pretty self explanatory
Source
http://www.gamedev.net/topic/589120-basic-maze-game-c/
Source
http://www.gamedev.net/topic/589120-basic-maze-game-c/
- Code:
#include <iostream>
#include <conio.h>
/* Key ASCII chars */
#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_LEFT 75
#define KEY_RIGHT 77
int main()
{
char input = 0;
/* Keep checking for input untill we press ESC */
while (input != 27) {
/* Store userinput in our input variable */
input = getch();
/* Check for arrow key presses */
switch (input) {
case KEY_UP:
printf("You've pressed KEY UP!\n");
break;
case KEY_DOWN:
printf("You've pressed KEY DOWN!\n");
break;
case KEY_LEFT:
printf("You've pressed KEY LEFT!\n");
break;
case KEY_RIGHT:
printf("You've pressed KEY RIGHT!\n");
break;
}
}}
lee- Posts : 22
Join date : 2012-02-23
Similar topics
» How to insert code into a forum post
» Programming Challenge #4 - Code Obfuscation
» All topics must identify which language the code problem is in
» All topics must identify which language the code problem is in
» Programming Challenge #4 - Code Obfuscation
» All topics must identify which language the code problem is in
» All topics must identify which language the code problem is in
RUSES :: Part 1 :: Programming :: Coursework
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum