summary refs log tree commit diff stats
path: root/src/renderer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer.cpp')
-rw-r--r--src/renderer.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/renderer.cpp b/src/renderer.cpp index 724e297..09bddc9 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -1,6 +1,7 @@
1#include "renderer.h" 1#include "renderer.h"
2#include <iostream> 2#include <iostream>
3#include "game.h" 3#include "game.h"
4#include "runtime.h"
4 5
5Renderer::Renderer() 6Renderer::Renderer()
6{ 7{
@@ -33,7 +34,7 @@ Renderer::Renderer()
33 } 34 }
34 35
35 texture_ptr origFade; 36 texture_ptr origFade;
36 loadTextureFromFile("../res/lighting.png", origFade); 37 loadTextureFromFile("lighting.png", origFade);
37 38
38 playerFade_ = texture_ptr( 39 playerFade_ = texture_ptr(
39 SDL_CreateTexture( 40 SDL_CreateTexture(
@@ -105,22 +106,22 @@ Renderer::Renderer()
105 SDL_SetRenderDrawColor(ren_.get(), 100, 100, 100, 255); 106 SDL_SetRenderDrawColor(ren_.get(), 100, 100, 100, 255);
106 SDL_RenderFillRect(ren_.get(), nullptr); 107 SDL_RenderFillRect(ren_.get(), nullptr);
107 108
108 loadTextureFromFile("../res/player.png", playerSheet_); 109 loadTextureFromFile("player.png", playerSheet_);
109 loadTextureFromFile("../res/runninbloods.png", tileset_); 110 loadTextureFromFile("runninbloods.png", tileset_);
110 loadTextureFromFile("../res/lamp.png", lamp_); 111 loadTextureFromFile("lamp.png", lamp_);
111 loadTextureFromFile("../res/read_instruction.png", readInstruction_); 112 loadTextureFromFile("read_instruction.png", readInstruction_);
112 loadTextureFromFile("../res/menu.png", menuBg_); 113 loadTextureFromFile("menu.png", menuBg_);
113 114
114 loadTextureFromFile("../res/title0.png", titles_[0]); 115 loadTextureFromFile("title0.png", titles_[0]);
115 SDL_QueryTexture(titles_[0].get(), nullptr, nullptr, &titleWidths_[0], &titleHeights_[0]); 116 SDL_QueryTexture(titles_[0].get(), nullptr, nullptr, &titleWidths_[0], &titleHeights_[0]);
116 117
117 loadTextureFromFile("../res/title1.png", titles_[1]); 118 loadTextureFromFile("title1.png", titles_[1]);
118 SDL_QueryTexture(titles_[1].get(), nullptr, nullptr, &titleWidths_[1], &titleHeights_[1]); 119 SDL_QueryTexture(titles_[1].get(), nullptr, nullptr, &titleWidths_[1], &titleHeights_[1]);
119 120
120 loadTextureFromFile("../res/title3.png", titles_[2]); 121 loadTextureFromFile("title3.png", titles_[2]);
121 SDL_QueryTexture(titles_[2].get(), nullptr, nullptr, &titleWidths_[2], &titleHeights_[2]); 122 SDL_QueryTexture(titles_[2].get(), nullptr, nullptr, &titleWidths_[2], &titleHeights_[2]);
122 123
123 font_ = font_ptr(TTF_OpenFont("../res/softsquare.ttf", 45)); 124 font_ = font_ptr(TTF_OpenFont(Runtime::getResourcePath("softsquare.ttf").c_str(), 45));
124 if (!font_) { 125 if (!font_) {
125 throw ttf_error(); 126 throw ttf_error();
126 } 127 }
@@ -553,7 +554,7 @@ void Renderer::renderTitle(int num, double fade) {
553} 554}
554 555
555void Renderer::loadTextureFromFile(std::string_view path, texture_ptr& texture) { 556void Renderer::loadTextureFromFile(std::string_view path, texture_ptr& texture) {
556 surface_ptr pfs(IMG_Load(path.data())); 557 surface_ptr pfs(IMG_Load(Runtime::getResourcePath(path).c_str()));
557 if (!pfs) 558 if (!pfs)
558 { 559 {
559 throw img_error(); 560 throw img_error();