From 1f95c377b2abfaa454b1f2298af10956d95ad941 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 13 Feb 2008 00:40:59 +0000 Subject: split client from game module --- src/client/draw.cc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/client/draw.cc') diff --git a/src/client/draw.cc b/src/client/draw.cc index 8d83ba8..021cf3a 100644 --- a/src/client/draw.cc +++ b/src/client/draw.cc @@ -1,10 +1,10 @@ /* - draw.cc + client/draw.cc This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ -// projet headers +#include "core/player.h" #include "render/render.h" #include "render/sphere.h" #include "render/box.h" @@ -89,13 +89,16 @@ math::Vector3f v6(-1.0f, 1.0f, 1.0f); math::Vector3f v7(-1.0f, -1.0f, 1.0f); float angle = 0; -void draw_ship(game::Ship *ship, float elapsed) +void draw_ship(core::EntityControlable *entity) { using math::Vector3f; using math::Color; using namespace render; - gl::rotate(ship->yaw(), 0.0f, 1.0f, 0.0f ); + gl::push(); + gl::translate(entity->location); + gl::scale(0.2f, 0.2f, 0.2f); + gl::rotate(entity->direction, 0.0f, 1.0f, 0.0f ); Vector3f tl(0.25, 0.125, 0.125); Vector3f br(-0.25, -0.125, -0.125); @@ -124,14 +127,14 @@ void draw_ship(game::Ship *ship, float elapsed) cockpit.bottomcolor = engine1.bottomcolor; cockpit.draw(); - if(ship->thrust() > 0 ) { + if(entity->target_thrust > 0 ) { gl::color(1.0f,0 ,0 ); gl::begin(gl::Lines); gl::vertex(-0.5f, 0, 0.185); - gl::vertex(-0.5f-0.25f*ship->thrust(), 0, 0.185); + gl::vertex(-0.5f-0.25f*entity->target_thrust, 0, 0.185); gl::vertex(-0.5f, 0, -0.185f); - gl::vertex(-0.5f-0.25f*ship->thrust(), 0, -0.185f); + gl::vertex(-0.5f-0.25f*entity->target_thrust, 0, -0.185f); gl::end(); } @@ -156,6 +159,8 @@ void draw_ship(game::Ship *ship, float elapsed) gl::vertex(v7); gl::vertex(v4); gl::end(); + + gl::pop(); } void draw_spacegrid() @@ -192,10 +197,10 @@ void draw_spacegrid() end(); } -void draw_world(float elapsed) +void draw_world(float seconds) { // used for animations - angle += 180.0f * elapsed; + angle += 180.0f * seconds; if( angle > 360.0f ) { angle -= 360.0f; } @@ -208,18 +213,13 @@ void draw_world(float elapsed) case core::entity::Default: draw_entity_default((*it)); break; + case core::entity::Controlable: + draw_ship(static_cast(*it)); default: break; } } - // draw the ship - gl::push(); - gl::translate(game.ship->location); - gl::scale(0.2f, 0.2f, 0.2f); - draw_ship(game.ship, elapsed); - gl::pop(); - // draw the background grid draw_spacegrid(); } -- cgit v1.2.3