--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Graphics/GameView.cc Wed Jan 21 01:57:24 2009 +0200
@@ -0,0 +1,48 @@
+
+#include "GameView.hh"
+
+namespace graphics
+{
+
+
+void GameView::draw (Display *display) {
+ CL_GraphicContext *gc = display->get_gc();
+
+ // calculate camera
+ PixelCoordinate camera(0, 0);
+
+ // ...to track our local player
+ if (player != NULL) {
+ // display resolution
+ PixelCoordinate resolution = display->getResolution();
+
+ // try and center the screen on the player
+ PixelCoordinate target = player->getCoordinate() - PixelCoordinate(resolution.x / 2, (resolution.y - 100) / 2);
+
+ // ...but keep the world in view
+ PixelCoordinate max = state.terrain.getDimensions() - resolution + PixelCoordinate(0, 100);
+
+ // ...by limiting the value to 0...max
+ camera = PixelCoordinate(
+ value_between(0, target.x, max.x),
+ value_between(0, target.y, max.y)
+ );
+ }
+
+ // Black background
+ gc->clear(CL_Color::black);
+
+ // Draw the game
+ state.draw(this, camera, flags & GUI_INPUT_DISPLAY_WEAPON);
+
+ // draw player info box
+ if (player != NULL) {
+ draw_player_info(gc, player);
+ }
+
+ // draw messages
+ message_view.draw(this);
+}
+
+
+};