]> git.seodisparate.com - RockPaperScissorsDuel/commitdiff
Negate score when displaying for player 2
authorStephen Seo <seo.disparate@gmail.com>
Wed, 4 Jan 2023 05:04:43 +0000 (14:04 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 4 Jan 2023 05:04:43 +0000 (14:04 +0900)
src/game.cc

index 8c0e775689a71f811a0e2672b4f089cdac7afe36..1aaaf02c816c5fa2e411ea06a2c50bb770a7b343 100644 (file)
@@ -619,13 +619,24 @@ bool Game::is_opponent_choices_set() const {
 }
 
 void Game::draw_score() const {
-  char buf[6] = {prevPos < 0 ? '-' : ' ',
-                 prevPos < 0 ? (char)('0' - prevPos) : (char)('0' + prevPos),
-                 0,
-                 cachedPos < 0 ? '-' : ' ',
-                 cachedPos < 0 ? (char)('0' - cachedPos)
-                               : (char)('0' + cachedPos),
-                 0};
+  char buf[6];
+
+  if (isPlayerOne || flags.test(2)) {
+    buf[0] = prevPos < 0 ? '-' : ' ';
+    buf[1] = prevPos < 0 ? (char)('0' - prevPos) : (char)('0' + prevPos);
+    buf[2] = 0;
+    buf[3] = cachedPos < 0 ? '-' : ' ';
+    buf[4] = cachedPos < 0 ? (char)('0' - cachedPos) : (char)('0' + cachedPos);
+    buf[5] = 0;
+  } else {
+    buf[0] = -prevPos < 0 ? '-' : ' ';
+    buf[1] = -prevPos < 0 ? (char)('0' - -prevPos) : (char)('0' + -prevPos);
+    buf[2] = 0;
+    buf[3] = -cachedPos < 0 ? '-' : ' ';
+    buf[4] =
+        -cachedPos < 0 ? (char)('0' - -cachedPos) : (char)('0' + -cachedPos);
+    buf[5] = 0;
+  }
   if (prevPos != cachedPos) {
     float ratio = 1.0F - scoreChangeTimer / SCORE_CHANGE_TIMER_MAX;
     DrawText(&buf[3], 0, 0, 20,