Browse Source

move game score window to bottom right

Thomas B 1 month ago
parent
commit
ac40343934
3 changed files with 12 additions and 9 deletions
  1. 4
    3
      src/game.c
  2. 7
    5
      src/maps.c
  3. 1
    1
      src/maps.h

+ 4
- 3
src/game.c View File

103
     obj_add(SPR_SHOT_LIGHT, 32, 32, 0, 0);
103
     obj_add(SPR_SHOT_LIGHT, 32, 32, 0, 0);
104
     obj_add(SPR_SHOT_DARK, -32, -32, 0, 0);
104
     obj_add(SPR_SHOT_DARK, -32, -32, 0, 0);
105
 
105
 
106
-    win_game_draw(score);
107
-    move_win(MINWNDPOSX, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
106
+    uint8_t x_off = win_game_draw(score);
107
+    move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
108
 
108
 
109
     SHOW_WIN;
109
     SHOW_WIN;
110
     DISPLAY_ON;
110
     DISPLAY_ON;
183
         }
183
         }
184
 
184
 
185
         if (score != prev_score) {
185
         if (score != prev_score) {
186
-            win_game_draw(score);
186
+            uint8_t x_off = win_game_draw(score);
187
+            move_win(MINWNDPOSX + DEVICE_SCREEN_PX_WIDTH - x_off, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
187
         }
188
         }
188
 
189
 
189
         // adjust speed down when not moving
190
         // adjust speed down when not moving

+ 7
- 5
src/maps.c View File

91
                   (is_black ? num_attr_2 : num_attr_1) + off);
91
                   (is_black ? num_attr_2 : num_attr_1) + off);
92
 }
92
 }
93
 
93
 
94
-static void number(int32_t score, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
94
+static uint8_t number(int32_t score, uint8_t x_off, uint8_t y_off, uint8_t is_black) NONBANKED {
95
     // TODO can not set numbers larger than int16 max?!
95
     // TODO can not set numbers larger than int16 max?!
96
     //score = 32767 + 1; // wtf?!
96
     //score = 32767 + 1; // wtf?!
97
 
97
 
107
 
107
 
108
     // if the number was too large for our buffer don't draw anything
108
     // if the number was too large for our buffer don't draw anything
109
     if (score > 0) {
109
     if (score > 0) {
110
-        return;
110
+        return 0;
111
     }
111
     }
112
 
112
 
113
     uint8_t off = (x_off == 0xFF) ? (10 - len) : ((x_off == 0xFE) ? (20 - (len * 2)) : x_off);
113
     uint8_t off = (x_off == 0xFF) ? (10 - len) : ((x_off == 0xFE) ? (20 - (len * 2)) : x_off);
114
     for (uint8_t i = 0; i < len; i++) {
114
     for (uint8_t i = 0; i < len; i++) {
115
         digit(digits[len - i - 1], i, off, y_off, is_black);
115
         digit(digits[len - i - 1], i, off, y_off, is_black);
116
     }
116
     }
117
+
118
+    return 8 * len * 2;
117
 }
119
 }
118
 
120
 
119
 static void fill_win(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tile, uint8_t attr) NONBANKED {
121
 static void fill_win(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tile, uint8_t attr) NONBANKED {
144
     number(score, 5, 4 + off * 3, is_black);
146
     number(score, 5, 4 + off * 3, is_black);
145
 }
147
 }
146
 
148
 
147
-void win_game_draw(int32_t score) NONBANKED {
148
-    fill_win(0, 0, 20, 2, (uint8_t)bg_map_TILE_COUNT + (uint8_t)numbers_TILE_COUNT, 0x81);
149
+uint8_t win_game_draw(int32_t score) NONBANKED {
150
+    fill_win(0, 0, 10, 2, (uint8_t)bg_map_TILE_COUNT + (uint8_t)numbers_TILE_COUNT, 0x81);
149
 
151
 
150
     uint8_t is_black = 0;
152
     uint8_t is_black = 0;
151
     if (score < 0) {
153
     if (score < 0) {
153
         is_black = 1;
155
         is_black = 1;
154
     }
156
     }
155
 
157
 
156
-    number(score, 0xFF, 0, is_black);
158
+    return number(score, 0, 0, is_black);
157
 }
159
 }

+ 1
- 1
src/maps.h View File

29
 void win_splash_draw(int32_t lowest, int32_t highest);
29
 void win_splash_draw(int32_t lowest, int32_t highest);
30
 void win_score_clear(void);
30
 void win_score_clear(void);
31
 void win_score_draw(int32_t score, uint8_t off, uint8_t is_black);
31
 void win_score_draw(int32_t score, uint8_t off, uint8_t is_black);
32
-void win_game_draw(int32_t score);
32
+uint8_t win_game_draw(int32_t score);
33
 
33
 
34
 #endif // __MAPS_H__
34
 #endif // __MAPS_H__

Loading…
Cancel
Save