# HG changeset patch # User Tero Marttila # Date 1232572042 -7200 # Node ID 721c60072091c7f0d7e50ac0db64c40c8d81b7b3 # Parent 106aaf6eadfe3f773bb3e0b924d2722fa5942f9b new graphics code compiles... no, it doesn't work yet diff -r 106aaf6eadfe -r 721c60072091 src/Application.cc --- a/src/Application.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Application.cc Wed Jan 21 23:07:22 2009 +0200 @@ -200,7 +200,6 @@ int Main::main (int argc, char **argv) { // initialize the ClanLib components that we use CL_SetupCore setup_core; - CL_SetupNetwork setup_network; CL_SetupDisplay setup_disp; CL_SetupGL setup_gl; diff -r 106aaf6eadfe -r 721c60072091 src/CMakeLists.txt --- a/src/CMakeLists.txt Wed Jan 21 03:33:35 2009 +0200 +++ b/src/CMakeLists.txt Wed Jan 21 23:07:22 2009 +0200 @@ -1,19 +1,32 @@ -FILE(GLOB SOURCE_FILES "*.cc" "Network/*.cc" "Graphics/*.cc") -FILE(GLOB HEADER_FILES "*.hh" "Network/*.hh" "Graphics/*.hh") +FILE(GLOB SOURCE_FILES "*.cc" "Network/*.cc") +FILE(GLOB HEADER_FILES "*.hh" "Network/*.hh") set_source_files_properties("version.c" PROPERTIES GENERATED true) -set(SOURCES ${SOURCE_FILES} ${HEADER_FILES} "version.c") # Generate config.h configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) include_directories("${CMAKE_CURRENT_BINARY_DIR}") +# main module +set (CORE_CLANLIB_COMPONENTS Core App Signals) +set (CORE_SOURCES ${SOURCE_FILES} ${HEADER_FILES}) + +# Graphics module +add_subdirectory(Graphics) + # Libraries +set (CLANLIB_VERSION 0.8) +set (CLANLIB_COMPONENTS ${CORE_CLANLIB_COMPONENTS} ${GRAPHICS_CLANLIB_COMPONENTS}) # ClanLib 0.8 -find_package(ClanLib 0.8 REQUIRED COMPONENTS Core App Signals Display GL Sound Network) +message (STATUS "Finding ClanLib version=${CLANLIB_VERSION}, components=${CLANLIB_COMPONENTS}" ) +find_package(ClanLib ${CLANLIB_VERSION} REQUIRED COMPONENTS ${CLANLIB_COMPONENTS}) + include_directories(${ClanLib_INCLUDE_DIRS}) + +# build list of libs/source files set(LIBS ${LIBS} ${ClanLib_LIBRARIES}) +set(SOURCES ${CORE_SOURCES} ${GRAPHICS_SOURCES} "version.c") # Assumes the project generates only one executable. If you need more, you'll need to alter # the script and replace ${PROJECT_SHORT_NAME} by executable name. diff -r 106aaf6eadfe -r 721c60072091 src/Config.hh --- a/src/Config.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Config.hh Wed Jan 21 23:07:22 2009 +0200 @@ -1,16 +1,21 @@ #ifndef CONFIG_HH #define CONFIG_HH -// XXX: merge this as Config.hh.in? +/** + * @file + * + * Various constants used to define application/game behaviour + */ + +// build settings #include "config.h" +// custom types #include "Types.hh" +// for CL_Color #include -// This is a temporary way to declare different constants. Maybe we -// should do somekind of resource manager? Do we have time? - /** * The value of pi used in physics/graphics calculations */ diff -r 106aaf6eadfe -r 721c60072091 src/GameState.cc --- a/src/GameState.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/GameState.cc Wed Jan 21 23:07:22 2009 +0200 @@ -50,9 +50,9 @@ event_handler->on_player_left(player); } -void GameState::draw(Graphics *g, PixelCoordinate camera, bool displayWeapon) { +void GameState::draw (graphics::Display &display, PixelCoordinate camera, bool displayWeapon) { // Draw terrain - terrain.draw(g, camera); + terrain.draw(display, camera); // Draw players for (std::list::iterator it = player_list.begin(); it != player_list.end(); it++) { @@ -60,14 +60,14 @@ // our LocalPlayer has it's own draw method if (p == local_player) - local_player->draw(g, displayWeapon, camera); + local_player->draw(display, displayWeapon, camera); else - p->draw(g, camera); + p->draw(display, camera); } // Draw projectiles for (std::list::iterator it = projectiles.begin(); it != projectiles.end(); it++) { - (*it)->draw(g, camera); + (*it)->draw(display, camera); } } diff -r 106aaf6eadfe -r 721c60072091 src/GameState.hh --- a/src/GameState.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/GameState.hh Wed Jan 21 23:07:22 2009 +0200 @@ -8,9 +8,10 @@ #include "Projectile.hh" #include "Rope.hh" #include "Input.hh" -#include "GraphicsPointer.hh" #include "Config.hh" +#include "Graphics/Drawable.hh" + #include #include #include @@ -97,7 +98,7 @@ /** * Draws the terrain, players and projectiles */ - virtual void draw (Graphics *g, PixelCoordinate camera, bool displayWeapon); + virtual void draw (graphics::Display &display, PixelCoordinate camera, bool displayWeapon); }; #endif diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Graphics/CMakeLists.txt Wed Jan 21 23:07:22 2009 +0200 @@ -0,0 +1,7 @@ +FILE(GLOB GRAPHICS_SOURCE_FILES "*.cc") +FILE(GLOB GRAPHICS_HEADER_FILES "*.hh") + +# what ClanLib components we need +set (GRAPHICS_CLANLIB_COMPONENTS Display GL GUI PARENT_SCOPE) +set (GRAPHICS_SOURCES ${GRAPHICS_SOURCE_FILES} ${GRAPHICS_HEADER_FILES} PARENT_SCOPE) + diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/Console.hh --- a/src/Graphics/Console.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/Console.hh Wed Jan 21 23:07:22 2009 +0200 @@ -1,7 +1,8 @@ #ifndef GRAPHICS_CONSOLE_HH #define GRAPHICS_CONSOLE_HH -#include +#include "GUI.hh" + #include namespace graphics diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/Display.cc --- a/src/Graphics/Display.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/Display.cc Wed Jan 21 23:07:22 2009 +0200 @@ -1,5 +1,6 @@ #include "Display.hh" +#include "../Error.hh" namespace graphics { @@ -22,7 +23,7 @@ } else { CL_DisplayMode best_mode = getBestMode(); - fullscreen_resolution = PixelCoordinate(best_mode.get_resolution().width, best_mode.get_resolution().height); + fullscreen_resolution = PixelDimensions(best_mode.get_resolution().width, best_mode.get_resolution().height); } } @@ -31,7 +32,7 @@ } const CL_DisplayMode Display::getBestMode (void) { - const std::vector &modes = Graphics::getDisplayModes(); + const std::vector &modes = getDisplayModes(); const CL_DisplayMode *best_mode = NULL; @@ -65,7 +66,7 @@ // do we have something to draw? if (target) { // draw it - target->draw(this); + target->draw(*this); // flip buffers, sync flip(1); @@ -73,6 +74,9 @@ } void Display::on_window_resize (int new_x, int new_y) { + (void) new_x; + (void) new_y; + // ignore resize in fullscreen mode if (is_fullscreen()) return; diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/Display.hh --- a/src/Graphics/Display.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/Display.hh Wed Jan 21 23:07:22 2009 +0200 @@ -1,6 +1,9 @@ #ifndef GRAPHICS_DISPLAY_HH #define GRAPHICS_DISPLAY_HH +#include "../Types.hh" +#include "../Config.hh" + namespace graphics { @@ -20,8 +23,6 @@ } #include "Drawable.hh" -#include "../Types.hh" -#include "../Config.hh" #include "../Timer.hh" #include diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/Drawable.hh --- a/src/Graphics/Drawable.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/Drawable.hh Wed Jan 21 23:07:22 2009 +0200 @@ -21,7 +21,7 @@ /** * Draw graphics onto the given display */ - virtual void draw (Display *display) = 0; + virtual void draw (Display &display) = 0; }; } diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/GUI.hh --- a/src/Graphics/GUI.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/GUI.hh Wed Jan 21 23:07:22 2009 +0200 @@ -6,7 +6,7 @@ #include -namespace Graphics +namespace graphics { /** diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/GUIStyle.hh --- a/src/Graphics/GUIStyle.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/GUIStyle.hh Wed Jan 21 23:07:22 2009 +0200 @@ -1,8 +1,9 @@ #ifndef GRAPHICS_GUI_STYLE_HH #define GRAPHICS_GUI_STYLE_HH -#include -#include +#include "GUI.hh" + +#include namespace graphics { @@ -10,13 +11,13 @@ /** * Our CL_StyleManager used for drawing ClanLib's GUI components */ -class GUIStyle : public CL_StyleManager_Boring { +class GUIStyle : public CL_StyleManager_Silver { public: /** * Construct GUI style */ GUIStyle (CL_ResourceManager *resources) : - CL_StyleManager_Boring(resources) + CL_StyleManager_Silver(resources) { } @@ -24,10 +25,10 @@ /** * Handle attaching style objects to components */ - virtual void connect_styles (const std::string &type, CL_Component *owner) { + virtual void connect_styles (const std::string &type, CL_Component *component) { // default to parent impl - CL_StyleManager_Boring::connect_styles(type, component); + CL_StyleManager_Silver::connect_styles(type, component); } }; diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/GameView.cc --- a/src/Graphics/GameView.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/GameView.cc Wed Jan 21 23:07:22 2009 +0200 @@ -8,15 +8,16 @@ { GameView::GameView (GameState &state, LocalPlayer *player) : - View(PixelArea(0, 0, graphics->display.get_width, graphics->display.get_height)), - state(state), player(NULL), info_view(NULL), message_view(getMessageViewArea()) + View(PixelArea(0, 0, graphics->display.get_width(), graphics->display.get_height())), + state(state), player(NULL), info_view(NULL), message_view(getMessageViewArea()), + flags(0) { // have player? if (player) setPlayer(player); // insert message - message_view.add_message("Hello World!"); + message_view.add_message(CL_Color::white, "Hello World!"); } void GameView::setPlayer (LocalPlayer *player) { @@ -29,9 +30,25 @@ info_view = new PlayerInfoView(getInfoViewArea(), player); } +/* + * Helper function for Camera + */ +static PixelDimension value_between (PixelDimension low, PixelDimension value, PixelDimension high) { + if (high < low) + return (high + low) / 2; -void GameView::draw (Display *display) { - CL_GraphicContext *gc = display->get_gc(); + else if (value < low) + return low; + + else if (value > high) + return high; + + else + return value; +} + +void GameView::draw (Display &display) { + CL_GraphicContext *gc = display.get_gc(); // calculate camera PixelCoordinate camera(0, 0); @@ -39,7 +56,7 @@ // ...to track our local player if (player != NULL) { // display resolution - PixelCoordinate resolution = display->getResolution(); + PixelCoordinate resolution = display.getResolution(); // try and center the screen on the player PixelCoordinate target = player->getCoordinate() - PixelCoordinate(resolution.x / 2, (resolution.y - 100) / 2); @@ -58,14 +75,14 @@ gc->clear(CL_Color::black); // Draw the game - state.draw(this, camera, flags & GUI_INPUT_DISPLAY_WEAPON); + state.draw(display, camera, flags & GUI_INPUT_DISPLAY_WEAPON); // draw info view? if (info_view) info_view->draw(display); // draw messages - message_view.draw(this); + message_view.draw(display); } void GameView::resize (const PixelArea &new_area) { @@ -78,7 +95,7 @@ message_view.resize(getMessageViewArea()); // log message - message_view.add_message(CL_Color::yellow, CL_String::format("[ Resized window to %1 x %2 ]", getWidth(), getHeight())); + message_view.add_message(CL_Color::yellow, CL_String::format("[ Resized window to %1 x %2 ]", (int) getWidth(), (int) getHeight())); } diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/GameView.hh --- a/src/Graphics/GameView.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/GameView.hh Wed Jan 21 23:07:22 2009 +0200 @@ -6,6 +6,8 @@ #include "MessageView.hh" #include "../GameState.hh" +#include "../Input.hh" + namespace graphics { @@ -29,6 +31,11 @@ * The message list view */ MessageView message_view; + + /** + * Input flags + */ + GuiInput flags; public: /** @@ -61,7 +68,7 @@ /** * Draw this view onto the given display */ - virtual void draw (Display *display); + virtual void draw (Display &display); /** * Resize sub-views diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/Graphics.cc --- a/src/Graphics/Graphics.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/Graphics.cc Wed Jan 21 23:07:22 2009 +0200 @@ -7,10 +7,11 @@ { // initialize the global graphics object -static Graphics *graphics = NULL; +Graphics *graphics = NULL; Graphics::Graphics (Engine &engine, CL_ResourceManager &resources, const DisplayConfig &display_config) : - engine(engine), fonts(resources), display(display_config) + // display must be set up before fonts, due to implicit CL_DisplayWindow + engine(engine), display(display_config), fonts(resources) { assert(!graphics); diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/Graphics.hh --- a/src/Graphics/Graphics.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/Graphics.hh Wed Jan 21 23:07:22 2009 +0200 @@ -1,6 +1,13 @@ #ifndef GRAPHICS_GRAPHICS_HH #define GRAPHICS_GRAPHICS_HH +namespace graphics +{ + +class Graphics; + +} + #include "../Engine.hh" #include "Display.hh" #include "FontManager.hh" @@ -20,15 +27,15 @@ Engine &engine; /** + * Our primary display + */ + Display display; + + /** * For loading fonts */ FontManager fonts; - - /** - * Our primary display - */ - Display display; - + /** * Initialize the graphics subsystem */ diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/MessageView.cc --- a/src/Graphics/MessageView.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/MessageView.cc Wed Jan 21 23:07:22 2009 +0200 @@ -1,6 +1,6 @@ +#include "MessageView.hh" #include "Graphics.hh" -#include "MessageView.hh" namespace graphics { @@ -17,7 +17,7 @@ messages.push_back(msg); } -void MessageView::draw (Display *display) { +void MessageView::draw (Display &display) { // get font CL_Font &font = graphics->fonts.getSimpleFont(); @@ -46,7 +46,7 @@ break; // draw text - font.draw(CL_Rect(area.left, offset_this, area.right, offset_prev), it->message, g->get_gc()); + font.draw(CL_Rect(area.left, offset_this, area.right, offset_prev), it->message, display.get_gc()); // advance offset offset_prev = offset_this; diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/MessageView.hh --- a/src/Graphics/MessageView.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/MessageView.hh Wed Jan 21 23:07:22 2009 +0200 @@ -40,7 +40,7 @@ /** * Draw as many messages as fits */ - virtual void draw (Display *display); + virtual void draw (Display &display); }; } diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/PlayerInfoView.cc --- a/src/Graphics/PlayerInfoView.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/PlayerInfoView.cc Wed Jan 21 23:07:22 2009 +0200 @@ -1,13 +1,17 @@ #include "PlayerInfoView.hh" +#include "Graphics.hh" #include namespace graphics { -void PlayerInfoView::draw (Display *display) { - CL_GraphicContext *gc = display->get_gc(); +void PlayerInfoView::draw (Display &display) { + CL_GraphicContext *gc = display.get_gc(); + CL_Font font = graphics->fonts.getSimpleFont(); + + int bar_length = 3; // draw status info at bottom of display gc->fill_rect( @@ -21,6 +25,8 @@ ); // Health + double health_percent = player->getHealthPercent(); + gc->draw_rect( CL_Rect( area.left + 9, @@ -35,45 +41,45 @@ CL_Rect( area.left + 10, area.top + 10, - area.left + 10 + (int) (p->getHealthPercent() * bar_length), + area.left + 10 + (int) (health_percent * bar_length), area.top + 30 ), CL_Gradient( CL_Color(200, 0, 0), - CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0), + CL_Color(200 - (int)(health_percent * 2), (int)(health_percent * 2), 0), CL_Color(200, 0, 0), - CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0) + CL_Color(200 - (int)(health_percent * 2), (int)(health_percent * 2), 0) ) ); // stats - kills std::stringstream sskills; - sskills << "Kills: " << p->getKills(); - getSimpleFont().draw( + sskills << "Kills: " << player->getKills(); + font.draw( area.left + 20 + 100 * bar_length, area.top + 10, sskills.str(), - get_gc() + display.get_gc() ); // stats - deaths std::stringstream ssdeaths; - ssdeaths << "Deaths: " << p->getDeaths(); - getSimpleFont().draw( + ssdeaths << "Deaths: " << player->getDeaths(); + font.draw( area.left + 20 + 100 * bar_length, area.top + 30, ssdeaths.str(), - get_gc() + display.get_gc() ); // stats - ratio std::stringstream ssratio; - ssratio << "Ratio: " << (p->getKills()+1) / (p->getDeaths()+1); - getSimpleFont().draw( + ssratio << "Ratio: " << (player->getKills() + 1) / (player->getDeaths() + 1); + font.draw( area.left + 20 + 100 * bar_length, area.top + 50, ssratio.str(), - get_gc() + display.get_gc() ); @@ -92,7 +98,9 @@ CL_Rect( area.left + 10, area.top + 70, - area.left + 10 + (100 - (int) (p->getCurrentWeapon()->getReloadTimer() * 100 / p->getCurrentWeapon()->getReloadTime())) * bar_length, + area.left + 10 + (100 - (int) ( + player->getCurrentWeapon()->getReloadTimer() * 100 / player->getCurrentWeapon()->getReloadTime() + )) * bar_length, area.top + 90 ), CL_Gradient( @@ -104,11 +112,11 @@ ); // current weapon name - getSimpleFont().draw( + font.draw( area.left + 20 + 100 * bar_length, area.top + 70, - p->getCurrentWeapon()->getName(), - get_gc() + player->getCurrentWeapon()->getName(), + display.get_gc() ); } diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/PlayerInfoView.hh --- a/src/Graphics/PlayerInfoView.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/PlayerInfoView.hh Wed Jan 21 23:07:22 2009 +0200 @@ -29,7 +29,7 @@ /** * Draw the player info onto the given display */ - virtual void draw (Display *display); + virtual void draw (Display &display); }; } diff -r 106aaf6eadfe -r 721c60072091 src/Graphics/View.hh --- a/src/Graphics/View.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Graphics/View.hh Wed Jan 21 23:07:22 2009 +0200 @@ -1,6 +1,7 @@ #ifndef GRAPHICS_VIEW_HH #define GRAPHICS_VIEW_HH +#include "Drawable.hh" #include "../Types.hh" namespace graphics diff -r 106aaf6eadfe -r 721c60072091 src/Logger.cc --- a/src/Logger.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Logger.cc Wed Jan 21 23:07:22 2009 +0200 @@ -26,21 +26,3 @@ #endif } -std::ostream& operator<< (std::ostream &s, CL_NetComputer &c) { - s << "[" << c.get_address().get_address() << ":" << c.get_address().get_port() << "]"; - - return s; -} - -std::ostream& operator<< (std::ostream &s, CL_NetObject_Server &obj) { - s << "%" << obj.get_obj_id(); - - return s; -} - -std::ostream& operator<< (std::ostream &s, CL_NetObject_Client &obj) { - s << "%" << obj.get_obj_id(); - - return s; -} - diff -r 106aaf6eadfe -r 721c60072091 src/Player.cc --- a/src/Player.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Player.cc Wed Jan 21 23:07:22 2009 +0200 @@ -2,7 +2,8 @@ #include "Player.hh" #include "Weapons.hh" #include "Engine.hh" -#include "Graphics.hh" + +#include "Graphics/Graphics.hh" #include #include @@ -324,14 +325,14 @@ kills++; } -void Player::draw (Graphics *g, PixelCoordinate camera) { - CL_GraphicContext *gc = g->get_gc(); +void Player::draw (graphics::Display &display, PixelCoordinate camera) { + CL_GraphicContext *gc = display.get_gc(); if (!isAlive()) return; // draw rope behind player - rope.draw(g, camera); + rope.draw(display, camera); // animation indexes int aim_img_idx = (int)((1 - (getAim() + KG_PI / 2) / KG_PI) * img_num_aim); @@ -375,22 +376,26 @@ ); } -void LocalPlayer::draw (Graphics *g, bool displayWeapon, PixelCoordinate camera) { +void LocalPlayer::draw (graphics::Display &display, bool displayWeapon, PixelCoordinate camera) { // superclass draw - Player::draw(g, camera); + Player::draw(display, camera); // display weapon name? if (isAlive() && displayWeapon && getCurrentWeapon()) { const std::string weaponName = getCurrentWeapon()->getName(); + + // position + PixelCoordinate pc = getCoordinate() - camera; - PixelCoordinate pc = getCoordinate() - camera; + // get font + CL_Font &font = graphics::graphics->fonts.getSimpleFont(); // XXX: fix magic constants once we know how big the worm is - g->getSimpleFont().draw( - pc.x - g->getSimpleFont().get_width(weaponName) / 2, - pc.y - 20, - weaponName, - g->get_gc() + font.draw( + pc.x - font.get_width(weaponName) / 2, + pc.y - 20, + weaponName, + display.get_gc() ); } } diff -r 106aaf6eadfe -r 721c60072091 src/Player.hh --- a/src/Player.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Player.hh Wed Jan 21 23:07:22 2009 +0200 @@ -12,6 +12,7 @@ #include "Input.hh" #include "Rope.hh" #include "Types.hh" + #include "Graphics/Drawable.hh" #include @@ -160,9 +161,16 @@ /** * Draw this player */ - virtual void draw (Display *display, PixelCoordinate camera); + virtual void draw (graphics::Display &display, PixelCoordinate camera); + + /** + * Returns statistics on the number of kills for this player + */ + uint16_t getKills() { return kills; } - uint16_t getKills() { return kills; } + /** + * Returns statistics on the number of deaths for this player + */ uint16_t getDeaths() { return deaths; } }; @@ -195,7 +203,7 @@ /** * As Player, but also draws the current weapon name if displayWeapon */ - virtual void draw (Display *display, bool displayWeapon, PixelCoordinate camera); + virtual void draw (graphics::Display &display, bool displayWeapon, PixelCoordinate camera); }; /** diff -r 106aaf6eadfe -r 721c60072091 src/Projectile.cc --- a/src/Projectile.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Projectile.cc Wed Jan 21 23:07:22 2009 +0200 @@ -1,5 +1,4 @@ #include "Projectile.hh" -#include "Graphics.hh" #include "Timer.hh" @@ -75,8 +74,8 @@ PhysicsObject::tick(dt); } -void Projectile::draw(Graphics *g, PixelCoordinate camera) const { - CL_GraphicContext *gc = g->get_gc(); +void Projectile::draw(graphics::Display &display, PixelCoordinate camera) const { + CL_GraphicContext *gc = display.get_gc(); if (visible) { PixelCoordinate pos = getCoordinate() - camera; diff -r 106aaf6eadfe -r 721c60072091 src/Projectile.hh --- a/src/Projectile.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Projectile.hh Wed Jan 21 23:07:22 2009 +0200 @@ -8,7 +8,8 @@ #include "PhysicsObject.hh" #include "Timer.hh" #include "Types.hh" -#include "GraphicsPointer.hh" + +#include "Graphics/Drawable.hh" /** * A projectile is a flying PhysicsObject, created by firing a player's weapon. It has an initial velocity, is @@ -49,7 +50,7 @@ /** * Draw */ - virtual void draw (Graphics *g, PixelCoordinate camera) const; + virtual void draw (graphics::Display &display, PixelCoordinate camera) const; /** * Get damage inflicted by this projectile. diff -r 106aaf6eadfe -r 721c60072091 src/Rope.cc --- a/src/Rope.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Rope.cc Wed Jan 21 23:07:22 2009 +0200 @@ -1,7 +1,7 @@ #include "Player.hh" #include "Rope.hh" #include "Engine.hh" -#include "Graphics.hh" + #include #include @@ -150,7 +150,7 @@ this->length = length; } -void Rope::draw (Graphics *g, PixelCoordinate camera) { +void Rope::draw (graphics::Display &display, PixelCoordinate camera) { PixelCoordinate player_pos = player.getCoordinate() - camera; PixelCoordinate target_pos; @@ -175,7 +175,7 @@ target_pos -= camera; // draw a line from the player to the target chosen above - g->get_gc()->draw_line( + display.get_gc()->draw_line( player_pos.x, player_pos.y, target_pos.x, target_pos.y, ROPE_COLOR_DARK diff -r 106aaf6eadfe -r 721c60072091 src/Rope.hh --- a/src/Rope.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Rope.hh Wed Jan 21 23:07:22 2009 +0200 @@ -7,7 +7,8 @@ #include "Player.hh" #include "PhysicsObject.hh" -#include "GraphicsPointer.hh" + +#include "Graphics/Drawable.hh" /** * The rope can be in one of three states... @@ -84,9 +85,9 @@ virtual void tick (TimeMS dt); /* - * Just draws it + * Draw the rope, in the FLYING/FIXED state */ - virtual void draw (Graphics *c, PixelCoordinate camera); + virtual void draw (graphics::Display &display, PixelCoordinate camera); }; #endif diff -r 106aaf6eadfe -r 721c60072091 src/Terrain.cc --- a/src/Terrain.cc Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Terrain.cc Wed Jan 21 23:07:22 2009 +0200 @@ -1,5 +1,5 @@ + #include "Terrain.hh" -#include "Graphics.hh" #include "Engine.hh" #include @@ -20,7 +20,7 @@ Terrain::Terrain (const TerrainConfig &config) : terrain_buf(NULL), - width(config.dimensions.x), height(config.dimensions.y) + width(config.dimensions.width), height(config.dimensions.height) { // allocate terrain_buf terrain_buf = new TerrainPixel[width * height]; @@ -410,13 +410,13 @@ return normal; } -void Terrain::draw (Graphics *g, PixelCoordinate camera) { +void Terrain::draw (graphics::Display &display, PixelCoordinate camera) { // XXX: can we optimize this somehow? // load the terrain pixbuf as a surface CL_Surface surf (pixbuf); // draw it onto the graphics, offset by camera position - surf.draw(-camera.x, -camera.y, g->get_gc()); + surf.draw(-camera.x, -camera.y, display.get_gc()); } diff -r 106aaf6eadfe -r 721c60072091 src/Terrain.hh --- a/src/Terrain.hh Wed Jan 21 03:33:35 2009 +0200 +++ b/src/Terrain.hh Wed Jan 21 23:07:22 2009 +0200 @@ -2,10 +2,11 @@ #define TERRAIN_HH #include "Vector.hh" -#include "GraphicsPointer.hh" #include "Types.hh" #include "Config.hh" +#include "Graphics/Drawable.hh" + /** * Different types of terrain available */ @@ -246,7 +247,7 @@ * @param gc Graphics to draw on * @param camera view position */ - virtual void draw (Graphics *g, PixelCoordinate camera = PixelCoordinate(0, 0)); + virtual void draw (graphics::Display &display, PixelCoordinate camera = PixelCoordinate(0, 0)); }; #endif