2010-04-05 23:38:59 +02:00
|
|
|
#include "View.h"
|
|
|
|
#include "CameraBase.h"
|
|
|
|
#include "SimpleConsoleOverlay.h"
|
2010-09-16 00:04:39 +02:00
|
|
|
#include "IMGUIControls.h"
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
#include "Engine.h"
|
|
|
|
#include "Physics.h"
|
|
|
|
#include "Model.h"
|
2010-09-16 00:04:39 +02:00
|
|
|
#include "Controller.h"
|
2010-07-28 18:02:12 +02:00
|
|
|
#include "EventBase.h"
|
2010-04-05 23:38:59 +02:00
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
#include "Game.h"
|
2010-04-05 23:38:59 +02:00
|
|
|
#include "ShipEntity.h"
|
|
|
|
#include "AsteroidEntity.h"
|
|
|
|
#include "AsteroidsEvents.h"
|
|
|
|
#include "RocketEntity.h"
|
|
|
|
|
|
|
|
#include <GL/gl.h>
|
2010-09-16 00:04:39 +02:00
|
|
|
#include <GL/glu.h>
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
// #define DRAW_BOUNDARIES
|
|
|
|
|
|
|
|
#ifdef DRAW_BOUNDARIES
|
|
|
|
#include "coll2d.h"
|
|
|
|
#include "DrawingsGL.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace asteroids {
|
|
|
|
|
|
|
|
int View::OnInit (int argc, char* argv[]) {
|
|
|
|
ViewBase::OnInit (argc, argv);
|
|
|
|
|
2010-06-06 01:22:01 +02:00
|
|
|
/*
|
2010-04-05 23:38:59 +02:00
|
|
|
// We want the console
|
2010-04-14 22:01:45 +02:00
|
|
|
mConsoleOverlay = boost::shared_ptr<Engine::SimpleConsoleOverlay> (new Engine::SimpleConsoleOverlay);
|
2010-04-05 23:38:59 +02:00
|
|
|
// We also want to display the log bar
|
2010-04-14 22:01:45 +02:00
|
|
|
mConsoleOverlay->SetDrawLogBar (true);
|
2010-06-06 00:58:11 +02:00
|
|
|
mOverlayManager.Register (mConsoleOverlay, GameStateMainMenu);
|
2010-06-06 01:22:01 +02:00
|
|
|
*/
|
2010-04-05 23:38:59 +02:00
|
|
|
|
2010-11-01 22:33:14 +01:00
|
|
|
LoadFont("AldotheApache.ttf size=20 color=#000000");
|
2010-09-16 00:04:39 +02:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
button_width = 250;
|
|
|
|
button_height = 40;
|
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
// This is a simple star field that makes the game so spacy
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 200; i++) {
|
|
|
|
BackgroundStar star;
|
2010-12-01 10:48:10 +01:00
|
|
|
star.position[0] = rand() / float(RAND_MAX) * 1.2;
|
|
|
|
star.position[1] = rand() / float(RAND_MAX) * 1.2;
|
|
|
|
star.position[2] = rand() / float(RAND_MAX) * 1.2;
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
mBackgroundStars.push_back (star);
|
|
|
|
}
|
|
|
|
|
2010-12-03 00:15:26 +01:00
|
|
|
mGUIShipSprite.LoadFromPNG(Engine::GetResourceFullPath("/data/textures/ship.png"));
|
2010-09-16 00:04:39 +02:00
|
|
|
mGUIShipSprite.SetScale (0.1);
|
|
|
|
|
2010-12-03 00:15:26 +01:00
|
|
|
mAsteroidSprite.LoadFromPNG (Engine::GetResourceFullPath("/data/textures/asteroid.png"));
|
|
|
|
mShipSprite.LoadFromPNG (Engine::GetResourceFullPath("/data/textures/ship.png"));
|
2010-04-05 23:38:59 +02:00
|
|
|
|
2010-12-03 00:15:26 +01:00
|
|
|
mShipThrustSprite.LoadFromPNG (Engine::GetResourceFullPath("/data/textures/ship_thrust.png"));
|
2010-04-05 23:38:59 +02:00
|
|
|
mShipThrustSprite.SetAnimation (4, 8);
|
|
|
|
|
2010-12-03 00:15:26 +01:00
|
|
|
mShipPartsSprite.LoadFromPNG (Engine::GetResourceFullPath("/data/textures/ship_parts.png"));
|
2010-04-05 23:38:59 +02:00
|
|
|
mShipPartsSprite.SetSubSpriteCount (10);
|
|
|
|
|
2010-07-28 18:02:12 +02:00
|
|
|
Engine::RegisterListener (this, EventAccelerateStart);
|
|
|
|
Engine::RegisterListener (this, EventAccelerateStop);
|
|
|
|
Engine::RegisterListener (this, EventShipExplode);
|
2010-11-28 00:20:58 +01:00
|
|
|
Engine::RegisterListener (this, EventPlayerDied);
|
2010-11-27 08:38:32 +01:00
|
|
|
Engine::RegisterListener (this, EventGameOver);
|
2010-11-28 00:20:58 +01:00
|
|
|
Engine::RegisterListener (this, EventLevelComplete);
|
2010-04-05 23:38:59 +02:00
|
|
|
|
2010-11-22 20:00:44 +01:00
|
|
|
PushViewState (ViewStateMainMenu);
|
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::OnDestroy() {
|
2010-04-14 22:01:45 +02:00
|
|
|
mBackgroundStars.clear();
|
|
|
|
mShipPartsEntityIds.clear();
|
|
|
|
|
|
|
|
Engine::ViewBase::OnDestroy();
|
2010-04-05 23:38:59 +02:00
|
|
|
}
|
|
|
|
|
2010-07-28 18:02:12 +02:00
|
|
|
bool View::OnReceiveEvent (const Engine::EventBasePtr &event) {
|
|
|
|
switch (event->mEventType) {
|
|
|
|
case EventAccelerateStart:
|
|
|
|
case EventAccelerateStop:
|
|
|
|
if (event->mEventType == EventAccelerateStart)
|
|
|
|
mShipThrustSprite.ResetAnimation();
|
2010-04-05 23:38:59 +02:00
|
|
|
|
2010-07-28 18:02:12 +02:00
|
|
|
Engine::LogDebug ("Received Acceleration Event: %d", event->mEventType);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
break;
|
2010-11-28 00:20:58 +01:00
|
|
|
case EventLevelComplete:
|
|
|
|
PushViewState(ViewStateLevelComplete);
|
2010-12-01 10:02:26 +01:00
|
|
|
GetController()->ResetPlayerEntity();
|
2010-11-28 00:20:58 +01:00
|
|
|
break;
|
|
|
|
|
2010-11-27 08:38:32 +01:00
|
|
|
case EventGameOver:
|
2010-11-28 00:20:58 +01:00
|
|
|
mFadeTimerSecValue = 2.;
|
|
|
|
|
2010-11-27 08:38:32 +01:00
|
|
|
PopViewState();
|
|
|
|
PushViewState(ViewStateGameOver);
|
2010-12-01 10:02:26 +01:00
|
|
|
GetController()->ResetPlayerEntity();
|
2010-07-28 18:02:12 +02:00
|
|
|
|
2010-11-27 08:38:32 +01:00
|
|
|
break;
|
2010-11-28 00:20:58 +01:00
|
|
|
case EventPlayerDied:
|
|
|
|
mFadeTimerSecValue = 2.;
|
2010-11-27 08:38:32 +01:00
|
|
|
PushViewState(ViewStatePlayerDied);
|
2010-12-01 10:02:26 +01:00
|
|
|
GetController()->ResetPlayerEntity();
|
2010-11-28 00:20:58 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
case EventShipExplode: {
|
|
|
|
// This event is fired when the ship explodes. Note: this event is not
|
|
|
|
// sufficient for EventPlayerDied!
|
|
|
|
Engine::LogDebug ("Received PlayerDied Event: %d", event->mEventType);
|
|
|
|
|
2010-11-27 08:38:32 +01:00
|
|
|
// insert sprits that contains parts of the ship
|
|
|
|
Engine::EntityBase *ship_entity = Engine::GetEntity (event->mEventUnsignedInt);
|
|
|
|
vector3d position = ship_entity->mPhysicState->mPosition;
|
|
|
|
vector3d orientation = ship_entity->mPhysicState->mOrientation;
|
|
|
|
vector3d velocity = ship_entity->mPhysicState->mVelocity;
|
2010-12-01 10:30:07 +01:00
|
|
|
vector3d rel_velocity = event->mVector3d;
|
2010-11-27 08:38:32 +01:00
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
mShipPartsEntityIds.clear();
|
|
|
|
|
|
|
|
for (i = 0; i < mShipPartsSprite.GetSubSpriteCount(); i++) {
|
|
|
|
Engine::EntityBase* part_sprite_particle = Engine::CreateEntity (GameEntityTypeShipPart);
|
|
|
|
part_sprite_particle->mPhysicState->mPosition = position;
|
|
|
|
part_sprite_particle->mPhysicState->mOrientation = orientation;
|
2010-12-01 10:30:07 +01:00
|
|
|
vector3d part_velocity (
|
|
|
|
rel_velocity[0] * (rand()/float(RAND_MAX)) * 1.7,
|
|
|
|
0.,
|
|
|
|
rel_velocity[2] * (rand()/float(RAND_MAX)) * 1.5
|
|
|
|
);
|
|
|
|
part_sprite_particle->mPhysicState->mVelocity = part_velocity;
|
|
|
|
|
2010-11-27 08:38:32 +01:00
|
|
|
part_sprite_particle->mPhysicState->mAngleVelocity = (rand()/float(RAND_MAX) - 0.5 ) * 100.;
|
|
|
|
|
|
|
|
mShipPartsEntityIds.push_back(part_sprite_particle->mId);
|
|
|
|
}
|
2010-07-28 18:02:12 +02:00
|
|
|
|
2010-11-27 08:38:32 +01:00
|
|
|
// We do not need the entity anymore
|
|
|
|
Engine::KillEntity(event->mEventUnsignedInt);
|
|
|
|
|
|
|
|
return true;
|
2010-07-28 18:02:12 +02:00
|
|
|
|
|
|
|
break;
|
2010-11-27 08:38:32 +01:00
|
|
|
}
|
2010-04-05 23:38:59 +02:00
|
|
|
|
2010-07-28 18:02:12 +02:00
|
|
|
default: Engine::LogWarning ("Received Event with type %d but don't know what to do with it!", event->mEventType);
|
|
|
|
break;
|
2010-04-05 23:38:59 +02:00
|
|
|
}
|
|
|
|
|
2010-07-28 18:02:12 +02:00
|
|
|
return false;
|
2010-04-05 23:38:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Module specific functions
|
|
|
|
*/
|
|
|
|
void View::UpdateCamera () {
|
|
|
|
mCamera->SetEye (
|
|
|
|
0.,
|
|
|
|
9.5,
|
|
|
|
0.
|
|
|
|
);
|
|
|
|
mCamera->SetPointOfIntrest (
|
|
|
|
0.,
|
|
|
|
0.,
|
|
|
|
0.
|
|
|
|
);
|
|
|
|
mCamera->SetUp (
|
|
|
|
0.,
|
|
|
|
0.,
|
|
|
|
-1.
|
|
|
|
);
|
|
|
|
|
|
|
|
mCamera->Update ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawStars() {
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
float world_width, world_height;
|
|
|
|
world_width = static_cast<Model*>(mModel)->GetWorldWidth();
|
|
|
|
world_height = static_cast<Model*>(mModel)->GetWorldHeight();
|
|
|
|
vector3d velocity (1., 0., 0.);
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(-world_width * 0.5, 0, -world_height * 0.5);
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
glPointSize(2.);
|
|
|
|
glBegin(GL_POINTS);
|
|
|
|
float z_value;
|
|
|
|
for (i = 0; i < mBackgroundStars.size(); i++) {
|
|
|
|
// glPointSize (2. + 300. *mBackgroundStars.at(i).position[1]);
|
|
|
|
z_value = mBackgroundStars.at(i).position[1] + 0.1;
|
|
|
|
|
|
|
|
glColor3f (z_value, z_value, z_value);
|
|
|
|
glVertex3f (mBackgroundStars.at(i).position[0] * world_width,
|
|
|
|
-1.,
|
|
|
|
mBackgroundStars.at(i).position[2] * world_height);
|
|
|
|
|
|
|
|
mBackgroundStars.at(i).position -= vector3d(Engine::GetFrameDuration() * 0.7 * mBackgroundStars.at(i).position[1] / world_width, 0., 0.);
|
|
|
|
|
2010-12-01 10:48:10 +01:00
|
|
|
// we move the stars a little more such that they are not blende out too early
|
|
|
|
// \todo compute proper bounds from Physics world size!
|
|
|
|
if (mBackgroundStars.at(i).position[0] < -0.1)
|
|
|
|
mBackgroundStars.at(i).position[0] += 1.2;
|
|
|
|
if (mBackgroundStars.at(i).position[0] >= 1.1)
|
|
|
|
mBackgroundStars.at(i).position[0] -= 1.2;
|
2010-04-05 23:38:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
void View::Draw() {
|
|
|
|
PreDraw();
|
|
|
|
|
2010-11-28 00:20:58 +01:00
|
|
|
mFadeTimerSecValue -= GetModel()->GetFrameDuration();
|
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
// Actual Drawing
|
|
|
|
UpdateCamera ();
|
|
|
|
|
|
|
|
if (mDrawGrid)
|
|
|
|
DrawGrid ();
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (mDrawAxis)
|
|
|
|
DrawAxis ();
|
2010-11-28 00:20:58 +01:00
|
|
|
*/
|
2010-09-16 00:04:39 +02:00
|
|
|
|
|
|
|
DrawWorld ();
|
|
|
|
|
|
|
|
DrawUi ();
|
|
|
|
|
|
|
|
// Perform post-Draw actions
|
|
|
|
PostDraw();
|
|
|
|
}
|
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
void View::DrawWorld() {
|
|
|
|
std::map<unsigned int, Engine::EntityBase*>::iterator entity_iterator;
|
|
|
|
|
|
|
|
Model *game_model = static_cast<Model*> (mModel);
|
|
|
|
|
|
|
|
DrawStars ();
|
|
|
|
|
|
|
|
if ( game_model->GetGameState() != GameStateRunning) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewBase::DrawWorld();
|
|
|
|
|
|
|
|
for (entity_iterator = game_model->mEntities.begin ();
|
|
|
|
entity_iterator != game_model->mEntities.end();
|
|
|
|
entity_iterator++) {
|
|
|
|
Engine::EntityBase* entity = entity_iterator->second;
|
|
|
|
|
|
|
|
// Perform multiple drawing if the entity is at the border
|
|
|
|
Physics* game_physics = (Physics*) game_model->mPhysics;
|
|
|
|
float world_width = game_physics->GetWorldWidth();
|
|
|
|
float world_height = game_physics->GetWorldHeight();
|
|
|
|
|
|
|
|
// Drawing at the original position:
|
|
|
|
glPushMatrix ();
|
|
|
|
glTranslatef (entity->mPhysicState->mPosition[0],
|
|
|
|
entity->mPhysicState->mPosition[1],
|
|
|
|
entity->mPhysicState->mPosition[2]);
|
|
|
|
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[0], 0., 0., 1.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[1], 0., 1., 0.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[2], 1., 0., 0.);
|
|
|
|
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
DrawEntity (entity);
|
|
|
|
|
|
|
|
glPopMatrix ();
|
|
|
|
|
|
|
|
// If we move out the right side
|
|
|
|
if (entity->mPhysicState->mPosition[0] + entity->mPhysicState->mRadius * 2
|
|
|
|
>= world_width * 0.5) {
|
|
|
|
|
|
|
|
glPushMatrix ();
|
|
|
|
glTranslatef (entity->mPhysicState->mPosition[0] - world_width,
|
|
|
|
entity->mPhysicState->mPosition[1],
|
|
|
|
entity->mPhysicState->mPosition[2]);
|
|
|
|
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[0], 0., 0., 1.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[1], 0., 1., 0.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[2], 1., 0., 0.);
|
|
|
|
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
DrawEntity (entity);
|
|
|
|
|
|
|
|
glPopMatrix ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we move out the left side
|
|
|
|
if (entity->mPhysicState->mPosition[0] - entity->mPhysicState->mRadius * 2
|
|
|
|
< - world_width * 0.5) {
|
|
|
|
glPushMatrix ();
|
|
|
|
glTranslatef (entity->mPhysicState->mPosition[0] + world_width,
|
|
|
|
entity->mPhysicState->mPosition[1],
|
|
|
|
entity->mPhysicState->mPosition[2]);
|
|
|
|
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[0], 0., 0., 1.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[1], 0., 1., 0.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[2], 1., 0., 0.);
|
|
|
|
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
DrawEntity (entity);
|
|
|
|
|
|
|
|
glPopMatrix ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we move out the bottom side
|
|
|
|
if (entity->mPhysicState->mPosition[2] + entity->mPhysicState->mRadius * 2
|
|
|
|
>= world_height * 0.5) {
|
|
|
|
|
|
|
|
glPushMatrix ();
|
|
|
|
glTranslatef (entity->mPhysicState->mPosition[0],
|
|
|
|
entity->mPhysicState->mPosition[1],
|
|
|
|
entity->mPhysicState->mPosition[2] - world_height);
|
|
|
|
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[0], 0., 0., 1.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[1], 0., 1., 0.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[2], 1., 0., 0.);
|
|
|
|
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
DrawEntity (entity);
|
|
|
|
|
|
|
|
glPopMatrix ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we move out the left side
|
|
|
|
if (entity->mPhysicState->mPosition[2] - entity->mPhysicState->mRadius * 2
|
|
|
|
< - world_height* 0.5) {
|
|
|
|
glPushMatrix ();
|
|
|
|
glTranslatef (entity->mPhysicState->mPosition[0],
|
|
|
|
entity->mPhysicState->mPosition[1],
|
|
|
|
entity->mPhysicState->mPosition[2] + world_height);
|
|
|
|
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[0], 0., 0., 1.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[1], 0., 1., 0.);
|
|
|
|
glRotatef(entity->mPhysicState->mOrientation[2], 1., 0., 0.);
|
|
|
|
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
DrawEntity (entity);
|
|
|
|
|
|
|
|
glPopMatrix ();
|
|
|
|
}
|
|
|
|
}
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Userinterface
|
|
|
|
*/
|
|
|
|
void View::DrawUi () {
|
|
|
|
glClearColor (0.1, 0.1, 0.1, 1.);
|
|
|
|
|
|
|
|
screen_right = static_cast<float> (Engine::GetWindowWidth());
|
|
|
|
screen_bottom = static_cast<float> (Engine::GetWindowHeight());
|
|
|
|
|
|
|
|
// we switch to orthographic projection and draw the contents of the 2d
|
|
|
|
// overlay on top of the previous drawings
|
|
|
|
glMatrixMode (GL_PROJECTION);
|
|
|
|
glPushMatrix ();
|
|
|
|
glLoadIdentity ();
|
|
|
|
|
|
|
|
// first we have to get the size of the current viewport to set up the
|
|
|
|
// orthographic projection correctly
|
|
|
|
GLint viewport[4];
|
|
|
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
|
|
|
gluOrtho2D (viewport[0], viewport[2], viewport[3], viewport[1]);
|
|
|
|
|
|
|
|
glMatrixMode (GL_MODELVIEW);
|
|
|
|
glPushMatrix ();
|
|
|
|
glLoadIdentity ();
|
|
|
|
|
|
|
|
unsigned int game_state = GetModel()->GetGameState();
|
|
|
|
|
|
|
|
SelectFont("console.ttf");
|
|
|
|
SetFontJustification (Engine::FontJustificationLeft);
|
|
|
|
GetController()->EnableTextinput(true);
|
|
|
|
|
2010-11-22 20:00:44 +01:00
|
|
|
ViewState current_view_state = GetViewState();
|
|
|
|
|
2010-11-28 23:08:52 +01:00
|
|
|
// SelectFont ("console.ttf size=12");
|
|
|
|
// Engine::GUI::Label (99999, GetStringViewState(current_view_state), 8, 16);
|
2010-11-22 20:00:44 +01:00
|
|
|
|
|
|
|
switch (current_view_state) {
|
|
|
|
case ViewStateMainMenu:
|
2010-09-16 00:04:39 +02:00
|
|
|
DrawUiMainMenu();
|
|
|
|
break;
|
2010-11-22 20:00:44 +01:00
|
|
|
case ViewStateGameRunning:
|
2010-09-16 00:04:39 +02:00
|
|
|
DrawUiGameRunning();
|
|
|
|
break;
|
2010-11-22 20:00:44 +01:00
|
|
|
case ViewStatePaused:
|
2010-09-16 00:04:39 +02:00
|
|
|
DrawUiGamePaused();
|
|
|
|
break;
|
2010-11-22 20:00:44 +01:00
|
|
|
case ViewStatePlayerDied:
|
2010-09-16 00:04:39 +02:00
|
|
|
DrawUiPlayerDied();
|
|
|
|
break;
|
2010-11-22 20:00:44 +01:00
|
|
|
case ViewStateLevelComplete:
|
2010-09-16 00:04:39 +02:00
|
|
|
DrawUiLevelComplete();
|
|
|
|
break;
|
2010-11-22 20:00:44 +01:00
|
|
|
case ViewStateShowHighscore:
|
2010-09-16 00:04:39 +02:00
|
|
|
DrawUiHighscore();
|
|
|
|
break;
|
2010-11-22 20:00:44 +01:00
|
|
|
case ViewStateOptions:
|
|
|
|
DrawUiOptions();
|
|
|
|
break;
|
|
|
|
case ViewStateEnterPlayername:
|
2010-09-16 00:04:39 +02:00
|
|
|
DrawUiEnterPlayername();
|
|
|
|
break;
|
2010-11-22 20:00:44 +01:00
|
|
|
case ViewStateGameOver:
|
2010-09-16 00:04:39 +02:00
|
|
|
DrawUiGameOver();
|
|
|
|
break;
|
|
|
|
default:
|
2010-11-22 20:00:44 +01:00
|
|
|
Engine::LogWarning ("Trying to draw unknown ViewState: %s (%d)",
|
|
|
|
GetStringViewState (game_state), game_state);
|
2010-09-16 00:04:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
glPopMatrix ();
|
|
|
|
|
|
|
|
glMatrixMode (GL_PROJECTION);
|
|
|
|
glPopMatrix ();
|
|
|
|
|
|
|
|
glMatrixMode (GL_MODELVIEW);
|
2010-11-13 18:45:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawPageTitle (const std::string& title) {
|
|
|
|
SelectFont("console.ttf size=46 color=#808080");
|
|
|
|
float width, height;
|
|
|
|
DrawGLStringMeasure(title.c_str(), &width, &height);
|
2010-09-16 00:04:39 +02:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
float xpos = (screen_right - width) * 0.5 - 40;
|
|
|
|
float ypos = 180;
|
|
|
|
Engine::GUI::Label (4, title.c_str(), xpos - 2, ypos + 2);
|
|
|
|
|
|
|
|
SelectFont("console.ttf size=46 color=#ffffff");
|
|
|
|
Engine::GUI::Label (4, title.c_str(), xpos, ypos);
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawUiMainMenu() {
|
2010-11-13 18:45:15 +01:00
|
|
|
DrawPageTitle ("Asteroids");
|
2010-09-16 00:04:39 +02:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
SelectFont("console.ttf size=23");
|
|
|
|
if (Engine::GUI::Button (1, "New Game", screen_right * 0.5 - 100, 200, button_width, button_height)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
PushViewState(ViewStateEnterPlayername);
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
|
2010-11-22 20:00:44 +01:00
|
|
|
if (Engine::GUI::Button (2, "Options", screen_right * 0.5 - 100, 250, button_width, button_height)) {
|
|
|
|
PushViewState (ViewStateOptions);
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
|
2010-11-22 20:00:44 +01:00
|
|
|
if (Engine::GUI::Button (3, "Highscores", screen_right * 0.5 - 100, 300, button_width, button_height)) {
|
|
|
|
PushViewState(ViewStateShowHighscore);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Engine::GUI::Button (4, "Quit", screen_right * 0.5 - 100, 380, button_width, button_height)) {
|
2010-09-16 00:04:39 +02:00
|
|
|
Engine::RunCommand("quit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawUiGameRunning() {
|
|
|
|
// We choose a different font and also draw it aligned to the right as this
|
|
|
|
// looks nicer with the points
|
2010-11-01 22:33:14 +01:00
|
|
|
SelectFont ("AldotheApache.ttf size=20 color=#ffffff");
|
2010-09-16 00:04:39 +02:00
|
|
|
SetFontJustification (Engine::FontJustificationRight);
|
|
|
|
|
|
|
|
std::ostringstream out_stream;
|
|
|
|
out_stream << GetModel()->GetPlayerLives() << " x ";
|
|
|
|
DrawGLString (screen_right - 64, screen_bottom - 20, out_stream.str().c_str());
|
|
|
|
|
|
|
|
mGUIShipSprite.DrawAt2D (screen_right - 32 - 10, screen_bottom - 16);
|
|
|
|
|
|
|
|
out_stream.str("");
|
|
|
|
out_stream << GetModel()->GetPoints();
|
|
|
|
DrawGLString (screen_right - 30, 40, out_stream.str().c_str());
|
|
|
|
|
|
|
|
// revert the font justification
|
|
|
|
SetFontJustification (Engine::FontJustificationLeft);
|
|
|
|
|
2010-11-22 20:00:44 +01:00
|
|
|
if (Engine::GUI::CheckKeyPress(SDLK_ESCAPE)) {
|
|
|
|
PushViewState(ViewStatePaused);
|
2010-11-27 08:38:32 +01:00
|
|
|
GetModel()->SetGameState(GameStatePaused);
|
2010-11-22 20:00:44 +01:00
|
|
|
}
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawUiGameOver() {
|
2010-11-13 18:45:15 +01:00
|
|
|
DrawPageTitle ("Game Over");
|
|
|
|
|
|
|
|
SelectFont("console.ttf size=23 color=#ffffff");
|
2010-09-16 00:04:39 +02:00
|
|
|
|
|
|
|
if (GetModel()->GetPlayerLives() == 0) {
|
2010-11-13 18:45:15 +01:00
|
|
|
Engine::GUI::LabelCentered(5,
|
|
|
|
"That was pathetic!",
|
|
|
|
screen_right * 0.5,
|
|
|
|
screen_bottom * 0.5 - 8);
|
2010-09-16 00:04:39 +02:00
|
|
|
} else {
|
2010-11-13 18:45:15 +01:00
|
|
|
Engine::GUI::LabelCentered (6, "You earned yourself the",
|
|
|
|
screen_right * 0.5,
|
2010-09-16 00:04:39 +02:00
|
|
|
screen_bottom * 0.5 - 32);
|
2010-11-13 18:45:15 +01:00
|
|
|
Engine::GUI::LabelCentered (7, "You Rock(TM) award.",
|
|
|
|
screen_right * 0.5,
|
2010-09-16 00:04:39 +02:00
|
|
|
screen_bottom * 0.5 + 0);
|
2010-11-13 18:45:15 +01:00
|
|
|
Engine::GUI::LabelCentered (8, "Go tell your friends.",
|
|
|
|
screen_right * 0.5,
|
2010-09-16 00:04:39 +02:00
|
|
|
screen_bottom * 0.5 + 32);
|
|
|
|
}
|
|
|
|
|
2010-11-28 00:20:58 +01:00
|
|
|
if (mFadeTimerSecValue > 0.)
|
|
|
|
return;
|
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
if (Engine::GUI::Button (2, "Continue...",
|
2010-11-13 18:45:15 +01:00
|
|
|
(screen_right - button_width) * 0.5,
|
|
|
|
screen_bottom * 0.5 + 80, button_width, button_height)) {
|
2010-11-28 00:20:58 +01:00
|
|
|
// We do not want the background to show the remaining bits of the game
|
|
|
|
GetModel()->SetGameState(GameStatePaused);
|
|
|
|
|
2010-11-22 20:00:44 +01:00
|
|
|
PopViewState();
|
|
|
|
PushViewState(ViewStateShowHighscore);
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawUiLevelComplete() {
|
2010-11-13 18:45:15 +01:00
|
|
|
DrawPageTitle ("Level Complete!");
|
2010-09-16 00:04:39 +02:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
SelectFont ("console.ttf size=23");
|
2010-09-16 00:04:39 +02:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
if(Engine::GUI::Button (1, "Next level ...", (screen_right - button_width) * 0.5, screen_bottom * 0.5 + 60, button_width, button_height)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
PopViewState();
|
2010-11-28 00:20:58 +01:00
|
|
|
GetModel()->ProceedToNextLevel();
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawUiGamePaused() {
|
2010-11-13 18:45:15 +01:00
|
|
|
DrawPageTitle ("Game Paused");
|
|
|
|
SelectFont ("console.ttf size=23");
|
2010-09-16 00:04:39 +02:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
if (Engine::GUI::Button (1, "Resume Game", screen_right * 0.5 - 100, 200, button_width, button_height)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
PopViewState();
|
2010-11-27 20:56:38 +01:00
|
|
|
GetModel()->SetGameState(GameStateRunning);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Engine::GUI::Button (2, "Options", screen_right * 0.5 - 100, 250, button_width, button_height)) {
|
|
|
|
PushViewState (ViewStateOptions);
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
|
2010-11-27 20:56:38 +01:00
|
|
|
if (Engine::GUI::Button (3, "Abort Game", screen_right * 0.5 - 100, 300, button_width, button_height)) {
|
2010-11-28 00:20:58 +01:00
|
|
|
ResetViewState();
|
2010-11-22 20:00:44 +01:00
|
|
|
|
2010-11-27 20:56:38 +01:00
|
|
|
PushViewState(ViewStateMainMenu);
|
|
|
|
GetModel()->SetGameState(GameStatePaused);
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
|
2010-11-27 20:56:38 +01:00
|
|
|
if (Engine::GUI::Button (4, "Quit", screen_right * 0.5 - 100, 380, button_width, button_height)) {
|
2010-09-16 00:04:39 +02:00
|
|
|
Engine::RunCommand("quit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawUiPlayerDied() {
|
2010-11-13 18:45:15 +01:00
|
|
|
DrawPageTitle ("You died!");
|
|
|
|
SelectFont ("console.ttf size=23");
|
2010-09-16 00:04:39 +02:00
|
|
|
|
2010-11-28 00:20:58 +01:00
|
|
|
if (mFadeTimerSecValue > 0.)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Engine::GUI::Button (1, "Continue", screen_right * 0.5 - 100, 380, button_width, button_height)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
PopViewState();
|
2010-11-28 00:20:58 +01:00
|
|
|
GetModel()->ReloadLevel();
|
|
|
|
GetModel()->SetGameState(GameStateRunning);
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
/** \brief Draws an entry in the form <name> .... <points>
|
|
|
|
*
|
|
|
|
* The amount of dots is also computed within this function. Not necessarily
|
|
|
|
* fast, however it works for now.
|
|
|
|
*/
|
|
|
|
void View::DrawHighscoreEntry (float x, float y, float entry_width, const std::string &name, unsigned int points) {
|
|
|
|
const float width_buffer = 30.;
|
|
|
|
float width, height;
|
|
|
|
float name_width, points_value_width;
|
|
|
|
|
|
|
|
// Measure and draw the name
|
|
|
|
DrawGLStringMeasure (name.c_str(), &name_width, &height);
|
|
|
|
name_width = fabsf(name_width);
|
|
|
|
Engine::DrawGLString ( x, y, name.c_str());
|
|
|
|
|
|
|
|
// Compute the width of the points value when it is printed out
|
|
|
|
std::ostringstream points_value_stream;
|
|
|
|
points_value_stream << points;
|
|
|
|
DrawGLStringMeasure (points_value_stream.str().c_str(), &points_value_width, &height);
|
|
|
|
points_value_width = fabsf(points_value_width);
|
|
|
|
|
|
|
|
// Compute the amount of dots. This is done by iteratively adding a dot '.'
|
|
|
|
// to a stream and check whether it has the desired width.
|
|
|
|
float dots_width = 0.;
|
|
|
|
std::ostringstream dots_stream;
|
|
|
|
|
|
|
|
while (ceil(name_width) + dots_width + points_value_width + width_buffer < entry_width) {
|
|
|
|
dots_stream << ".";
|
|
|
|
DrawGLStringMeasure (dots_stream.str().c_str(), &dots_width, &height);
|
|
|
|
dots_width = fabsf(dots_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Drawing of the dots and the points value
|
|
|
|
Engine::DrawGLString ( x + entry_width - points_value_width - dots_width - 10, y, dots_stream.str().c_str());
|
|
|
|
Engine::DrawGLString ( x + entry_width - points_value_width, y, points_value_stream.str().c_str());
|
|
|
|
}
|
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
void View::DrawUiHighscore() {
|
2010-11-13 18:45:15 +01:00
|
|
|
DrawPageTitle ("Highscores");
|
|
|
|
SelectFont ("console.ttf size=23");
|
|
|
|
|
2010-11-28 00:20:58 +01:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
unsigned int entry_length = 32;
|
|
|
|
float char_width, height;
|
|
|
|
DrawGLStringMeasure ("M", &char_width, &height);
|
2010-11-15 22:49:35 +01:00
|
|
|
height = fabsf(height);
|
2010-11-13 18:45:15 +01:00
|
|
|
float entry_width = fabsf(char_width * entry_length);
|
|
|
|
float x = screen_right * 0.5 - entry_width * 0.5;
|
2010-09-16 00:04:39 +02:00
|
|
|
float y = screen_bottom * 0.5 - 8 - 128;
|
|
|
|
|
|
|
|
// then we do the drawings
|
2010-11-13 18:45:15 +01:00
|
|
|
y += 60;
|
2010-09-16 00:04:39 +02:00
|
|
|
std::list<Model::HighscoreEntry>::iterator highscore_iter = GetModel()->mHighscoreList.begin();
|
|
|
|
|
|
|
|
SetFontJustification(Engine::FontJustificationLeft);
|
|
|
|
|
|
|
|
unsigned int i = 0;
|
|
|
|
while (highscore_iter != GetModel()->mHighscoreList.end()) {
|
|
|
|
// Check whether we have to highlight an entry (such as when entering
|
|
|
|
// the name)
|
|
|
|
if (GetModel()->mNewestHighscoreEntryIndex < GetModel()->mHighscoreList.size()
|
|
|
|
&& GetModel()->mNewestHighscoreEntryIndex == i) {
|
2010-11-13 18:45:15 +01:00
|
|
|
// we highlight the newest entry
|
|
|
|
SelectFont("console.ttf color=#e8d500 size=23");
|
2010-09-16 00:04:39 +02:00
|
|
|
} else {
|
2010-11-13 18:45:15 +01:00
|
|
|
SelectFont("console.ttf color=#ffffff size=23");
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
2010-11-13 18:45:15 +01:00
|
|
|
DrawHighscoreEntry ( x, y, entry_width, highscore_iter->name, highscore_iter->points);
|
2010-09-16 00:04:39 +02:00
|
|
|
|
|
|
|
// go down one line
|
2010-11-15 22:49:35 +01:00
|
|
|
y += height * 1.3;
|
2010-09-16 00:04:39 +02:00
|
|
|
|
|
|
|
i++;
|
|
|
|
highscore_iter++;
|
|
|
|
}
|
2010-04-05 23:38:59 +02:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
if (Engine::GUI::Button (1, "Back to Menu", screen_right * 0.5 - 250 * 0.5, y + 16, button_width, button_height)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
PopViewState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawUiOptions() {
|
|
|
|
DrawPageTitle ("Options");
|
|
|
|
SelectFont ("console.ttf size=23");
|
|
|
|
|
2010-11-28 01:13:45 +01:00
|
|
|
Engine::GUI::Label (10, "Effects Volume: ", screen_right * 0.5 - 150, 240);
|
2010-11-22 20:00:44 +01:00
|
|
|
|
|
|
|
float effects_volume = Engine::GetEffectsVolume();
|
2010-11-28 01:13:45 +01:00
|
|
|
if (Engine::GUI::VerticalSlider (1, screen_right * 0.5 - 100, 250, 250, 16, 0., 1., effects_volume)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
Engine::LogDebug ("Setting effects volume to: %f", effects_volume);
|
|
|
|
Engine::SetEffectsVolume(effects_volume);
|
|
|
|
}
|
|
|
|
|
2010-11-28 01:13:45 +01:00
|
|
|
Engine::GUI::Label (11, "Music Volume: ", screen_right * 0.5 - 150, 300);
|
2010-11-22 20:00:44 +01:00
|
|
|
|
|
|
|
float music_volume = Engine::GetMusicVolume();
|
2010-11-28 01:13:45 +01:00
|
|
|
if (Engine::GUI::VerticalSlider (2, screen_right * 0.5 - 100, 310, 250, 16, 0., 1., music_volume)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
Engine::LogDebug ("Setting music volume to: %f", music_volume);
|
|
|
|
Engine::SetMusicVolume(music_volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Engine::GUI::Button (5, "Back", screen_right * 0.5 - 100, 380, button_width, button_height)) {
|
|
|
|
PopViewState();
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
2010-04-05 23:38:59 +02:00
|
|
|
}
|
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
void View::DrawUiEnterPlayername() {
|
2010-11-13 18:45:15 +01:00
|
|
|
DrawPageTitle ("Asteroids");
|
|
|
|
SelectFont ("console.ttf size=23");
|
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
// Enter your name
|
|
|
|
std::string player_name = GetModel()->GetPlayerName();
|
2010-11-01 22:33:14 +01:00
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
SelectFont("console.ttf size=23");
|
|
|
|
Engine::GUI::Label (1, "Enter your name: ", screen_right * 0.5 - 220, 250);
|
2010-09-16 00:04:39 +02:00
|
|
|
|
|
|
|
if (Engine::GUI::LineEdit (2, screen_right * 0.5 + 20, 238, player_name, 16)) {
|
|
|
|
GetModel()->SetPlayerName(player_name);
|
|
|
|
}
|
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
if (Engine::GUI::Button (3, "Start Game", screen_right - 180 - 20, 500, 180, 40)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
PopViewState();
|
|
|
|
PushViewState(ViewStateGameRunning);
|
|
|
|
GetModel()->OnNewGame();
|
2010-09-16 00:04:39 +02:00
|
|
|
GetModel()->SetGameState(GameStateRunning);
|
|
|
|
}
|
|
|
|
|
2010-11-13 18:45:15 +01:00
|
|
|
if (Engine::GUI::Button (5, "Back", 20, 500, 180, 40)) {
|
2010-11-22 20:00:44 +01:00
|
|
|
PopViewState();
|
2010-09-16 00:04:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Entities
|
|
|
|
*/
|
2010-04-05 23:38:59 +02:00
|
|
|
void View::DrawEntity (Engine::EntityBase *entity) {
|
|
|
|
if (entity->mType == GameEntityTypeAsteroid)
|
|
|
|
DrawAsteroid ((AsteroidEntity*) entity);
|
|
|
|
else if (entity->mType == GameEntityTypeShip)
|
|
|
|
DrawShip ((ShipEntity*) entity);
|
|
|
|
else if (entity->mType == GameEntityTypeRocket)
|
|
|
|
DrawRocket ((RocketEntity*) entity);
|
|
|
|
else if (entity->mType == GameEntityTypeShipPart)
|
|
|
|
DrawShipPart (entity);
|
|
|
|
else {
|
|
|
|
Engine::LogError ("Cannot draw entity: unknown type '%d'", entity->mType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \todo: Update of the animation ??
|
|
|
|
void View::DrawShip (ShipEntity *ship) {
|
|
|
|
if (!ship->mAlive)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mShipSprite.SetScale (2. * ship->mPhysicState->mRadius / mShipSprite.GetHeight());
|
|
|
|
mShipThrustSprite.SetScale (2. * ship->mPhysicState->mRadius / mShipSprite.GetHeight());
|
|
|
|
|
|
|
|
if (ship->mState == ShipEntity::Accelerating) {
|
|
|
|
mShipThrustSprite.UpdateAnimation (Engine::GetFrameDuration());
|
|
|
|
mShipThrustSprite.DrawAt(-0.5, 0., 0.);
|
|
|
|
}
|
|
|
|
|
|
|
|
mShipSprite.DrawAt(0., 0., 0.);
|
|
|
|
|
|
|
|
#ifdef DRAW_BOUNDARIES
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
DrawCircle (ship->mPhysicState->mRadius, 20);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawAsteroid (AsteroidEntity *asteroid) {
|
|
|
|
mAsteroidSprite.SetScale (2. * asteroid->mPhysicState->mRadius / mAsteroidSprite.GetWidth());
|
|
|
|
mAsteroidSprite.DrawAt(0., 0., 0.);
|
|
|
|
|
|
|
|
#ifdef DRAW_BOUNDARIES
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
DrawCircle (asteroid->mPhysicState->mRadius, 20);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawRocket (RocketEntity *rocket) {
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
glBegin (GL_QUADS);
|
|
|
|
glVertex3f (-0.25, 0., 0.05);
|
|
|
|
glVertex3f (0.05, 0., 0.05);
|
|
|
|
glVertex3f (0.05, 0., -0.05);
|
|
|
|
glVertex3f (-0.25, 0., -0.05);
|
|
|
|
glEnd ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DrawShipPart (Engine::EntityBase *entity) {
|
|
|
|
unsigned int i;
|
|
|
|
mShipPartsSprite.SetScale (1. / mShipSprite.GetHeight());
|
|
|
|
|
|
|
|
for (i = 0; i < mShipPartsEntityIds.size(); i++) {
|
|
|
|
if (mShipPartsEntityIds.at(i) == entity->mId) {
|
|
|
|
mShipPartsSprite.DrawSubAt (i, 0., 0., 0.);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DRAW_BOUNDARIES
|
|
|
|
glColor3f (1., 1., 1.);
|
|
|
|
DrawCircle (entity->mPhysicState->mRadius, 20);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|