diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp index 7bb681e..10e9016 100644 --- a/src/saland/Game.cpp +++ b/src/saland/Game.cpp @@ -743,12 +743,14 @@ void Game::Update() { projectile->X = target.first; projectile->Y = target.second; projectile->Radius = 8.0f; + projectile->velocity = 0.0f; + projectile->sprite = ""; projectile->directionX = projectile->X - data->world_mouse_x; projectile->directionY = projectile->Y - data->world_mouse_y; SetLengthToOne(projectile->directionX, projectile->directionY); projectile->fired_by = data->human; data->gameRegion.placeables.push_back(projectile); - projectile->timeToLive = 10.0f; + projectile->timeToLive = 100.0f; } } if (data->slot_spell.at(data->slot_selected).name == "spell_create_block") { diff --git a/src/saland/GameDraw.cpp b/src/saland/GameDraw.cpp index 6816460..7bea743 100644 --- a/src/saland/GameDraw.cpp +++ b/src/saland/GameDraw.cpp @@ -231,13 +231,15 @@ void DrawMonster(SDL_Renderer* target, sago::SagoSpriteHolder* sHolder, const Mo void DrawProjectile(SDL_Renderer* target, sago::SagoSpriteHolder* sHolder, const Projectile* entity, float time, int offsetX, int offsetY, bool drawCollision) { (void)sHolder; (void)time; - const sago::SagoSprite& mySprite = sHolder->GetSprite("effect_fireball"); - double angleRadian = 0.0; - if (entity->directionY || entity->directionX) { - //atan2 is defined if either of directionY or directionX is not zero - angleRadian = atan2(entity->directionY, entity->directionX)-M_PI/2.0; + if (entity->sprite.length()) { + const sago::SagoSprite& mySprite = sHolder->GetSprite(entity->sprite); + double angleRadian = 0.0; + if (entity->directionY || entity->directionX) { + //atan2 is defined if either of directionY or directionX is not zero + angleRadian = atan2(entity->directionY, entity->directionX)-M_PI/2.0; + } + mySprite.DrawRotated(target, time, std::round(entity->X) - offsetX, std::round(entity->Y) - offsetY, angleRadian); } - mySprite.DrawRotated(target, time, std::round(entity->X) - offsetX, std::round(entity->Y) - offsetY, angleRadian); DrawCollision(target, entity, offsetX, offsetY, drawCollision); } diff --git a/src/saland/model/placeables.hpp b/src/saland/model/placeables.hpp index 56fa98c..85bd4d7 100644 --- a/src/saland/model/placeables.hpp +++ b/src/saland/model/placeables.hpp @@ -97,6 +97,7 @@ public: float velocity = 1.0f; float timeToLive = 2000.0; std::shared_ptr fired_by; + std::string sprite = "effect_fireball"; }; #endif /* PLACEABLES_HPP */