Browse Source

Lesson 4.1

Godzil 3 years ago
parent
commit
f1d9fb3558
2 changed files with 16 additions and 2 deletions
  1. 15 2
      source/Game.cpp
  2. 1 0
      source/include/Game.h

+ 15 - 2
source/Game.cpp

@@ -35,9 +35,10 @@ void Game::Initialize()
     }
 
     SDL_GetCurrentDisplayMode(0, &displayMode);
-    this->windowsHeight = displayMode.h;
     this->windowsWidth = displayMode.w;
+    this->windowsHeight = displayMode.h;
     printf("%d:%d\n", displayMode.w, displayMode.h);
+
     this->window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                                     this->windowsWidth, this->windowsHeight, SDL_WINDOW_BORDERLESS);
     if (!window)
@@ -74,6 +75,8 @@ void Game::Destroy()
 
 void Game::Run()
 {
+    this->Setup();
+
     while(this->isRunning)
     {
         this->ProcessInput();
@@ -82,6 +85,11 @@ void Game::Run()
     }
 }
 
+void Game::Setup()
+{
+
+}
+
 void Game::ProcessInput()
 {
     SDL_Event event;
@@ -115,8 +123,13 @@ void Game::Update()
 
 void Game::Render()
 {
-    SDL_SetRenderDrawColor(this->renderer, 255, 64, 127, 255);
+    SDL_SetRenderDrawColor(this->renderer, 21, 21, 21, 255);
     SDL_RenderClear(this->renderer);
 
+    SDL_Rect player = { 10, 10, 20, 20 };
+    SDL_SetRenderDrawColor(this->renderer, 127, 255, 64, 255);
+    SDL_RenderFillRect(this->renderer, &player);
+
     SDL_RenderPresent(this->renderer);
 }
+

+ 1 - 0
source/include/Game.h

@@ -26,6 +26,7 @@ public:
     void Run();
     void Destroy();
 
+    void Setup();
     void ProcessInput();
     void Render();
     void Update();