r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
projectileManager.cpp
Go to the documentation of this file.
2#include "Utils/Common.hpp"
5
6namespace gme
7{
8 ecs::Entity ProjectileManager::createBasicProjectile(ecs::Registry &registry, const float x, const float y,
9 const float velocityX, const float velocityY)
10 {
11 return createProjectile(registry, ecs::Projectile::BASIC, x, y, velocityX, velocityY);
12 }
13
15 const float velocityX, const float velocityY)
16 {
17 return createProjectile(registry, ecs::Projectile::SUPERCHARGED, x, y, velocityX, velocityY);
18 }
19
21 float y, float velocityX, float velocityY)
22 {
23 if (type == ecs::Projectile::BASIC)
24 {
28
29 return registry.createEntity()
30 .with<ecs::Transform>("projectile_transform", x, y, 0.F)
31 .with<ecs::Velocity>("projectile_velocity", velocityX, velocityY)
32 .with<ecs::Rect>("projectile_rect", 0.F, 0.F,
35 .with<ecs::Scale>("projectile_scale", utl::GameConfig::Projectile::Basic::SCALE,
37 .with<ecs::Texture>("projectile_texture", utl::Path::Texture::TEXTURE_SHOOT)
38 .with<ecs::Projectile>("projectile", type, utl::GameConfig::Projectile::Basic::DAMAGE,
40 .with<ecs::Hitbox>("projectile_hitbox", utl::GameConfig::Hitbox::PROJECTILE_BASIC_RADIUS, offsetX,
41 offsetY)
42 .build();
43 }
44
48
49 return registry.createEntity()
50 .with<ecs::Transform>("projectile_transform", x, y, 0.F)
51 .with<ecs::Velocity>("projectile_velocity", velocityX, velocityY)
52 .with<ecs::Rect>("projectile_rect", 0.F, 0.F,
55 .with<ecs::Scale>("projectile_scale", utl::GameConfig::Projectile::Supercharged::SCALE,
58 .with<ecs::Projectile>("projectile", type, utl::GameConfig::Projectile::Supercharged::DAMAGE,
60 .with<ecs::Animation>("projectile_animation", 0,
66 .with<ecs::Hitbox>("projectile_hitbox", utl::GameConfig::Hitbox::PROJECTILE_SUPERCHARGED_RADIUS, offsetX,
67 offsetY)
68 .build();
69 }
70} // namespace gme
Configuration constants for the multiplayer game.
Utility functions for hitbox calculations.
Manages projectile creation and configuration.
EntityBuilder & with(Args &&...args)
Definition Registry.hpp:40
Class for managing entities and their components.
Definition Registry.hpp:25
EntityBuilder createEntity()
Definition Registry.hpp:53
static ecs::Entity createSuperchargedProjectile(ecs::Registry &registry, float x, float y, float velocityX, float velocityY)
Create a supercharged projectile.
static ecs::Entity createProjectile(ecs::Registry &registry, ecs::Projectile::Type type, float x, float y, float velocityX, float velocityY)
Create a projectile with given parameters.
static ecs::Entity createBasicProjectile(ecs::Registry &registry, float x, float y, float velocityX, float velocityY)
Create a basic projectile.
This file contains common definitions and constants.
std::uint32_t Entity
Definition Entity.hpp:13
constexpr float PROJECTILE_BASIC_RADIUS
constexpr float PROJECTILE_SUPERCHARGED_RADIUS
constexpr auto TEXTURE_SHOOT
Definition Common.hpp:115
constexpr auto TEXTURE_SHOOT_CHARGED
Definition Common.hpp:116
std::pair< float, float > calculateHitboxOffsets(const float spriteWidth, const float spriteHeight, const float scale)
Calculate hitbox offsets to center the hitbox on the sprite.