I have one other problem now. After reading the faq I decided to add movement to my very advance game, so I used preludes "An alternative solution to this problem is the Win32 API"
here is my code now:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <windows.h>
int main()
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon, FOREGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY);
int background[8] = { 1, 1, 1, 1, 2, 2, 2, 2 };
int screen[8] = { 1, 1, 1, 1, 2, 2, 2, 2 }; //the map array
int x,y,a,b;
int playerpos; //players position
short esc = 0; //something prelude did in the $$$ know clue
playerpos = 3; //set players starting point to the fourth element in the array
screen[playerpos] = 8; // make the hero a mighty 8 :)
for( x = 0; x < 8; x++ ) // loop to see if this works
{
printf(" %d ", screen[x]);
} //loop worked now we try to move 8
while ( !esc )
{
esc = GetAsyncKeyState ( VK_ESCAPE );
if ( GetAsyncKeyState ( VK_UP ) & SHRT_MAX )
puts ( " you cant jump yet " );
else if ( GetAsyncKeyState ( VK_DOWN ) & SHRT_MAX )
puts ( " going through the ground is cheating :) " );
else if ( GetAsyncKeyState ( VK_LEFT ) & SHRT_MAX )
screen[playerpos] = background[playerpos]; //copy the correct number to the array
y = playerpos; //copy playerpos to a variable
playerpos = y - 1; // move playerpos to the left
screen[playerpos] = 8; //shape shifting isnt allowed
printf("\n"); //new line to compare
for( a = 0; a < 8; a++ ) //the new loop begins
{
printf(" %d ", screen[a]);
} //new loop ends
else if ( GetAsyncKeyState ( VK_RIGHT ) & SHRT_MAX )
screen[playerpos] = background[playerpos]; //copy the correct number to the array
y = playerpos; //copy playerpos to a variable
playerpos = y - 1; // move playerpos to the left
screen[playerpos] = 8; //shape shifting isnt allowed
printf("\n"); //new line to compare
for( a = 0; a < 8; a++ ) //the new loop begins
{
printf(" %d ", screen[a]);
} //new loop ends
}
return EXIT_SUCCESS;
}
Thanks again to all who apply it gives me a parse error before the 2nd to the last else if or line 49.