Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <windows.h> // WinApi header
- void drawPixel(int x, int y, int c)
- {
- COORD coordinate;
- coordinate.X = x;
- coordinate.Y = y;
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hConsole, c);
- SetConsoleCursorPosition(hConsole, coordinate);
- printf("%c", 219);
- return;
- }
- int main()
- {
- system("mode 80, 25");
- int playerX = 5;
- int playerY = 5;
- int FPS = 30;
- while (1)
- {
- if (GetAsyncKeyState(0x25)) playerX--;
- if (GetAsyncKeyState(0x26)) playerY--;
- if (GetAsyncKeyState(0x27)) playerX++;
- if (GetAsyncKeyState(0x28)) playerY++;
- system("cls");
- drawPixel(playerX, playerY, 106);
- Sleep(1000/FPS);
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment