void ttexture::set_flop(bool flop) { if (flop) { flip_ = SDL_RendererFlip(flip_ | SDL_FLIP_VERTICAL); } else { flip_ = SDL_RendererFlip(flip_ & ~SDL_FLIP_VERTICAL); } }
void ttexture::set_flip(bool flip) { if (flip) { flip_ = SDL_RendererFlip(flip_ | SDL_FLIP_HORIZONTAL); } else { flip_ = SDL_RendererFlip(flip_ & ~SDL_FLIP_HORIZONTAL); } }
void Image::DrawImage(int x, int y, int frame, double rotation, SDL_Renderer *destination) { SDL_Rect offset; offset.x = x-centerX; offset.y = y-centerY; offset.w = cut[frame].w; offset.h = cut[frame].h; SDL_Point point{centerX, centerY}; // SDL_BlitSurface(picture, &cut[0], destination, &offset); SDL_RenderCopyEx(destination, picture, &cut[frame], &offset, rotation, &point, SDL_RendererFlip()); }
void Player::Render() const { SDL_Rect s = { killed ? WIDTH : 0, 0, WIDTH, HEIGHT }; SDL_Rect d = { int(x) * SCREEN_MUL, int(y) * SCREEN_MUL, WIDTH * SCREEN_MUL, HEIGHT * SCREEN_MUL }; auto flag = SDL_RendererFlip( (flip ? SDL_FLIP_VERTICAL : 0) | (left ? SDL_FLIP_HORIZONTAL : 0)); if (killed) SDL_SetTextureColorMod(texture.get(), 255, 0, 0); else SDL_SetTextureColorMod(texture.get(), 100, 255, 100); SDL_RenderCopyEx(renderer, texture.get(), &s, &d, 0, nullptr, flag); if (x > Level::WIDTH*8-WIDTH && level.Neighbor(RIGHT) == level.Name()) { d.x -= Level::WIDTH*8*SCREEN_MUL; SDL_RenderCopyEx(renderer, texture.get(), &s, &d, 0, nullptr, flag); } if (x < 0 && level.Neighbor(LEFT) == level.Name()) { d.x += Level::WIDTH*8*SCREEN_MUL; SDL_RenderCopyEx(renderer, texture.get(), &s, &d, 0, nullptr, flag); } if (y > Level::HEIGHT*8-HEIGHT && level.Neighbor(DOWN) == level.Name()) { d.y -= Level::HEIGHT*8*SCREEN_MUL; SDL_RenderCopyEx(renderer, texture.get(), &s, &d, 0, nullptr, flag); } if (y < 0 && level.Neighbor(UP) == level.Name()) { d.y += Level::HEIGHT*8*SCREEN_MUL; SDL_RenderCopyEx(renderer, texture.get(), &s, &d, 0, nullptr, flag); } }
void Texture::Render(SDL_Renderer *const Renderer, const int &x, const int &y) { return Render(Renderer, x, y, NULL, 0.0, NULL, SDL_RendererFlip()); }
void Texture::Render(SDL_Renderer *const Renderer, const int &x, const int &y, SDL_Rect *const Clip, const double &Angle, SDL_Point *const Centre) { return Render(Renderer, x, y, Clip, Angle, Centre, SDL_RendererFlip()); }
inline void FlipXY() { //Platform-Dependant sdlFlip = SDL_RendererFlip(SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL); }