Browse Source

remove flicker when showing score. large white spheres now kinda repel. add description to web page.

Thomas B 1 month ago
parent
commit
e1f30c62ed
4 changed files with 43 additions and 16 deletions
  1. 17
    9
      docs/index.html
  2. 3
    2
      src/game.c
  3. 8
    2
      src/main.c
  4. 15
    3
      src/obj.c

+ 17
- 9
docs/index.html View File

@@ -1,19 +1,21 @@
1 1
 <html>
2 2
     <head>
3 3
         <style>
4
-            #wrap, #text {
4
+            #wrap, .text {
5 5
                 width: 100%;
6
-                height: 100%;
7
-                max-width: 640px;
8
-                max-height: 480px;
6
+                max-width: 640px; /* 160px * 4 */
9 7
                 margin: auto;
10 8
                 text-align: center;
11 9
             }
10
+            #wrap {
11
+                height: 100%;
12
+                max-height: 576px; /* 144px * 4 */
13
+            }
12 14
             #controls {
13 15
                 margin: 0px auto;
14 16
             }
15 17
             @media (prefers-color-scheme: dark) {
16
-                body, #wrap, #text {
18
+                body, .wrap, #text {
17 19
                     background-color: #111111;
18 20
                     color: #FFFFFF;
19 21
                 }
@@ -21,22 +23,28 @@
21 23
         </style>
22 24
     </head>
23 25
     <body>
26
+        <div class="text">
27
+            <h1>Duality</h1>
28
+        </div>
24 29
         <div id="wrap">
25 30
             <div id="game"></div>
26 31
         </div>
27
-        <div id="text">
28
-            <h1>Duality</h1>
32
+        <div class="text">
29 33
             <p>A GameBoy (Color) port of the GTA San Andreas arcade game Duality.</p>
30 34
             <table id="controls" border="1">
31 35
                 <tr><th>Key</th><th>Action</th></tr>
32 36
                 <tr><td>Arrow Left</td><td>Rotate Left</td></tr>
33 37
                 <tr><td>Arrow Right</td><td>Rotate Right</td></tr>
34
-                <tr><td>Z</td><td>Accelerate</td></tr>
35
-                <tr><td>X</td><td>Shoot</td></tr>
38
+                <tr><td>A (Z)</td><td>Accelerate</td></tr>
39
+                <tr><td>B (X)</td><td>Shoot</td></tr>
36 40
             </table>
41
+            <p>Press Left or Right on the title screen to show either the black or white highscores.</p>
42
+            <p>Collect small white spheres to get +5 white score. Collect small black spheres to get +5 black score. The opposite color will reduce your score when collected. Large black holes will attract you and damage your ship when touched. Large white spheres will repel you and replenish your health when touched. Accelerating will reduce your fuel, which will recharge when not accelerating. You can shoot large spheres for +10 points.<p>
43
+            <p>For a more detailed description of the original game check out the <a href="https://gta.fandom.com/wiki/Duality">Duality article on GTA Wiki</a>.</p>
37 44
             <hr>
38 45
             <p>Download the <a href="https://xythobuz.github.io/Duality/duality.gb">ROM</a>!</p>
39 46
             <p>Get the source code on <a href="https://github.com/xythobuz/Duality">GitHub</a>.</p>
47
+            <hr>
40 48
             <p>Emulation supported by <a href="https://emulatorjs.org">EmulatorJS</a>.</p>
41 49
         </div>
42 50
         <script>

+ 3
- 2
src/game.c View File

