Clear screen without SYSTEM("cls")

Because im working on a game that i was actually going to share on the net. Its a console based game. Simple to use. Its called Text Quest Maze Edition

Its my first app. And i really do not want that security problem that i saw in another topic. Thanks

here is my current work (Ill keep up to date)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <ctime>
#include <string>
//#define newline endl
//#undef newline


using namespace std;
//The way to pause the program or messages to make readable you must type wait(T) T represents seconds i believe

void wait(int wait_time);

int launch(bool b);

//bool var_status = false;
bool var_status = true;
char var_name [11];
int main()
{


    cout << "Welcome to the Text Quest Game." << endl;
    wait(1);
    cout << "This is a text type game. Using only a console for actions and more." << endl;
    wait(4);
    cout << "Please Enter Your Name: ";
    cin >> var_name;
    cout << endl;
    system("cls");
    cout << "Welcome to Text Quest " << var_name;
    wait(4);
    system("cls");
    launch(var_status);
}


void wait(int wait_time)
{
    long *start_time = new long;
    *start_time = time(0);

    while ((*start_time + wait_time) > time(0)){
    };

    delete start_time;
};
int launch(bool b)
{
    bool var_stat = b;


    if (var_stat == true) {
        cout << "This game is launching loader.";
        wait(3);
        system("Cls");
        cout << "Loading Map / Locations" << endl;
        /// Syntex for Path directions below
        /*
        1   = N
        2   = E
        3   = S
        4   = W
        5   = NE
        6   = ES
        7   = SW
        8   = NW
        9   = NES
        10  = ESW
        11  = NSE
        12  = NEW
        13  = NESW
        14  = EW
        15  = NS
        */
        cout << "Loading Map Area Data" << endl;
        int locations [6] [6]= {{101,5,14,12,14,4},{5,7,5,10,12,4},{3,1,3,5,7,1},{2,13,14,10,14,11},{5,10,8,5,12,4},{3,2,10,7,6,102}};
        cout << "Load Map Area Data Completed successfully" <<endl;
        cout << "Starting Game.";
        wait(3);
        system("cls");


}

    else if (var_stat == false) {
        cout << "Sorry but this game has a status of Incomplete. You may not play this game. Sorry for any let downs." << endl;
    }
    else cout << "Error: Variable Stat has a invalid Value! Game ending";
    return 0;
}
My bad. Must have not seen that one
Not a problem. ;)
It turns out most of the solutions dont work for me. And i want it to do something and that the other ones that might work is something i can not use. Because it will ruin what i need to do.
cout << string( 100, '\n' );
doesn't work for you?
It works but it makes the text look wierd :| like all the text is now on the bottom. I want it to stay on top :)
What OS are you using? Depending on what you are using there are different ways of putting the cursor at the top of the screen.
Last edited on
Windows XP

But that has nothing to do with it its that its not clearing its just making a bunch of empty lines :|

So basically it calls it has like its a mass info thing look of nothing
Try reading http://www.adrianxw.dk/SoftwareSite/Consoles/Consoles2.html. If you print enough blank lines, then put the cursor at the top left of the screen it will have the effect you want.
You could look into ncurses/pdcurses (windows version I think).
They have this neat function; clrscr() I think.

http://web.cs.mun.ca/~rod/ncurses/ncurses.html

Change any ncurses.h to curses.h and link with this ( http://gnuwin32.sourceforge.net/packages/pdcurses.htm ) and you're away.
Topic archived. No new replies allowed.