blob: b2ea253a1b1d8017068315e8ef8b66ce8687bf80 (
plain)
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
|
#include "../include/bullet.h"
#include "../include/ship.h"
#include <cmath>
#define M_PI 3.14159265
// Bullet non-default constructor
Bullet :: Bullet( const Point &point ) : FlyingObject() , framesAlive( 0 )
{
setPoint ( point );
}
// Fire Bullet
void Bullet :: fire ( const Velocity &vel , const float angle )
{
velocity.setDx ( BULLET_SPEED * ( -cos ( M_PI / 180 * angle ) ) );
velocity.setDy ( BULLET_SPEED * ( sin ( M_PI / 180 * angle ) ) );
}
// Advance Bullet
void Bullet :: advance ()
{
framesAlive++;
if ( framesAlive >= 40 )
{
kill();
}
FlyingObject :: advance();
}
|