-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemy.cpp
More file actions
39 lines (35 loc) · 796 Bytes
/
enemy.cpp
File metadata and controls
39 lines (35 loc) · 796 Bytes
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
#include "enemy.h"
// Set random spawn position for enemy
void Enemy::setSpawnpostion(int x_coordinate, int y_coordinate)
{
this->setPosition(x_coordinate, y_coordinate);
}
// Setter for Horizontal speed
void Enemy::setSpeed(int speedx, int speedy)
{
speedx_ = speedx;
speedy_ = speedy;
}
// Setter for y_limit
void Enemy::setyLimit(int ylimit)
{
y_limit_ = ylimit;
}
// Check if enemy crossed the y_limit
void Enemy::isEscape()
{
if(this->current_y_ + this->getGlobalBounds().height > y_limit_)
{
this->alive = false;
this->escape = true;
}
}
// Check collision and return bool
bool Enemy::isCollided(sf::FloatRect &bulletbounds)
{
if(this->getGlobalBounds().intersects(bulletbounds))
{
return true;
}
else return false;
}