Godzil 3 vuotta sitten
vanhempi
commit
a2624bcde5
1 muutettua tiedostoa jossa 10 lisäystä ja 5 poistoa
  1. 10 5
      source/Game.cpp

+ 10 - 5
source/Game.cpp

@@ -9,6 +9,7 @@
 #include <Game.h>
 #include <stdio.h>
 #include <SDL.h>
+#include <SDL_image.h>
 
 Game::Game()
 {
@@ -37,7 +38,6 @@ void Game::Initialize()
     SDL_GetCurrentDisplayMode(0, &displayMode);
     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);
@@ -126,10 +126,15 @@ void Game::Render()
     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_Surface *surface = IMG_Load("assets/images/tank-tiger-right.png");
+    SDL_Texture *texture = SDL_CreateTextureFromSurface(this->renderer, surface);
+    SDL_FreeSurface(surface);
+
+    SDL_Rect dest = {10, 10, 32, 32};
+
+    SDL_RenderCopy(this->renderer, texture, NULL, &dest);
+
+    SDL_DestroyTexture(texture);
 
     SDL_RenderPresent(this->renderer);
 }
-