mirror of
https://github.com/Relintai/programming_tutorials.git
synced 2025-05-11 22:52:11 +02:00
Cleaned up the remaining 3 txts.
This commit is contained in:
parent
4d1e74b62c
commit
22d5415c86
@ -3,204 +3,232 @@
|
|||||||
|---------------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------------|
|
||||||
| class Texture |
|
| class Texture |
|
||||||
|---------------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------------|
|
||||||
| + Color get_color_mod() const; |
|
| + Color get_color_mod() const |
|
||||||
| + void set_color_mod(const Color &color); |
|
| + void set_color_mod(const Color &color) |
|
||||||
| |
|
| |
|
||||||
| + SDL_BlendMode get_blend_mode() const; |
|
| + SDL_BlendMode get_blend_mode() const |
|
||||||
| + void set_blend_mode(const SDL_BlendMode blend_mode); |
|
| + void set_blend_mode(const SDL_BlendMode blend_mode) |
|
||||||
| |
|
| |
|
||||||
| + SDL_ScaleMode get_texture_scale_mode() const; |
|
| + SDL_ScaleMode get_texture_scale_mode() const |
|
||||||
| + void set_texture_scale_mode(const SDL_ScaleMode scale_mode); |
|
| + void set_texture_scale_mode(const SDL_ScaleMode scale_mode) |
|
||||||
| |
|
| |
|
||||||
| + Image *get_image(); |
|
| + Image *get_image() |
|
||||||
| + void set_image(Image *image); |
|
| + void set_image(Image *image) |
|
||||||
| |
|
| |
|
||||||
| + int get_width() const; |
|
| + int get_width() const |
|
||||||
| + int get_height() const; |
|
| + int get_height() const |
|
||||||
| + Uint32 get_format() const; |
|
| + Uint32 get_format() const |
|
||||||
| + int get_access() const; |
|
| + int get_access() const |
|
||||||
| |
|
| |
|
||||||
| + void create(const int access, const int w, const int h); |
|
| + void create(const int access, const int w, const int h) |
|
||||||
| + void refresh(); |
|
| + void refresh() |
|
||||||
| + void free(); |
|
| + void free() |
|
||||||
| |
|
| |
|
||||||
| + SDL_Texture *get_texture(); |
|
| + SDL_Texture *get_texture() |
|
||||||
| + SDL_Texture *get_texture() const; |
|
| + SDL_Texture *get_texture() const |
|
||||||
| |
|
| |
|
||||||
| + bool is_render_target(); |
|
| + bool is_render_target() |
|
||||||
| |
|
| |
|
||||||
| + Texture(); |
|
| + Texture() |
|
||||||
| + Texture(Image *image); |
|
| + Texture(Image *image) |
|
||||||
| + virtual ~Texture(); |
|
| + virtual ~Texture() |
|
||||||
| |
|
| |
|
||||||
| - Image *_image; |
|
| - Image *_image |
|
||||||
| - SDL_Texture *_texture; |
|
| - SDL_Texture *_texture |
|
||||||
|---------------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------------|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "texture.h"
|
get_color_mod:
|
||||||
|
Uint8 r
|
||||||
|
Uint8 g
|
||||||
|
Uint8 b
|
||||||
|
Uint8 a
|
||||||
|
|
||||||
#include "renderer.h"
|
SDL_GetTextureColorMod(_texture, &r, &g, &b)
|
||||||
|
SDL_GetTextureAlphaMod(_texture, &a)
|
||||||
|
|
||||||
Color Texture::get_color_mod() const {
|
return Color(r, g, b, a)
|
||||||
Uint8 r;
|
|
||||||
Uint8 g;
|
|
||||||
Uint8 b;
|
|
||||||
Uint8 a;
|
|
||||||
|
|
||||||
SDL_GetTextureColorMod(_texture, &r, &g, &b);
|
------------------------------------------------------------------------------------------
|
||||||
SDL_GetTextureAlphaMod(_texture, &a);
|
|
||||||
|
|
||||||
return Color(r, g, b, a);
|
set_color_mod:
|
||||||
}
|
SDL_SetTextureColorMod(_texture, color.r, color.g, color.b)
|
||||||
void Texture::set_color_mod(const Color &color) {
|
SDL_SetTextureAlphaMod(_texture, color.a)
|
||||||
SDL_SetTextureColorMod(_texture, color.r, color.g, color.b);
|
|
||||||
SDL_SetTextureAlphaMod(_texture, color.a);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_BlendMode Texture::get_blend_mode() const {
|
------------------------------------------------------------------------------------------
|
||||||
SDL_BlendMode blendMode;
|
|
||||||
|
|
||||||
SDL_GetTextureBlendMode(_texture, &blendMode);
|
get_blend_mode:
|
||||||
|
SDL_BlendMode blendMode
|
||||||
|
|
||||||
return blendMode;
|
SDL_GetTextureBlendMode(_texture, &blendMode)
|
||||||
}
|
|
||||||
void Texture::set_blend_mode(const SDL_BlendMode blend_mode) {
|
|
||||||
SDL_SetTextureBlendMode(_texture, blend_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_ScaleMode Texture::get_texture_scale_mode() const {
|
return blendMode
|
||||||
SDL_ScaleMode scale_mode;
|
|
||||||
|
|
||||||
SDL_GetTextureScaleMode(_texture, &scale_mode);
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return scale_mode;
|
set_blend_mode:
|
||||||
}
|
SDL_SetTextureBlendMode(_texture, blend_mode)
|
||||||
void Texture::set_texture_scale_mode(const SDL_ScaleMode scale_mode) {
|
|
||||||
SDL_SetTextureScaleMode(_texture, scale_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
Image *Texture::get_image() {
|
------------------------------------------------------------------------------------------
|
||||||
return _image;
|
|
||||||
}
|
|
||||||
void Texture::set_image(Image *image) {
|
|
||||||
if (_texture) {
|
|
||||||
free();
|
|
||||||
}
|
|
||||||
|
|
||||||
_image = image;
|
get_texture_scale_mode:
|
||||||
|
SDL_ScaleMode scale_mode
|
||||||
|
|
||||||
refresh();
|
SDL_GetTextureScaleMode(_texture, &scale_mode)
|
||||||
}
|
|
||||||
|
|
||||||
int Texture::get_width() const {
|
return scale_mode
|
||||||
Uint32 format;
|
|
||||||
int access;
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
|
|
||||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h)) {
|
------------------------------------------------------------------------------------------
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return w;
|
set_texture_scale_mode:
|
||||||
}
|
SDL_SetTextureScaleMode(_texture, scale_mode)
|
||||||
int Texture::get_height() const {
|
|
||||||
Uint32 format;
|
|
||||||
int access;
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
|
|
||||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h)) {
|
------------------------------------------------------------------------------------------
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return h;
|
get_image:
|
||||||
}
|
return _image
|
||||||
Uint32 Texture::get_format() const {
|
|
||||||
Uint32 format;
|
|
||||||
int access;
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
|
|
||||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h)) {
|
------------------------------------------------------------------------------------------
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return format;
|
set_image:
|
||||||
}
|
if (_texture)
|
||||||
int Texture::get_access() const {
|
free()
|
||||||
Uint32 format;
|
|
||||||
int access;
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
|
|
||||||
if (SDL_QueryTexture(_texture, &format, &access, &w, &h)) {
|
_image = image
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return access;
|
refresh()
|
||||||
}
|
|
||||||
|
|
||||||
void Texture::create(int access, int w, int h) {
|
------------------------------------------------------------------------------------------
|
||||||
if (_texture) {
|
|
||||||
free();
|
|
||||||
}
|
|
||||||
|
|
||||||
_image = nullptr;
|
get_width:
|
||||||
|
Uint32 format
|
||||||
|
int access
|
||||||
|
int w
|
||||||
|
int h
|
||||||
|
|
||||||
_texture = SDL_CreateTexture(Renderer::get_singleton()->get_renderer(), SDL_PIXELFORMAT_RGBA8888, access, w, h);
|
if (SDL_QueryTexture(_texture, &format, &access, &w, &h))
|
||||||
}
|
return 0
|
||||||
void Texture::refresh() {
|
|
||||||
if (_image == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_image->get_surface() == nullptr) {
|
return w
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_texture) {
|
------------------------------------------------------------------------------------------
|
||||||
free();
|
|
||||||
}
|
|
||||||
|
|
||||||
_texture = SDL_CreateTextureFromSurface(Renderer::get_singleton()->get_renderer(), _image->get_surface());
|
get_height:
|
||||||
}
|
Uint32 format
|
||||||
void Texture::free() {
|
int access
|
||||||
if (_texture) {
|
int w
|
||||||
SDL_DestroyTexture(_texture);
|
int h
|
||||||
|
|
||||||
_texture = nullptr;
|
if (SDL_QueryTexture(_texture, &format, &access, &w, &h))
|
||||||
}
|
return 0
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Texture *Texture::get_texture() {
|
return h
|
||||||
return _texture;
|
|
||||||
}
|
|
||||||
SDL_Texture *Texture::get_texture() const {
|
|
||||||
return _texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Texture::is_render_target() {
|
------------------------------------------------------------------------------------------
|
||||||
if (_texture == Renderer::get_singleton()->get_render_target()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
get_format:
|
||||||
}
|
Uint32 format
|
||||||
|
int access
|
||||||
|
int w
|
||||||
|
int h
|
||||||
|
|
||||||
Texture::Texture() {
|
if (SDL_QueryTexture(_texture, &format, &access, &w, &h))
|
||||||
_image = nullptr;
|
return 0
|
||||||
_texture = nullptr;
|
|
||||||
}
|
|
||||||
Texture::Texture(Image *image) {
|
|
||||||
_image = nullptr;
|
|
||||||
_texture = nullptr;
|
|
||||||
|
|
||||||
set_image(image);
|
return format
|
||||||
}
|
|
||||||
Texture::~Texture() {
|
------------------------------------------------------------------------------------------
|
||||||
if (_texture) {
|
|
||||||
free();
|
get_access:
|
||||||
}
|
Uint32 format
|
||||||
}
|
int access
|
||||||
|
int w
|
||||||
|
int h
|
||||||
|
|
||||||
|
if (SDL_QueryTexture(_texture, &format, &access, &w, &h))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
return access
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
create:
|
||||||
|
if (_texture)
|
||||||
|
free()
|
||||||
|
|
||||||
|
|
||||||
|
_image = nullptr
|
||||||
|
|
||||||
|
_texture = SDL_CreateTexture(Renderer::get_singleton()->get_renderer(), SDL_PIXELFORMAT_RGBA8888, access, w, h)
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
refresh:
|
||||||
|
if (_image == nullptr)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if (_image->get_surface() == nullptr)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if (_texture)
|
||||||
|
free()
|
||||||
|
|
||||||
|
|
||||||
|
_texture = SDL_CreateTextureFromSurface(Renderer::get_singleton()->get_renderer(), _image->get_surface())
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
free:
|
||||||
|
if (_texture)
|
||||||
|
SDL_DestroyTexture(_texture)
|
||||||
|
|
||||||
|
_texture = nullptr
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_texture():
|
||||||
|
return _texture
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_texture() const:
|
||||||
|
return _texture
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
is_render_target:
|
||||||
|
if (_texture == Renderer::get_singleton()->get_render_target())
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Texture():
|
||||||
|
_image = nullptr
|
||||||
|
_texture = nullptr
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Texture(Image *image):
|
||||||
|
_image = nullptr
|
||||||
|
_texture = nullptr
|
||||||
|
|
||||||
|
set_image(image)
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
~Texture:
|
||||||
|
if (_texture)
|
||||||
|
free()
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
| |
|
| |
|
||||||
| + Sprite(Texture *texture, const float x, const float y, |
|
| + Sprite(Texture *texture, const float x, const float y, |
|
||||||
| const float w, const float h, const double angle = 0) |
|
| const float w, const float h, const double angle = 0) |
|
||||||
| + virtual ~Sprite() |
|
| + virtual ~Sprite() | -> Üres
|
||||||
| |
|
| |
|
||||||
| - Rect2 _texture_clip_rect |
|
| - Rect2 _texture_clip_rect |
|
||||||
| - Rect2 _transform |
|
| - Rect2 _transform |
|
||||||
@ -72,107 +72,172 @@
|
|||||||
| - Texture *_texture |
|
| - Texture *_texture |
|
||||||
|---------------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------------|
|
||||||
|
|
||||||
#include "sprite.h"
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "renderer.h"
|
get_texture_clip_rect:
|
||||||
|
|
||||||
Rect2 Sprite::get_texture_clip_rect() const {
|
|
||||||
return _texture_clip_rect
|
return _texture_clip_rect
|
||||||
}
|
|
||||||
void Sprite::set_texture_clip_rect(const Rect2 &rect) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_texture_clip_rect:
|
||||||
_texture_clip_rect = rect
|
_texture_clip_rect = rect
|
||||||
}
|
|
||||||
|
|
||||||
Rect2 Sprite::get_transform() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_transform:
|
||||||
return _transform
|
return _transform
|
||||||
}
|
|
||||||
void Sprite::set_transform(const Rect2 &rect) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_transform:
|
||||||
_transform = rect
|
_transform = rect
|
||||||
}
|
|
||||||
|
|
||||||
float Sprite::get_x() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_x:
|
||||||
return _transform.x
|
return _transform.x
|
||||||
}
|
|
||||||
void Sprite::set_x(const float val) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_x:
|
||||||
_transform.x = val
|
_transform.x = val
|
||||||
}
|
|
||||||
|
|
||||||
float Sprite::get_y() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_y:
|
||||||
return _transform.y
|
return _transform.y
|
||||||
}
|
|
||||||
void Sprite::set_y(const float val) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_y:
|
||||||
_transform.y = val
|
_transform.y = val
|
||||||
}
|
|
||||||
|
|
||||||
float Sprite::get_w() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_w:
|
||||||
return _transform.w
|
return _transform.w
|
||||||
}
|
|
||||||
void Sprite::set_w(const float val) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_w:
|
||||||
_transform.w = val
|
_transform.w = val
|
||||||
}
|
|
||||||
|
|
||||||
float Sprite::get_h() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_h:
|
||||||
return _transform.h
|
return _transform.h
|
||||||
}
|
|
||||||
void Sprite::set_h(const float val) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_h:
|
||||||
_transform.h = val
|
_transform.h = val
|
||||||
}
|
|
||||||
|
|
||||||
double Sprite::get_angle() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_angle:
|
||||||
return _angle
|
return _angle
|
||||||
}
|
|
||||||
void Sprite::set_angle(const double val) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_angle:
|
||||||
_angle = val
|
_angle = val
|
||||||
}
|
|
||||||
|
|
||||||
float Sprite::get_anchor_x() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_anchor_x:
|
||||||
return _anchor_x
|
return _anchor_x
|
||||||
}
|
|
||||||
void Sprite::set_anchor_x(const float val) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_anchor_x:
|
||||||
_anchor_x = val
|
_anchor_x = val
|
||||||
}
|
|
||||||
|
|
||||||
float Sprite::get_anchor_y() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_anchor_y:
|
||||||
return _anchor_y
|
return _anchor_y
|
||||||
}
|
|
||||||
void Sprite::set_anchor_y(const float val) {
|
|
||||||
_anchor_y = val
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sprite::set_anchor(const float x, const float y) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_anchor_y:
|
||||||
|
_anchor_y = val
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_anchor:
|
||||||
_anchor_x = x
|
_anchor_x = x
|
||||||
_anchor_y = y
|
_anchor_y = y
|
||||||
}
|
|
||||||
|
|
||||||
SDL_RendererFlip Sprite::get_flip() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_flip:
|
||||||
return _flip
|
return _flip
|
||||||
}
|
|
||||||
void Sprite::set_flip(const SDL_RendererFlip val) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_flip:
|
||||||
_flip = val
|
_flip = val
|
||||||
}
|
|
||||||
|
|
||||||
Color Sprite::get_color_mod() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_color_mod:
|
||||||
return _color_mod
|
return _color_mod
|
||||||
}
|
|
||||||
void Sprite::set_color_mod(const Color &color) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_color_mod:
|
||||||
_color_mod = color
|
_color_mod = color
|
||||||
}
|
|
||||||
|
|
||||||
Texture *Sprite::get_texture() {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_texture():
|
||||||
return _texture
|
return _texture
|
||||||
}
|
|
||||||
Texture *Sprite::get_texture() const {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_texture() const:
|
||||||
return _texture
|
return _texture
|
||||||
}
|
|
||||||
void Sprite::set_texture(Texture *texture) {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set_texture:
|
||||||
_texture = texture
|
_texture = texture
|
||||||
}
|
|
||||||
|
|
||||||
void Sprite::draw() {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
draw:
|
||||||
Renderer::get_singleton()->draw_sprite(this)
|
Renderer::get_singleton()->draw_sprite(this)
|
||||||
}
|
|
||||||
|
|
||||||
Sprite::Sprite() {
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Sprite():
|
||||||
_angle = 0
|
_angle = 0
|
||||||
|
|
||||||
_anchor_x = 0
|
_anchor_x = 0
|
||||||
@ -183,8 +248,10 @@ Sprite::Sprite() {
|
|||||||
_texture = nullptr
|
_texture = nullptr
|
||||||
|
|
||||||
_color_mod = Color(255, 255, 255, 255)
|
_color_mod = Color(255, 255, 255, 255)
|
||||||
}
|
|
||||||
Sprite::Sprite(Texture *texture) {
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Sprite(Texture *texture):
|
||||||
_angle = 0
|
_angle = 0
|
||||||
|
|
||||||
_anchor_x = 0
|
_anchor_x = 0
|
||||||
@ -194,18 +261,19 @@ Sprite::Sprite(Texture *texture) {
|
|||||||
|
|
||||||
_texture = texture
|
_texture = texture
|
||||||
|
|
||||||
if (_texture != nullptr) {
|
if (_texture != nullptr):
|
||||||
_texture_clip_rect.w = texture->get_width()
|
_texture_clip_rect.w = texture->get_width()
|
||||||
_texture_clip_rect.h = texture->get_height()
|
_texture_clip_rect.h = texture->get_height()
|
||||||
|
|
||||||
_transform.w = texture->get_width()
|
_transform.w = texture->get_width()
|
||||||
_transform.h = texture->get_height()
|
_transform.h = texture->get_height()
|
||||||
}
|
|
||||||
|
|
||||||
_color_mod = Color(255, 255, 255, 255)
|
_color_mod = Color(255, 255, 255, 255)
|
||||||
}
|
|
||||||
|
|
||||||
Sprite::Sprite(Texture *texture, const Color &color_mod) {
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Sprite(Texture *texture, const Color &color_mod):
|
||||||
_angle = 0
|
_angle = 0
|
||||||
|
|
||||||
_anchor_x = 0
|
_anchor_x = 0
|
||||||
@ -215,18 +283,19 @@ Sprite::Sprite(Texture *texture, const Color &color_mod) {
|
|||||||
|
|
||||||
_texture = texture
|
_texture = texture
|
||||||
|
|
||||||
if (_texture != nullptr) {
|
if (_texture != nullptr):
|
||||||
_texture_clip_rect.w = texture->get_width()
|
_texture_clip_rect.w = texture->get_width()
|
||||||
_texture_clip_rect.h = texture->get_height()
|
_texture_clip_rect.h = texture->get_height()
|
||||||
|
|
||||||
_transform.w = texture->get_width()
|
_transform.w = texture->get_width()
|
||||||
_transform.h = texture->get_height()
|
_transform.h = texture->get_height()
|
||||||
}
|
|
||||||
|
|
||||||
_color_mod = color_mod
|
_color_mod = color_mod
|
||||||
}
|
|
||||||
|
|
||||||
Sprite::Sprite(Texture *texture, const float x, const float y, const double angle) {
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Sprite(Texture *texture, const float x, const float y, const double angle):
|
||||||
_angle = angle
|
_angle = angle
|
||||||
|
|
||||||
_anchor_x = 0
|
_anchor_x = 0
|
||||||
@ -239,17 +308,19 @@ Sprite::Sprite(Texture *texture, const float x, const float y, const double angl
|
|||||||
_transform.x = x
|
_transform.x = x
|
||||||
_transform.y = y
|
_transform.y = y
|
||||||
|
|
||||||
if (_texture != nullptr) {
|
if (_texture != nullptr):
|
||||||
_texture_clip_rect.w = texture->get_width()
|
_texture_clip_rect.w = texture->get_width()
|
||||||
_texture_clip_rect.h = texture->get_height()
|
_texture_clip_rect.h = texture->get_height()
|
||||||
|
|
||||||
_transform.w = texture->get_width()
|
_transform.w = texture->get_width()
|
||||||
_transform.h = texture->get_height()
|
_transform.h = texture->get_height()
|
||||||
}
|
|
||||||
|
|
||||||
_color_mod = Color(255, 255, 255, 255)
|
_color_mod = Color(255, 255, 255, 255)
|
||||||
}
|
|
||||||
Sprite::Sprite(Texture *texture, const float x, const float y, const Rect2 &texture_clip_rect, const double angle) {
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Sprite(Texture *texture, const float x, const float y, const Rect2 &texture_clip_rect, const double angle):
|
||||||
_angle = angle
|
_angle = angle
|
||||||
|
|
||||||
_anchor_x = 0
|
_anchor_x = 0
|
||||||
@ -262,16 +333,18 @@ Sprite::Sprite(Texture *texture, const float x, const float y, const Rect2 &text
|
|||||||
_transform.x = x
|
_transform.x = x
|
||||||
_transform.y = y
|
_transform.y = y
|
||||||
|
|
||||||
if (_texture != nullptr) {
|
if (_texture != nullptr):
|
||||||
_transform.w = texture->get_width()
|
_transform.w = texture->get_width()
|
||||||
_transform.h = texture->get_height()
|
_transform.h = texture->get_height()
|
||||||
}
|
|
||||||
|
|
||||||
_texture_clip_rect = texture_clip_rect
|
_texture_clip_rect = texture_clip_rect
|
||||||
|
|
||||||
_color_mod = Color(255, 255, 255, 255)
|
_color_mod = Color(255, 255, 255, 255)
|
||||||
}
|
|
||||||
Sprite::Sprite(Texture *texture, const Rect2 &transform, const Rect2 &texture_clip_rect, const double angle) {
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Sprite(Texture *texture, const Rect2 &transform, const Rect2 &texture_clip_rect, const double angle):
|
||||||
_angle = angle
|
_angle = angle
|
||||||
|
|
||||||
_anchor_x = 0
|
_anchor_x = 0
|
||||||
@ -285,8 +358,10 @@ Sprite::Sprite(Texture *texture, const Rect2 &transform, const Rect2 &texture_cl
|
|||||||
_texture_clip_rect = texture_clip_rect
|
_texture_clip_rect = texture_clip_rect
|
||||||
|
|
||||||
_color_mod = Color(255, 255, 255, 255)
|
_color_mod = Color(255, 255, 255, 255)
|
||||||
}
|
|
||||||
Sprite::Sprite(Texture *texture, const float x, const float y, const float w, const float h, const double angle) {
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Sprite(Texture *texture, const float x, const float y, const float w, const float h, const double angle):
|
||||||
_angle = angle
|
_angle = angle
|
||||||
|
|
||||||
_anchor_x = 0
|
_anchor_x = 0
|
||||||
@ -301,12 +376,11 @@ Sprite::Sprite(Texture *texture, const float x, const float y, const float w, co
|
|||||||
_transform.w = w
|
_transform.w = w
|
||||||
_transform.h = h
|
_transform.h = h
|
||||||
|
|
||||||
if (_texture != nullptr) {
|
if (_texture != nullptr):
|
||||||
_texture_clip_rect.w = texture->get_width()
|
_texture_clip_rect.w = texture->get_width()
|
||||||
_texture_clip_rect.h = texture->get_height()
|
_texture_clip_rect.h = texture->get_height()
|
||||||
}
|
|
||||||
|
|
||||||
_color_mod = Color(255, 255, 255, 255)
|
_color_mod = Color(255, 255, 255, 255)
|
||||||
}
|
|
||||||
Sprite::~Sprite() {
|
------------------------------------------------------------------------------------------
|
||||||
}
|
|
||||||
|
@ -2,41 +2,37 @@
|
|||||||
|---------------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------------|
|
||||||
| class Camera |
|
| class Camera |
|
||||||
|---------------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------------|
|
||||||
| + void bind(); |
|
| + void bind() |
|
||||||
| |
|
| |
|
||||||
| + Camera(); |
|
| + Camera() |
|
||||||
| + virtual ~Camera(); |
|
| + virtual ~Camera() | -> Üres
|
||||||
| |
|
| |
|
||||||
| + bool integer_scaling; |
|
| + bool integer_scaling |
|
||||||
| + float scale_w; |
|
| + float scale_w |
|
||||||
| + float scale_h; |
|
| + float scale_h |
|
||||||
| + viewport; |
|
| + viewport |
|
||||||
| + Rect2 clip_rect; |
|
| + Rect2 clip_rect |
|
||||||
|---------------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------------|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "camera.h"
|
bind:
|
||||||
|
Renderer::get_singleton()->set_integer_scaling(integer_scaling)
|
||||||
|
|
||||||
#include "renderer.h"
|
Renderer::get_singleton()->set_scale(scale_w, scale_h)
|
||||||
|
|
||||||
void Camera::bind() {
|
Renderer::get_singleton()->set_viewport(viewport)
|
||||||
Renderer::get_singleton()->set_integer_scaling(integer_scaling);
|
Renderer::get_singleton()->set_clip_rect(&clip_rect)
|
||||||
|
|
||||||
Renderer::get_singleton()->set_scale(scale_w, scale_h);
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Renderer::get_singleton()->set_viewport(viewport);
|
Camera:
|
||||||
Renderer::get_singleton()->set_clip_rect(&clip_rect);
|
integer_scaling = false
|
||||||
}
|
|
||||||
|
|
||||||
Camera::Camera() {
|
scale_w = 1
|
||||||
integer_scaling = false;
|
scale_h = 1
|
||||||
|
|
||||||
scale_w = 1;
|
viewport = Renderer::get_singleton()->get_viewport()
|
||||||
scale_h = 1;
|
clip_rect = Renderer::get_singleton()->get_clip_rect()
|
||||||
|
|
||||||
viewport = Renderer::get_singleton()->get_viewport();
|
|
||||||
clip_rect = Renderer::get_singleton()->get_clip_rect();
|
|
||||||
}
|
|
||||||
Camera::~Camera() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user