that works... but it is all skippy and stuff... try it and youll see
Code:
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
using namespace std;
void topframe (int,int,int,int);
void gotoxy(int,int);
int main()
{
HANDLE h;
h = GetStdHandle ( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE );
int x = 0; //Horizontil coordinates
int y = 0; //Vertical coordinates
int whereToGo;
while (whereToGo != 27)
{
topframe(1,1,77,3);
cout << "\n\n";
for (int i = 0; i < y; i++)
{
cout << "\n";
}
for (int i = 0; i < x; i++)
{
cout << " ";
}
putchar(2);
whereToGo = getch();
system("cls");
if(whereToGo == 80)//if press down arrow then make y = 1 + y
{
y++;
}
if(whereToGo == 72)//if press up arrow then make y = y - 1
{
if(y == 0)
{
//do nothing
}
else
{
y--;
}
}
if(whereToGo == 77)//if press right arrow then make x = 1 + x
{
x++;
}
if(whereToGo == 75)//if press left arrow then make x = x - 1
{
x--;
}
}
return 0;
}
void topframe (int xmin, int ymin, int xmax, int ymax)//red_baron's code
{
HANDLE h;
h = GetStdHandle ( STD_OUTPUT_HANDLE );
int count;
gotoxy(xmin,ymin);
putchar(218);
gotoxy(xmax,ymin);
putchar(191);
gotoxy(xmin,ymax);
putchar(192);
gotoxy(xmax,ymax);
putchar(217);
gotoxy(xmin+1,ymin);
for(count=xmin; count<xmax-1; count++)
putchar(196);
gotoxy(xmin+1,ymax);
for(count=xmin; count<xmax-1; count++)
putchar(196);
for(count=ymin+1; count<=ymax-1; count++)
{
gotoxy(xmin,count);
putchar(179);
}
SetConsoleTextAttribute ( h, FOREGROUND_GREEN );
cout << "The text goes here.";
SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE );
for(count=ymin+1; count<=ymax-1; count++)
{
gotoxy(xmax,count);
putchar(179);
}
}
void gotoxy(int x, int y)
{
HANDLE hConsoleOutput;
COORD dwCursorPosition;
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}