-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShip.cpp
More file actions
45 lines (42 loc) · 1.23 KB
/
Ship.cpp
File metadata and controls
45 lines (42 loc) · 1.23 KB
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
40
41
42
43
44
45
#ifndef SHIP_CPP
#define SHIP_CPP
#include "Ship.hpp"
void Ship::propagate(double const dt)
{
_physicsComp.propagate(dt);
_physicsWorld->apply_boundary(&_physicsComp);
}
void Ship::draw() const
{
_graphicsComp.draw(_physicsComp);
}
void Ship::input(ShipInputType const input)
{
switch (input)
{
case Left:
_physicsComp.set_force(TO_Left); break;
case Right:
_physicsComp.set_force(TO_Right); break;
case Forward:
_physicsComp.set_force(TO_Front); break;
case Neutral:
_physicsComp.set_force(None); break;
case Shoot:
break;
default:
break;
}
}
// Constructors
Ship::Ship(PhysicsWorld* const physicsWorld) :
_physicsComp(ShipPhysicsComponent()),
_graphicsComp(ShipGraphicsComponent()),
_physicsWorld(physicsWorld) {}
Ship::Ship( PhysicsWorld* const physicsWorld,
GLfloat const pos_x, GLfloat const pos_y, GLfloat const orientation,
GLfloat const movespeed, GLfloat const spinspeed) :
_physicsComp(ShipPhysicsComponent(pos_x, pos_y, orientation, movespeed, spinspeed)),
_graphicsComp(ShipGraphicsComponent()),
_physicsWorld(physicsWorld) {}
#endif /* Ship class */