How can i make sure something is constantly updating?

I'm trying to make a text based game with both a top and bottom status bar. how can i make sure that (1) it is always visible and (2) the info is always updating and accurate as the player plays?



Here is the code i have so far for the status bars:


#include <iostream>
#include <cmath>
#include <windows.h>
#include <cstdlib>
#include <fstream>
using namespace std;

string name = "Name"; // name
int LvNum; // level number
string Asp = "Aspiration"; // aspiration
int hlth; // current health
int mxhlth; // max health
int money; // money
int LukP;// Luck points
string area= "McCarther Park"; // displays the name of the area of the map you are in
string time_of_day = "Morning"; // displays what time of day it is; ie, morning ,midday ,afternoon ,evening, night

int TopBar(); // status bar on the top of the screen
int BottomBar(); // status bar on the bottom of the screen
int game();

int main ()
{
TopBar();

cout << " the game goes in between here" << endl;//


BottomBar();


system ("PAUSE");
return 0;
}


int TopBar()
{



cout<<
"________________________________________________________________________________" << endl;

cout << " "<< area<< " "<< time_of_day << endl;

cout<<
"________________________________________________________________________________" << endl;
}





int BottomBar()
{


cout <<
"________________________________________________________________________________" << endl;
cout << " "<< name <<" "<< "LV."<<LvNum<< " " << Asp << " " << "HP: "<< hlth << "/" << mxhlth << " "<< "$" << money<< " "<< "LP: "<< LukP << endl;
cout<<
"________________________________________________________________________________" << endl;
}


Last edited on
It just needs to be a part of your loop. Everytime the user does something that modifies the status of the game, write out the status bars and wait for the next input.
Just FYI, the Observer pattern is one approach to coordinating changes across dependents.
Topic archived. No new replies allowed.