@@ -82,8 +82,6 @@ int32_t game(void) {
82 82
     SHOW_BKG;
83 83
     SHOW_SPRITES;
84 84
     SPRITES_8x8;
85
-    DISPLAY_ON;
86
-    enable_interrupts();
87 85
 
88 86
     int16_t pos_x = 0;
89 87
     int16_t pos_y = 0;
@@ -107,7 +105,10 @@ int32_t game(void) {
107 105
 
108 106
     win_game_draw(score);
109 107
     move_win(MINWNDPOSX + 0, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - 16);
108
+
110 109
     SHOW_WIN;
110
+    DISPLAY_ON;
111
+    enable_interrupts();
111 112
 
112 113
     while(1) {
113 114
         key_read();

+ 8
- 2
src/main.c View File

@@ -33,6 +33,8 @@
33 33
 #include "score.h"
34 34
 
35 35
 static void highscore(uint8_t is_black) {
36
+    HIDE_WIN;
37
+
36 38
     hide_sprites_range(SPR_NUM_START, MAX_HARDWARE_SPRITES);
37 39
     win_score_clear();
38 40
 
@@ -42,6 +44,7 @@ static void highscore(uint8_t is_black) {
42 44
     }
43 45
 
44 46
     move_win(MINWNDPOSX + 0, MINWNDPOSY);
47
+    SHOW_WIN;
45 48
 
46 49
     while (1) {
47 50
         key_read();
@@ -55,6 +58,8 @@ static void highscore(uint8_t is_black) {
55 58
 }
56 59
 
57 60
 static void splash_win(void) {
61
+    HIDE_WIN;
62
+
58 63
     // initially show the top 1 scores
59 64
     int32_t low = score_lowest(0);
60 65
     int32_t high = score_highest(0);
@@ -75,8 +80,6 @@ static void splash(void) {
75 80
     SHOW_BKG;
76 81
     SHOW_SPRITES;
77 82
     SPRITES_8x8;
78
-    DISPLAY_ON;
79
-    enable_interrupts();
80 83
 
81 84
     obj_init();
82 85
     obj_add(SPR_LIGHT, 42, -42, 0, 0);
@@ -84,6 +87,9 @@ static void splash(void) {
84 87
 
85 88
     splash_win();
86 89
 
90
+    DISPLAY_ON;
91
+    enable_interrupts();
92
+
87 93
     while (1) {
88 94
         key_read();
89 95
 

+ 15
- 3
src/obj.c View File

@@ -154,7 +154,19 @@ int16_t obj_act(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score) {
154 154
                 break;
155 155
 
156 156
             case SPR_LIGHT:
157
-                // TODO
157
+                if ((abs(objs[i].off_x) <= GRAVITY_RANGE) && (abs(objs[i].off_y) <= GRAVITY_RANGE)) {
158
+                    if (objs[i].off_x > 0) {
159
+                        *spd_off_x -= (GRAVITY_RANGE - objs[i].off_x) >> GRAVITY_SHIFT;
160
+                    } else if (objs[i].off_x < 0) {
161
+                        *spd_off_x -= (-GRAVITY_RANGE - objs[i].off_x) >> GRAVITY_SHIFT;
162
+                    }
163
+                    if (objs[i].off_y > 0) {
164
+                        *spd_off_y -= (GRAVITY_RANGE - objs[i].off_y) >> GRAVITY_SHIFT;
165
+                    } else if (objs[i].off_y < 0) {
166
+                        *spd_off_y -= (-GRAVITY_RANGE - objs[i].off_y) >> GRAVITY_SHIFT;
167
+                    }
168
+                }
169
+
158 170
                 if ((abs(objs[i].off_x) <= PICKUP_LARGE_RANGE) && (abs(objs[i].off_y) <= PICKUP_LARGE_RANGE)) {
159 171
                     damage -= 1;
160 172
                 }
@@ -162,14 +174,14 @@ int16_t obj_act(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score) {
162 174
 
163 175
             case SPR_SHOT_DARK:
164 176
                 if ((abs(objs[i].off_x) <= PICKUP_SMALL_RANGE) && (abs(objs[i].off_y) <= PICKUP_SMALL_RANGE)) {
165
-                    (*score)--;
177
+                    (*score) -= 5;
166 178
                     objs[i].active = 0;
167 179
                 }
168 180
                 break;
169 181
 
170 182
             case SPR_SHOT_LIGHT:
171 183
                 if ((abs(objs[i].off_x) <= PICKUP_SMALL_RANGE) && (abs(objs[i].off_y) <= PICKUP_SMALL_RANGE)) {
172
-                    (*score)++;
184
+                    (*score) += 5;
173 185
                     objs[i].active = 0;
174 186
                 }
175 187
                 break;

Loading…
Cancel
Save