Корабът Радецки - Eight ball pool v 1.0
The documnetation for our physics-themed project.
sprite.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "drawable.hpp"
4#include <iostream>
5#include <raylib.h>
6
8{
9protected:
11 Texture2D sprite_texture;
14
15public:
16 Sprite(const char* texture_file_name, Vector2 initial_position, float scale = 1.0f, float rotation = 0.0f) : Drawable()
17 {
18 sprite_position = initial_position;
19 sprite_texture = LoadTexture(texture_file_name);
20 sprite_rotation = rotation;
21
22 if (sprite_texture.id == 0)
23 {
24 std::cout << "ERROR: Failed loading texture (" << texture_file_name << "), halting process" << std::endl;
25 exit(-1);
26 }
27
28 sprite_scale_factor = scale;
29 }
30
31 virtual ~Sprite()
32 {
33 UnloadTexture(sprite_texture);
34 }
35
41 void SetScale(float scale);
42
48 void SetPosition(Vector2 position);
49
55 void SetRotation(float rotation);
56
62 Vector2 GetPosition();
63
69 float GetWidth();
70
76 float GetHeight();
77
83 float GetRotation();
84
88 void Draw() override;
89};
Definition: drawable.hpp:13
Drawable()
Sets the sprites' IDs.
Definition: drawable.cpp:8
Definition: sprite.hpp:8
void SetPosition(Vector2 position)
Sets the position of the sprites.
Definition: sprite.cpp:8
void Draw() override
Draws the sprites.
Definition: sprite.cpp:39
Vector2 sprite_position
Definition: sprite.hpp:10
float GetWidth()
Gets the width of the sprites.
Definition: sprite.cpp:24
void SetScale(float scale)
Sets the scale of the sprites.
Definition: sprite.cpp:3
void SetRotation(float rotation)
Sets the rotation of the sprites.
Definition: sprite.cpp:14
float sprite_scale_factor
Definition: sprite.hpp:12
float GetHeight()
Gets the height of the sprites.
Definition: sprite.cpp:29
float GetRotation()
Gets the exact rotation of the sprites.
Definition: sprite.cpp:34
float sprite_rotation
Definition: sprite.hpp:13
Vector2 GetPosition()
Gets the position of the sprites.
Definition: sprite.cpp:19
Sprite(const char *texture_file_name, Vector2 initial_position, float scale=1.0f, float rotation=0.0f)
Definition: sprite.hpp:16
Texture2D sprite_texture
Definition: sprite.hpp:11
virtual ~Sprite()
Definition: sprite.hpp:31