-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspaceship.cpp
38 lines (36 loc) · 989 Bytes
/
spaceship.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
#include "spaceship.h"
#include <iostream>
Spaceship::Spaceship(float window_size)
{
assert(_spaceship.loadFromFile("Assets//spaceship.png"));
_forspaceship.setTexture(_spaceship);
_forspaceship.setPosition(sf::Vector2f(window_size,0));
}
void Spaceship::drawSpaceShip(sf::RenderWindow& w)
{
w.draw(_forspaceship);
}
void Spaceship::movement()
{
_forspaceship.move(-1,0);
}
bool Spaceship::isAppearNow(sf::Time& time)
{
return ( time.asSeconds() >= 25.0f );
}
void Spaceship::resetPosition(float window_size)
{
_forspaceship.setPosition(sf::Vector2f(window_size,0));
}
bool Spaceship::isDisappearNow()
{
return ( _forspaceship.getPosition().x == -static_cast<int>(_spaceship.getSize().x) );
}
void Spaceship::draw(sf::RenderWindow& window)
{
window.draw(_forspaceship);
}
bool Spaceship::isCollide(Bullet& bullet)
{
return (bullet.setSprite().getGlobalBounds().intersects(_forspaceship.getGlobalBounds()));
}