1 #include "globals.h"
2 #include "sizes.h"
3 #include "radar.h"
4 #include "object.h"
5 #include "ship.h"
6 #include "screen.h"
7
8
9 int ShowScore;
10 unsigned int MaxShield;
11 unsigned int MaxArmor;
12
13
14 int ScoreCompare(const void *value1, const void *value2);
15
16
17 // Function to draw the status on the bottom of the screen
DrawStatus()18 void DrawStatus()
19 {
20 char text[50];
21 int pos;
22 int i, j;
23 int n=0;
24 int tempval;
25 int ShieldLength, ArmorLength;
26 struct Color *textcolor;
27 int ScoreDisplayOrder[MAX_PLAYERS];
28
29 InitMatrixMode();
30
31 if (Ships[myShip]->Lives) {
32 sprintf(text, "Score: %d", Ships[myShip]->Score);
33 DrawText(10, ScreenHeight-20, text, &Green);
34
35 if (GameType!=DEATHMATCH) {
36 sprintf(text, "Lives: %d", Ships[myShip]->Lives);
37 DrawText(10, ScreenHeight-35, text, &Green);
38 }
39 sprintf(text, "HyperWarps: %d", Ships[myShip]->Warps);
40 DrawText(ScreenWidth-100, ScreenHeight-20, text, &Green);
41 sprintf(text, "Nukes: %d", Ships[myShip]->Nukes);
42 DrawText(ScreenWidth-100, ScreenHeight-35, text, &Green);
43
44 if (GameType!=SINGLE_PLAYER && (ShowScore || !GameRunning)) {
45 for (i=0; i<MAX_PLAYERS; i++) {
46 ScoreDisplayOrder[i]=i;
47 }
48
49 qsort(ScoreDisplayOrder, MAX_PLAYERS, sizeof(int), ScoreCompare);
50
51 for (i=0; i<MAX_PLAYERS-1; i++) {
52 for (j=i; j<MAX_PLAYERS-1; j++) {
53 }
54 }
55
56 for (i=0; i<MAX_PLAYERS; i++) {
57 if (Ships[ScoreDisplayOrder[i]]) {
58 sprintf(text, "%s Score: %d", Ships[ScoreDisplayOrder[i]]->PlayerName, Ships[ScoreDisplayOrder[i]]->Score);
59 if (ScoreDisplayOrder[i]==myShip) {
60 textcolor=&Red;
61 } else {
62 textcolor=&Blue;
63 }
64 DrawText(ScreenWidth/2-7, ScreenHeight-20*n-80, text, textcolor);
65 n++;
66 }
67 }
68 if (!GameRunning) {
69 sprintf(text, "Game Over");
70 DrawText(ScreenWidth/2-7, ScreenHeight-40, text, &Blue);
71 }
72 }
73 sprintf(text, "Shield: ");
74 pos=DrawText(10, 10, text, &Green)+5;
75 DrawLine(pos, 18, pos, 9, &White);
76 DrawLine(pos, 9, pos+40, 9, &White);
77 DrawLine(pos+40, 9, pos+40, 18, &White);
78 DrawLine(pos+40, 18, pos, 18, &White);
79 if (Ships[myShip]->Shield) {
80 ShieldLength=(38*Ships[myShip]->Shield)/MaxShield;
81 DrawRect(pos+1, 10, pos+1, 17, pos+1+ShieldLength, 17,
82 pos+1+ShieldLength, 10, &Blue);
83 }
84 sprintf(text, "Armor: ");
85 pos=DrawText(ScreenWidth-100, 10, text, &Green)+5;
86 DrawLine(pos, 18, pos, 9, &White);
87 DrawLine(pos, 9, pos+40, 9, &White);
88 DrawLine(pos+40, 9, pos+40, 18, &White);
89 DrawLine(pos+40, 18, pos, 18, &White);
90 if (Ships[myShip]->Armor) {
91 ArmorLength=(38*Ships[myShip]->Armor)/MaxArmor;
92 DrawRect(pos+1, 10, pos+1, 17, pos+1+ArmorLength, 17,
93 pos+1+ArmorLength, 10, &Blue);
94 }
95
96 } else {
97 sprintf(text, "Game Over");
98 DrawText(ScreenWidth/2-7, ScreenHeight/2+20, text, &Blue);
99 if (GameType!=SINGLE_PLAYER) {
100 /* for (i=0; i<NumPlayers; i++) {
101 if (Ships[i]->Connected) {
102 sprintf(text, "%s Score: %d", Ships[i]->ShipName, Ships[i]->score);
103 DrawText(ScreenWidth/2-7, ScreenHeight/2-20*i, text, &Blue);
104 }
105 }*/
106 } else {
107 sprintf(text, "Player Score: %d", Ships[myShip]->Score);
108 DrawText(ScreenWidth/2-7, ScreenHeight/2, text, &Blue);
109 sprintf(text, "Press Fire key to continue");
110 DrawText(ScreenWidth/2-7, ScreenHeight/2-20, text, &Blue);
111 }
112 }
113
114 DrawRadar();
115
116 SetupGameMatrixMode();
117 }
118
119
ScoreCompare(const void * value1,const void * value2)120 int ScoreCompare(const void *value1, const void *value2)
121 {
122 if (Ships[*(int *)value1] && Ships[*(int *)value2]) {
123 if (Ships[*(int *)value1]->Score < Ships[*(int *)value2]->Score) {
124 return(1);
125 } else if (Ships[*(int *)value2] &&
126 !Ships[*(int *)value1]) {
127 return(1);
128 }
129 }
130 return(-1);
131 }
132