diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-27 11:56:48 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-27 11:56:48 +0100 |
commit | 2b35e8f51a3536b62ea21dc82deec1e3b65568f6 (patch) | |
tree | 8245ca8f015634e0aca01e83822b02c869419b5c /src/crepe/facade/SDLContext.cpp | |
parent | 7f66cd4a9b609f6bf36d005f5e38ef2a57d1c0d3 (diff) |
make format and offset for the cameara relative from the transform gameobject
Diffstat (limited to 'src/crepe/facade/SDLContext.cpp')
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 72542e8..4887d35 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -40,7 +40,7 @@ SDLContext::SDLContext() { auto & cfg = Config::get_instance().win_set; SDL_Window * tmp_window = SDL_CreateWindow("Crepe Game Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - cfg.def_size.x,cfg.def_size.y, 0); + cfg.def_size.x, cfg.def_size.y, 0); if (!tmp_window) { throw runtime_error(format("SDLContext: SDL_Window error: {}", SDL_GetError())); } @@ -134,7 +134,7 @@ void SDLContext::draw_particle(const Sprite & sprite, const vec2 & pos, const do | (SDL_FLIP_VERTICAL * sprite.flip.flip_y)); SDL_Rect srcrect = this->get_src_rect(sprite); - SDL_Rect dstrect = this->get_dst_rect(sprite, pos, cam , img_scale); + SDL_Rect dstrect = this->get_dst_rect(sprite, pos, cam, img_scale); SDL_RenderCopyEx(this->game_renderer.get(), sprite.sprite_image.texture.get(), &srcrect, &dstrect, angle, NULL, render_flip); @@ -147,8 +147,7 @@ void SDLContext::draw(const Sprite & sprite, const Transform & transform, const | (SDL_FLIP_VERTICAL * sprite.flip.flip_y)); SDL_Rect srcrect = this->get_src_rect(sprite); - SDL_Rect dstrect - = this->get_dst_rect(sprite, transform.position, cam, transform.scale); + SDL_Rect dstrect = this->get_dst_rect(sprite, transform.position, cam, transform.scale); SDL_RenderCopyEx(this->game_renderer.get(), sprite.sprite_image.texture.get(), &srcrect, &dstrect, transform.rotation, NULL, render_flip); @@ -157,9 +156,9 @@ void SDLContext::draw(const Sprite & sprite, const Transform & transform, const void SDLContext::set_camera(const Camera & cam) { // resize window - int w,h; + int w, h; SDL_GetWindowSize(this->game_window.get(), &w, &h); - if ( w != cam.screen.x || h != cam.screen.y) { + if (w != cam.screen.x || h != cam.screen.y) { SDL_SetWindowSize(this->game_window.get(), cam.screen.x, cam.screen.y); } |