29 int idleAnim = animations->createAnimation(idleTexture, 1, 4, 0.5f);
33 animations->createAnimation(runTexture, 1, 6, 0.5f);
37 animations->createAnimation(deathTexture, 1, 6, 0.5f);
40 animations->setCurrentAnimation(idleAnim);
45 transform->setWorldPosition(200, 200);
46 transform->setWorldSize(40, 40);
49 auto input =
new Input();
52 auto health =
new Health(1000);
58 auto playerCollide =
new Collide();
59 playerCollide->setScreenSize(transform->getScreenSize().x * 0.4, transform->getScreenSize().y * 0.6);
60 playerCollide->setTransformOffset(transform->getScreenSize().x * 0.3, transform->getScreenSize().y * 0.45);
71 auto animation =
new Animation(sdl_texture);
72 animation->setPositionInSpriteMap(48, 48);
73 animation->setSizeInSpriteMap(48, 32);
74 animation->setRowsColsInSpriteMap(1, 3);
75 animation->setAnimationTime(0.4);
76 animation->setAutoPlay(
false);
77 animation->setFrame(0);
81 transform->setWorldPosition(240, 248);
82 transform->setWorldSize(25, 25);
88 auto input =
new Input();
91 auto bowCollide =
new Collide();
102 auto texture =
new Texture(sdl_texture);
104 if (abs(dx) >= abs(dy)) texture->setPositionInSpriteMap(32, 0);
105 else texture->setPositionInSpriteMap(16, 0);
106 if (dx < 0) texture->setFlipHorizontal(
true);
107 if (dy > 0) texture->setFlipVertical(
true);
109 texture->setSizeInSpriteMap(16, 16);
113 transform->setWorldPosition(225, 208);
114 transform->setWorldSize(15, 15);
120 auto arrowCollide =
new Collide();
121 arrowCollide->setScreenPosition(transform->getScreenPosition());
122 arrowCollide->setScreenSize(transform->getScreenSize());
133 auto texture =
new Animation(sdl_texture);
134 texture->setRowsColsInSpriteMap(1, 6);
135 texture->setAnimationTime(0.5);
139 transform->setWorldSize(40, 40);
140 transform->setWorldPosition(50, 50);
143 auto health =
new Health(200);
149 auto enemyCollide =
new Collide();
150 enemyCollide->setScreenSize(transform->getScreenSize().x * 0.4, transform->getScreenSize().y * 0.6);
151 enemyCollide->setTransformOffset(transform->getScreenSize().x * 0.3, transform->getScreenSize().y * 0.45);
165 auto texture =
new Animation(sdl_texture);
166 texture->setRowsColsInSpriteMap(row, col);
167 texture->setAnimationTime(animationTime);
168 std::cout << animationTime <<
"\n";
172 transform->setWorldSize(size_x, size_y);
173 transform->setWorldPosition(pos_x, pos_y);
176 auto health =
new Health(200);
182 auto enemyCollide =
new Collide();
183 enemyCollide->setScreenSize(transform->getScreenSize().x * 0.4, transform->getScreenSize().y * 0.6);
184 enemyCollide->setTransformOffset(transform->getScreenSize().x * 0.3, transform->getScreenSize().y * 0.45);
198 auto texture =
new Texture(sdl_texture);
199 texture->setSizeInSpriteMap(32, 32);
203 transform->setWorldSize(32, 32);
214 auto texture =
new Animation(sdl_texture);
215 texture->setRowsColsInSpriteMap(rc.
x, rc.
y);
216 texture->setSizeInSpriteMap(sprite_size.
x, sprite_size.
y);
217 texture->setPositionInSpriteMap(sprite_pos.
x, sprite_pos.
y);
221 transform->setWorldSize(size.
x, size.
y);
222 transform->setWorldPosition(pos.
x, pos.
y);
233 auto texture =
new Texture(sdl_texture);
235 texture->setSizeInSpriteMap(sprite_size.
x, sprite_size.
y);
236 texture->setPositionInSpriteMap(sprite_pos.
x, sprite_pos.
y);
240 transform->setWorldSize(size.
x, size.
y);
241 transform->setWorldPosition(pos.
x, pos.
y);
244 auto wallCollide =
new Collide();
245 wallCollide->setScreenSize(transform->getScreenSize());
257 auto texture =
new Texture(sdl_texture);
258 texture->setSizeInSpriteMap(sprite_size.
x, sprite_size.
y);
259 texture->setPositionInSpriteMap(sprite_pos.
x, sprite_pos.
y);
263 transform->setWorldSize(size.
x, size.
y);
264 transform->setWorldPosition(pos.
x, pos.
y);
267 auto tableCollide =
new Collide();
268 tableCollide->setScreenSize(transform->getScreenSize());
280 auto texture =
new Texture(sdl_texture);
281 texture->setPositionInSpriteMap(32, 64);
282 texture->setSizeInSpriteMap(16, 16);
286 transform->setWorldSize(32, 32);
289 auto keyCollide =
new Collide();
290 keyCollide->setScreenSize(transform->getScreenSize());
300 auto textureComponent =
new Texture(texture);
304 transform->setWorldSize(16, 16);
307 auto input =
new Input();
Defines the Animation class for handling sprite animations.
Component to handle animation of game objects. Derived from Texture.
Manages a collection of animations for a game entity, with functionality to play, pause,...
Component to handle collisions between game objects.
Script to manage collisions between game objects.
Script for managing the crosshair in the game.
Script to manage enemy artificial intelligence.
static GameObject * createEnemyWarriorCustom(std::string path, int row, int col, float animationTime, int pos_x, int pos_y, int size_x, int size_y)
Creates a customized enemy warrior object with specific texture and animations.
static GameObject * createArrow(int dx, int dy)
Creates an arrow object with specified dynamics.
static GameObject * createTableCustom(std::string path, Vec2 pos, Vec2 size, Vec2 sprite_size, Vec2 sprite_pos)
Creates a customized table object with specific texture.
static GameObject * createKey()
Creates a key object.
static GameObject * createEnemyWarrior()
Creates an enemy warrior object.
static GameObject * createTileCustom(std::string path, Vec2 pos, Vec2 size, Vec2 sprite_size, Vec2 sprite_pos, Vec2 rc)
Creates a customized tile object with specific texture.
static GameObject * createTile1()
Creates a basic tile object.
static GameObject * createCrosshair()
Creates a crosshair object.
static GameObject * createWallCustom(std::string path, Vec2 pos, Vec2 size, Vec2 sprite_size, Vec2 sprite_pos)
Creates a customized wall object with specific texture.
static GameObject * createPlayerTest()
Creates a test player object.
static GameObject * createBow()
Creates a bow object.
Core class representing an entity in the game world.
void addComponent(T *component)
Adds a component to the GameObject.
void addScript(T *script)
Adds a script to the GameObject.
A component for managing health of game objects.
Controls the movement of a projectile.
Controls the behavior of ranged weapons such as bows or guns.
SDL_Texture * loadTexture(std::string path)
Loads a texture from a specified file path.
static ResourceManager & getInstance()
Retrieves the singleton instance of ResourceManager.
Component for handling textures in the game engine.
Defines the Collide class, a component for managing collision detection and response.
Defines the Health class, a component for managing the health of game objects.
Manages resources such as textures, fonts, and potentially sounds for a game engine.
A structure to represent 2D vectors.
float y
Y coordinate of the vector.
float x
X coordinate of the vector.
Defines the Texture component for managing textures within the Game Engine, encapsulating SDL texture...