From 7a60ab9f178dd813c876fcf8e25c947f9a9a5e06 Mon Sep 17 00:00:00 2001 From: Simponic Date: Tue, 30 Jun 2020 20:04:55 -0600 Subject: Updated indentation --- bullet.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 bullet.cpp (limited to 'bullet.cpp') diff --git a/bullet.cpp b/bullet.cpp new file mode 100644 index 0000000..69fb603 --- /dev/null +++ b/bullet.cpp @@ -0,0 +1,29 @@ +#include "bullet.h" +#include "ship.h" +#include + +#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(); +} -- cgit v1.2.3-70-g09d2