   Less Glitchy Code
  I'm currently working on a 2D game in Dev-C++, and have made a basic structure for it. The only problem is that I'm using system("cls"); which is causing the text to blink, making it look glitchy.Is there any way that would be better then what i have right now? (Any comments appreciated.)#include <iostream>#include <windows.h>using namespace std;const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);int main() { int a, b, x, y, h, k, points;    x = 1;    y = 1;    h = 15;    k = 8;    a = 35;    b = 10;    points = 1;    while(1){   Sleep(4);if(GetAsyncKeyState(VK_DOWN)&1){ y++; if(x == h && y == k) { points++;  } }    else if(GetAsyncKeyState(VK_UP)&1){ y--; if(x == h && y == k) { points++;  } }    else if(GetAsyncKeyState(VK_RIGHT)&1){ x++; if(x == h && y == k) { points++;  } }    else if(GetAsyncKeyState(VK_LEFT)&1){ x--; if(x == h && y == k) { points++;  } }COORD life = { h, k };COORD position = { x, y };COORD winner = { a, b }; if(points == 2){ SetConsoleCursorPosition(hConsole, winner); SetConsoleTextAttribute(hConsole, 3); cout << "Winner!"; Sleep(3000); points--; }  system("CLS"); // Problem is right here i believe SetConsoleCursorPosition(hConsole, position); SetConsoleTextAttribute(hConsole, 6); cout << char(2);SetConsoleCursorPosition(hConsole, life);SetConsoleTextAttribute(hConsole, 4);cout << "0"; }}Thanks in advance,Crypt   
  'system' asks Windows to *start up an entirely different program* which happens to simply clear the screen and then shut down.Try just writing a space to the old player's location, and then putting the player symbol at the new location. (You'll want to redraw the target each time, so that it doesn't "disappear" after you hit it the first time.)Also, as points of code cleanliness:- Try to indent your code more consistently.- Why not start points at 0 instead of 1?- *Initialize* variables, and give them more meaningful names where possible. Also, mark constant values as const.- You can do the scoring check unconditionally.- We can make a function to draw stuff.#include <iostream>#include <windows.h>using namespace std;template <typename T>void textAt(int x, int y, int colour, T output) {    // The rest of our code doesn't need the handle, but we do want to reuse    // the handle for each call to this function, so we make it "static"    static const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);    // otherwise it would be re-created on each call.    COORD position = {x, y};    SetConsoleCursorPosition(hConsole, position);    SetConsoleTextAttribute(hConsole, colour);    cout << output;}int main() { int player_x = 1;    int player_y = 1;    const int target_x = 15;    const int target_y = 8;    const int message_x = 35;    const int message_y = 10;   int score = 0;    while(1) {   Sleep(4);   textAt(player_x, player_y, 0, ' '); // erase the symbol   // figure out where the player now is   if (GetAsyncKeyState(VK_DOWN) & 1) { player_y++; }   else if (GetAsyncKeyState(VK_UP) & 1) { player_y--; }   else if (GetAsyncKeyState(VK_RIGHT) & 1) { player_x++; }   else if (GetAsyncKeyState(VK_LEFT) & 1) { player_x--; }   // redraw the player (at new position) and target   textAt(player_x, player_y, 6, char(2));   textAt(target_x, target_y, 4, "0");   // handle victory condition   if (player_x == target_x && player_y == target_y) {  score++;   }   if (score == 1) {  textAt(message_x, message_y, 3, "Winner!");  Sleep(3000);  score = 0; // makes more sense to reset rather than subtract;   // otherwise, why *count*?   }    }};  Wow thanks for that reply. It'll help a ton.One thing i did change was:if (GetAsyncKeyState(VK_DOWN) & 1) {textAt(player_x, player_y, 0, ' '); /*Doesn't Erase until you actually move (A little glitchy before)*/    player_y++; }I really don't call functions too much either, so I'm glad you included it because i need to start using them more.- idk why my starting points were 1, but thanks for pointing that out.- I will also try to give more meaningful variables within the code (& keep it more organized too)Thanks again for the great code. ( A lot shorter :P)I'll build a more 'fun' game off of this simple structure. (A simple RPG or something.)Thanks,Crypt   