summary refs log tree commit diff stats
path: root/src/renderer.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-12 12:09:58 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-12 12:09:58 -0500
commitbe9ccb73bc20b03f62c77f5d529602a10ef4eda9 (patch)
tree6f88a9b780a75e52b2f04b6f61167f4ef46590a7 /src/renderer.cpp
parentc1a88a064a0cddbc1df2e716ef2102d22bbf681b (diff)
downloadether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.tar.gz
ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.tar.bz2
ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.zip
player has a sprite now thanks to world of solaria
Diffstat (limited to 'src/renderer.cpp')
-rw-r--r--src/renderer.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/renderer.cpp b/src/renderer.cpp index 2dac07e..0aaa14a 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -110,6 +110,18 @@ Renderer::Renderer()
110 110
111 SDL_SetRenderDrawColor(ren_.get(), 100, 100, 100, 255); 111 SDL_SetRenderDrawColor(ren_.get(), 100, 100, 100, 255);
112 SDL_RenderFillRect(ren_.get(), nullptr); 112 SDL_RenderFillRect(ren_.get(), nullptr);
113
114 {
115 surface_ptr pfs(IMG_Load("../res/player.png"));
116 if (!pfs)
117 {
118 throw img_error();
119 }
120
121 playerSheet_ = texture_ptr(SDL_CreateTextureFromSurface(ren_.get(), pfs.get()));
122 }
123
124 SDL_SetTextureBlendMode(playerSheet_.get(), SDL_BLENDMODE_BLEND);
113} 125}
114 126
115void Renderer::render( 127void Renderer::render(
@@ -140,10 +152,7 @@ void Renderer::render(
140 { 152 {
141 bool draw = true; 153 bool draw = true;
142 154
143 if ((game.player_x == x && game.player_y == y) && game.renderPlayer) 155 if (!game.map.at(x,y).lit)
144 {
145 SDL_SetRenderDrawColor(ren_.get(), 255, 255, 0, 255);
146 } else if (!game.map.at(x,y).lit)
147 { 156 {
148 if (drawDark) 157 if (drawDark)
149 { 158 {
@@ -191,6 +200,11 @@ void Renderer::render(
191 TILE_HEIGHT}; 200 TILE_HEIGHT};
192 201
193 SDL_RenderFillRect(ren_.get(), &rect); 202 SDL_RenderFillRect(ren_.get(), &rect);
203
204 if ((game.player_x == x && game.player_y == y) && game.renderPlayer)
205 {
206 SDL_RenderCopy(ren_.get(), playerSheet_.get(), &game.playerAnim.getRenderRect(), &rect);
207 }
194 } 208 }
195 } 209 }
196 } 210 }