]> git.seodisparate.com - RockPaperScissorsDuel/commitdiff
Rename "Game" to "BasicRenderer"
authorStephen Seo <seo.disparate@gmail.com>
Wed, 4 Jan 2023 10:44:44 +0000 (19:44 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 4 Jan 2023 10:44:44 +0000 (19:44 +0900)
CMakeLists.txt
src/basic_renderer.cc [moved from src/game.cc with 93% similarity]
src/basic_renderer.h [moved from src/game.h with 92% similarity]
src/main.cc
wasm_build/Makefile

index 520559efb710c3ccac8e6e2de96c5c3b6895745a..6581efee1eff29e55166ae31451ccb8ade89a227 100644 (file)
@@ -16,7 +16,7 @@ endif()
 
 set(RPSDuelNative_SOURCES
     src/main.cc
-    src/game.cc
+    src/basic_renderer.cc
     src/ems.cc
     src/helpers.cc
 )
similarity index 93%
rename from src/game.cc
rename to src/basic_renderer.cc
index 1aaaf02c816c5fa2e411ea06a2c50bb770a7b343..34a30ed796fc8b271b3d76e874dac2de076f1c1d 100644 (file)
@@ -1,4 +1,4 @@
-#include "game.h"
+#include "basic_renderer.h"
 
 // standard library includes
 #include <cstring>
@@ -12,7 +12,7 @@
 #include "ems.h"
 #include "helpers.h"
 
-Game::Game()
+BasicRenderer::BasicRenderer()
     : spriteSheet(std::nullopt), status("Unknown status"), readyTimer(0.0F),
       resultsTimer(RESULTS_TIMER_MAX), scoreChangeTimer(SCORE_CHANGE_TIMER_MAX),
       requestTimer(REQUEST_TIMER_MAX), prevPos(0), cachedPos(0),
@@ -28,11 +28,12 @@ Game::Game()
   opponentPicked[2] = 0;
 }
 
