Allegro display stats

so what i want is a program to display the stats of a character in a text based game. i am new to graphics and have a console text based game and it is mostly complete. now that i am trying to learn allegro though i wanted to have the characters stats displayed in a window. i got it to work out fairly well. but what i am having a hard time with is getting it to update the variables.

and actually i think maybe i thought of how to do it just now. i can just use a while loop like i should be doing anyways. right? anyways i will try that and see if it works. but in the mean time. please help. what should i do? this is what i have so far.

yes its very unorganized. i was getting frustrated and pretty much doing anything i could to try and get it to work. hah i got it to work with updating the fps but when i worked on applying it to this it didnt go so well.

Thanks a lot!

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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>

#include <iostream>

using namespace std;

     int width = 640;
     int height = 480;
     
     int ATT = 0;
     int DEF = 0;
     int HP = 0;
     int DAM = 0;
     int ATT1 = 0;
     int DEF1 = 0;
     int HP1 = 0;
     int DAM1 = 0;
     
     char NAME[20];
     
     bool done = false;
     
     ALLEGRO_DISPLAY *display = NULL;
     ALLEGRO_EVENT_QUEUE *event_queue = NULL;
     
     void test();
     void stats();

int main(void)
{    
     if(!al_init())
     {
          return -1;
     }
     
     display = al_create_display(width, height);
     
     if(!display)
     {
          return -1;
     }
     
     test();
     
     al_rest(5.0);
     
     al_destroy_display(display);
     
     return 0;
}




void test()
{
     al_init_font_addon();
     al_init_ttf_addon();
     
     ALLEGRO_FONT *font32 = al_load_font("couri.ttf", 32, 0);
     

          
          
          stats();
          
          ATT = ATT + ATT1;
          DEF = DEF + DEF1;
          HP = HP + HP1;
          DAM = HP - DAM1;
          
          display = al_create_display(width, height);
          
          al_draw_textf(font32, al_map_rgb(11, 0, 255), 50, height - 450, 0,
                                           "Name: %s", NAME);
          al_draw_textf(font32, al_map_rgb(11, 0, 255), 50, height - 400, 0,
                                           "Attack: %i", ATT);
          al_draw_textf(font32, al_map_rgb(11, 0, 255), 50, height - 350, 0,
                                           "Defence: %i", DEF);
          al_draw_textf(font32, al_map_rgb(11, 0, 255), 50, height - 300, 0,
                                           "Health: %i / %i", DAM, HP);
          
          al_flip_display();
          al_clear_to_color(al_map_rgb(0, 0, 0));
          
          test();     
}


void stats()
{
     cout << "Please enter your name: ";
     cin >> NAME;
     
     cout << endl << "Please enter your attack level: ";
     cin >> ATT1;
     cout << endl << "Please enter your defence level: ";
     cin >> DEF1;
     cout << endl << "Please enter your health level: ";
     cin >> HP1;
     cout << endl << "Please damage your character: ";
     cin >> DAM1;
     
     al_destroy_display(display);
}
ok. haha sorry disregard this i figured it out. i was right with the while loop. works well.
Topic archived. No new replies allowed.