26 animation->setFrame(0);
38 int bowX = transform->getScreenPosition().x;
39 int bowY = transform->getScreenPosition().y;
40 int dx =
input->m_mouseX - bowX;
41 int dy =
input->m_mouseY - bowY;
43 float angle = atan2(dy, dx) * (180.0f / M_PI);
49 animation->setAngle(angle);
55 arrow->getComponent<
Transform>()->setWorldPosition(transform->getWorldPosition());
58 sceneTree->addChild(arrow);
65 if (animation->isPlaying() && animation->getCurrentFrame() == (animation->getNumFrames() - 1) && !
m_animationPlayed) {
67 animation->setFrame(0);
Defines the Animation class for handling sprite animations.
Component to handle animation of game objects. Derived from Texture.
static GameObject * createArrow(int dx, int dy)
Creates an arrow object with specified dynamics.
std::string getTag()
Gets the tag identifier of the GameObject.
T * getComponent()
Gets a component of the specified type.
bool m_shoot
Flag to indicate whether the weapon should shoot.
RangedWeaponScript()
Constructs a RangedWeaponScript with default or initial settings.
void input() override
Processes input to handle shooting actions.
int m_lastFireTimeInMs
Timestamp of the last shooting action in milliseconds.
bool m_animationPlayed
Ensures that the shooting animation plays correctly.
void update() override
Updates the state of the weapon based on input and time constraints.
int m_fireRatePerSecond
Allowed number of shots per second to control shooting frequency.
static SceneManager & getInstance()
Retrieves the singleton instance of SceneManager.
SceneTree * getSceneTree()
Retrieves the current scene tree managing the game objects.
GameObject * m_owner
Pointer to the GameObject that owns this script.
Defines the SceneManager class for managing scenes in the game.