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
 <html>
1
 <html>
2
     <head>
2
     <head>
3
         <style>
3
         <style>
4
-            #wrap, #text {
4
+            #wrap, .text {
5
                 width: 100%;
5
                 width: 100%;
6
-                height: 100%;
7
-                max-width: 640px;
8
-                max-height: 480px;
6
+                max-width: 640px; /* 160px * 4 */
9
                 margin: auto;
7
                 margin: auto;
10
                 text-align: center;
8
                 text-align: center;
11
             }
9
             }
10
+            #wrap {
11
+                height: 100%;
12
+                max-height: 576px; /* 144px * 4 */
13
+            }
12
             #controls {
14
             #controls {
13
                 margin: 0px auto;
15
                 margin: 0px auto;
14
             }
16
             }
15
             @media (prefers-color-scheme: dark) {
17
             @media (prefers-color-scheme: dark) {
16
-                body, #wrap, #text {
18
+                body, .wrap, #text {
17
                     background-color: #111111;
19
                     background-color: #111111;
18
                     color: #FFFFFF;
20
                     color: #FFFFFF;
19
                 }
21
                 }
21
         </style>
23
         </style>
22
     </head>
24
     </head>
23
     <body>
25
     <body>
26
+        <div class="text">
27
+            <h1>Duality</h1>
28
+        </div>
24
         <div id="wrap">
29
         <div id="wrap">
25
             <div id="game"></div>
30
             <div id="game"></div>
26
         </div>
31
         </div>
27
-        <div id="text">
28
-            <h1>Duality</h1>
32
+        <div class="text">
29
             <p>A GameBoy (Color) port of the GTA San Andreas arcade game Duality.</p>
33
             <p>A GameBoy (Color) port of the GTA San Andreas arcade game Duality.</p>
30
             <table id="controls" border="1">
34
             <table id="controls" border="1">
31
                 <tr><th>Key</th><th>Action</th></tr>
35
                 <tr><th>Key</th><th>Action</th></tr>
32
                 <tr><td>Arrow Left</td><td>Rotate Left</td></tr>
36
                 <tr><td>Arrow Left</td><td>Rotate Left</td></tr>
33
                 <tr><td>Arrow Right</td><td>Rotate Right</td></tr>
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
             </table>
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
             <hr>
44
             <hr>
38
             <p>Download the <a href="https://xythobuz.github.io/Duality/duality.gb">ROM</a>!</p>
45
             <p>Download the <a href="https://xythobuz.github.io/Duality/duality.gb">ROM</a>!</p>
39
             <p>Get the source code on <a href="https://github.com/xythobuz/Duality">GitHub</a>.</p>
46
             <p>Get the source code on <a href="https://github.com/xythobuz/Duality">GitHub</a>.</p>
47
+            <hr>
40
             <p>Emulation supported by <a href="https://emulatorjs.org">EmulatorJS</a>.</p>
48
             <p>Emulation supported by <a href="https://emulatorjs.org">EmulatorJS</a>.</p>
41
         </div>
49
         </div>
42
         <script>
50
         <script>

+ 3
- 2
src/game.c View File

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

+ 8
- 2
src/main.c View File

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

+ 15
- 3
src/obj.c View File

154
                 break;
154
                 break;
155
 
155
 
156
             case SPR_LIGHT:
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
                 if ((abs(objs[i].off_x) <= PICKUP_LARGE_RANGE) && (abs(objs[i].off_y) <= PICKUP_LARGE_RANGE)) {
170
                 if ((abs(objs[i].off_x) <= PICKUP_LARGE_RANGE) && (abs(objs[i].off_y) <= PICKUP_LARGE_RANGE)) {
159
                     damage -= 1;
171
                     damage -= 1;
160
                 }
172
                 }
162
 
174
 
163
             case SPR_SHOT_DARK:
175
             case SPR_SHOT_DARK:
164
                 if ((abs(objs[i].off_x) <= PICKUP_SMALL_RANGE) && (abs(objs[i].off_y) <= PICKUP_SMALL_RANGE)) {
176
                 if ((abs(objs[i].off_x) <= PICKUP_SMALL_RANGE) && (abs(objs[i].off_y) <= PICKUP_SMALL_RANGE)) {
165
-                    (*score)--;
177
+                    (*score) -= 5;
166
                     objs[i].active = 0;
178
                     objs[i].active = 0;
167
                 }
179
                 }
168
                 break;
180
                 break;
169
 
181
 
170
             case SPR_SHOT_LIGHT:
182
             case SPR_SHOT_LIGHT:
171
                 if ((abs(objs[i].off_x) <= PICKUP_SMALL_RANGE) && (abs(objs[i].off_y) <= PICKUP_SMALL_RANGE)) {
183
                 if ((abs(objs[i].off_x) <= PICKUP_SMALL_RANGE) && (abs(objs[i].off_y) <= PICKUP_SMALL_RANGE)) {
172
-                    (*score)++;
184
+                    (*score) += 5;
173
                     objs[i].active = 0;
185
                     objs[i].active = 0;
174
                 }
186
                 }
175
                 break;
187
                 break;

Loading…
Cancel
Save