-
Notifications
You must be signed in to change notification settings - Fork 1
/
missile.cpp
48 lines (36 loc) · 858 Bytes
/
missile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "missile.h"
#include"Soldier.h"
Missile::Missile(sf::Texture* texture, float speed)
{
missilebody.setSize(sf::Vector2f(30.0f, 80.0f));
missilebody.setPosition(0.0f, 730.0f);
missilebody.setTexture(texture);
this->speed = speed;
}
Missile :: ~Missile()
{
}
void Missile::Update(float deltaTime)
{
sf::Vector2f movement(0.0f, 0.0f);
movement.y -= speed * deltaTime;
missilebody.move(movement);
}
void Missile::UpdateLeft(float deltaTime)
{
sf::Vector2f movement(0.0f, 0.0f);
movement.y -= speed * deltaTime;
movement.x -= 100 * deltaTime;
missilebody.move(movement);
}
void Missile::UpdateRight(float deltaTime)
{
sf::Vector2f movement(0.0f, 0.0f);
movement.y -= speed * deltaTime;
movement.x += 100 * deltaTime;
missilebody.move(movement);
}
void Missile::Draw(sf::RenderWindow& window)
{
window.draw(missilebody);
}