ok in about fifteen minutes i have been able to come up with this code does anybody have any suggestions on how i should put in the cases for where to move
Code:
#include "stdafx.h"
int winarray[20][12];
int move(int where);
enum
{
KEY_ESC = 27,
ARROW_UP = 256 + 72,
ARROW_DOWN = 256 + 80,
ARROW_LEFT = 256 + 75,
ARROW_RIGHT = 256 + 77
};
static int get_code ( void )
{
int ch = getch();
if ( ch == 0 || ch == 224 )
ch = 256 + getch();
return ch;
}
int main(int argc, char* argv[])
{
char ch;
int count,count2,mover;
for(count=0;count<20;count++)
winarray[count][0]=1;
for(count=0;count<12;count++){
winarray[1][count]=1;
winarray[20][count]=1;
}
mover=2;
winarray[1][1]=mover;
winarray[1][2]=mover;
winarray[2][1]=mover;
winarray[2][2]=mover;
for(count=0;count<20;count++){
if(count<12){
switch(winarray[count][count]){
case 0:{
printf(" ");
break;
}
case 1:{
printf(".");
break;
}
case 2:{
printf("[]");
}
}
}
if(count<=20){
switch(winarray[count][12]){
case 0:{
printf(" ");
break;
}
case 1:{
printf(".");
}
case 2:{
printf("[]");
}
}
if(count==20){
printf("\n");
}
}
while ( ( ch = get_code() ) != KEY_ESC ) {
switch ( ch ) {
case ARROW_UP:{
move(1);
break;
}
case ARROW_DOWN:{
move(2);
break;
}
case ARROW_LEFT{
move(3);
break;
}
case ARROW_RIGHT{
move(4);
break;
}
}
return 0;
}
int move(int where){
switch(where){
case 1:{} /*move up*/
case 2:{} /*move down*/
case 3:{} /*move left*/
case 4:{} /*move right*/
}
return 0;
}