Help

Write your question here.



Using base
#include <iostream>
#include <string>
#include <vector>
#include <windows.h>
#include <fstream>

using namespace std;

int MAX_ROWS = 22;
int MAX_COLS = 80;

//this is a reference to cout (we got this when we changed the output color)
//we can use this to setCursorPosition
HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);


COORD PlayerPos;
void handleKeys()
{
if (GetAsyncKeyState(VK_RIGHT))
{
PlayerPos.X += 1;
}
if (GetAsyncKeyState(VK_LEFT) && PlayerPos.X > 0)
{
PlayerPos.X -= 1;
}
if (GetAsyncKeyState(VK_DOWN))
{
PlayerPos.Y += 1;
}
if (GetAsyncKeyState(VK_UP) && PlayerPos.Y > 0)
{
PlayerPos.Y -= 1;
}
}
int main()
{
while (true)
{
SetConsoleTextAttribute(output, 10);
COORD pos;
pos.Y = 24;
pos.X = 0;
SetConsoleCursorPosition(output, pos);
cout << "Running ";

SetConsoleCursorPosition(output, PlayerPos);
cout << " ";
handleKeys();

SetConsoleTextAttribute(output, 14);
SetConsoleCursorPosition(output, PlayerPos);
cout << ((char)2);

Sleep(50);
}

COORD pos;
pos.Y = 24;
pos.X = 0;
SetConsoleCursorPosition(output, pos);
system("Pause");
return 0;
}

writing the any program as simple.
Please, use code tags (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your
post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <>
formatting button.

Could you be specific on what problems are you having with your code?
Topic archived. No new replies allowed.