-void Game::update_state(const char *playerOne, const char *playerTwo,
-                        const char *currentPlayer, char first_first,
-                        char first_second, char first_third, char second_first,
-                        char second_second, char second_third, bool first_ready,
-                        bool second_ready, int pos, int matchup_idx) {
+void BasicRenderer::update_state(const char *playerOne, const char *playerTwo,
+                                 const char *currentPlayer, char first_first,
+                                 char first_second, char first_third,
+                                 char second_first, char second_second,
+                                 char second_third, bool first_ready,
+                                 bool second_ready, int pos, int matchup_idx) {
   // TODO DEBUG
   // if (std::strcmp(playerOne, currentPlayer) == 0) {
   //  std::clog << "update_state:\n"
@@ -118,14 +119,14 @@ void Game::update_state(const char *playerOne, const char *playerTwo,
   }
 }
 
-void Game::do_update() {
+void BasicRenderer::do_update() {
   update_impl();
   draw_impl();
 }
 
-void Game::screen_size_changed() { flags.set(13); }
+void BasicRenderer::screen_size_changed() { flags.set(13); }
 
-void Game::update_impl() {
+void BasicRenderer::update_impl() {
   const float dt = GetFrameTime();
 
   if (flags.test(13)) {
@@ -399,7 +400,7 @@ void Game::update_impl() {
   }
 }
 
-void Game::draw_impl() {
+void BasicRenderer::draw_impl() {
   if (flags.test(2)) {
     BeginDrawing();
     ClearBackground(BLACK);
@@ -498,9 +499,9 @@ void Game::draw_impl() {
   EndDrawing();
 }
 
-void Game::draw_choice(const unsigned int idx, const char choice,
-                       const bool using_triple, const float y,
-                       const Color color) {
+void BasicRenderer::draw_choice(const unsigned int idx, const char choice,
+                                const bool using_triple, const float y,
+                                const Color color) {
   if (!spriteSheet.has_value()) {
     return;
   }
@@ -540,8 +541,8 @@ void Game::draw_choice(const unsigned int idx, const char choice,
   }
 }
 
-void Game::draw_qm(const unsigned int idx, const bool using_triple,
-                   const float y, const Color color) {
+void BasicRenderer::draw_qm(const unsigned int idx, const bool using_triple,
+                            const float y, const Color color) {
   if (!spriteSheet.has_value()) {
     return;
   }
@@ -555,8 +556,9 @@ void Game::draw_qm(const unsigned int idx, const bool using_triple,
                  {x, y, width, width}, {0.0F, 0.0F}, 0.0F, color);
 }
 
-void Game::draw_helper_coord(float *x, float *width, const unsigned int idx,
-                             const bool using_triple) {
+void BasicRenderer::draw_helper_coord(float *x, float *width,
+                                      const unsigned int idx,
+                                      const bool using_triple) {
   if (x) {
     *x = 0.0F;
     *width = ICON_MAX_WIDTH;
@@ -608,17 +610,17 @@ void Game::draw_helper_coord(float *x, float *width, const unsigned int idx,
   }
 }
 
-bool Game::is_choices_set() const {
+bool BasicRenderer::is_choices_set() const {
   return picked[0] != 0 && picked[1] != 0 && picked[2] != 0;
 }
 
-bool Game::is_opponent_choices_set() const {
+bool BasicRenderer::is_opponent_choices_set() const {
   return opponentPicked[0] != 0 && opponentPicked[1] != 0 &&
          opponentPicked[2] != 0 && opponentPicked[0] != '?' &&
          opponentPicked[1] != '?' && opponentPicked[2] != '?';
 }
 
-void Game::draw_score() const {
+void BasicRenderer::draw_score() const {
   char buf[6];
 
   if (isPlayerOne || flags.test(2)) {
@@ -648,7 +650,7 @@ void Game::draw_score() const {
   }
 }
 
-void Game::draw_reveal_choices(const char p[3], const float y) {
+void BasicRenderer::draw_reveal_choices(const char p[3], const float y) {
   float ratio = 1.0F - resultsTimer / RESULTS_TIMER_MAX;
   char otherPicked = Helpers::isValidChoice(p[0]) ? p[0] : '?';
   if (!flags.test(6)) {
similarity index 92%
rename from src/game.h
rename to src/basic_renderer.h
index 9f89bb2d3f805140e783b72d6bc97f65a655b98c..6735a2c3e9d80fe28bdef4728af7ca5012bb4918 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef ROCK_PAPER_SCISSORS_DUEL_GAME_H_
-#define ROCK_PAPER_SCISSORS_DUEL_GAME_H_
+#ifndef ROCK_PAPER_SCISSORS_DUEL_BASIC_RENDERER_H_
+#define ROCK_PAPER_SCISSORS_DUEL_BASIC_RENDERER_H_
 
 // standard library includes
 #include <bitset>
@@ -12,9 +12,9 @@
 // local includes
 #include "game_renderer.h"
 
-class Game : public GameRenderer {
+class BasicRenderer : public GameRenderer {
 public:
-  Game();
+  BasicRenderer();
 
   void update_state(const char *playerOne, const char *playerTwo,
                     const char *currentPlayer, char first_first,
index 5bfe8f1809fa810e714ebceae925bc62ad20ba1c..506e0aa580acd70c002f919c32f6c8e4c6af01c4 100644 (file)
@@ -15,8 +15,8 @@
 #include <raylib.h>
 
 // local includes
+#include "basic_renderer.h"
 #include "constants.h"
-#include "game.h"
 #include "game_renderer.h"
 
 #ifdef __EMSCRIPTEN__
@@ -59,7 +59,7 @@ int main() {
   InitWindow(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, "RPSDuel_Native");
 #endif
 
-  std::unique_ptr<GameRenderer> renderer = std::make_unique<Game>();
+  std::unique_ptr<GameRenderer> renderer = std::make_unique<BasicRenderer>();
 
 #ifdef __EMSCRIPTEN__
   global_game_ptr = renderer.get();
index 1871321dee53954e2b90e747f1a3177292bb9a4b..40ae8bcce82ede2338729b36313d46036d50626c 100644 (file)
@@ -7,13 +7,13 @@ endif
 SOURCES = \
                ../src/main.cc \
                ../src/ems.cc \
-               ../src/game.cc \
+               ../src/basic_renderer.cc \
                ../src/helpers.cc
 
 HEADERS = \
                ../src/constants.h \
                ../src/ems.h \
-               ../src/game.h \
+               ../src/basic_renderer.h \
                ../src/helpers.h \
                ../src/game_renderer.h