diff options
author | Simponic <loganthebean222@gmail.com> | 2020-06-30 20:10:29 -0600 |
---|---|---|
committer | Simponic <loganthebean222@gmail.com> | 2020-06-30 20:10:29 -0600 |
commit | 3010473314505bd948c687ac644b7d87ef03298d (patch) | |
tree | e7099f6c431305cdd041d32ba244eb6360eec2f9 /src/bullet.cpp | |
parent | 7a60ab9f178dd813c876fcf8e25c947f9a9a5e06 (diff) | |
download | asteroids-cs165-3010473314505bd948c687ac644b7d87ef03298d.tar.gz asteroids-cs165-3010473314505bd948c687ac644b7d87ef03298d.zip |
Updated file structure and changed indents to spaces
Diffstat (limited to 'src/bullet.cpp')
-rw-r--r-- | src/bullet.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/bullet.cpp b/src/bullet.cpp new file mode 100644 index 0000000..69fb603 --- /dev/null +++ b/src/bullet.cpp @@ -0,0 +1,29 @@ +#include "bullet.h" +#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(); +} |