[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.cxx,1.3,1.4 graph.hxx,
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.cxx,1.3,1.4 graph.hxx,1.5,1.6 manager.cxx,1.8,1.9 manager.hxx,1.8,1.9 node.hxx,1.4,1.5 pingus.hxx,1.7,1.8 worldmap.cxx,1.8,1.9 worldmap.hxx,1.7,1.8 |
Date: |
7 Sep 2002 19:29:06 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/worldmap
In directory dark:/tmp/cvs-serv32357/worldmap
Modified Files:
graph.cxx graph.hxx manager.cxx manager.hxx node.hxx
pingus.hxx worldmap.cxx worldmap.hxx
Log Message:
some docu, some blabla and the worldmap stuff needs a complete rewrite...
Index: graph.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/graph.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- graph.cxx 16 Aug 2002 15:14:00 -0000 1.3
+++ graph.cxx 7 Sep 2002 19:29:04 -0000 1.4
@@ -163,9 +163,6 @@
void
Graph::draw (const CL_Vector& offset)
{
- //float x_scale = CL_Display::get_width () / 800.0;
- //float y_scale = CL_Display::get_height () / 600.0;
-
for (iterator i = nodes.begin();
i != nodes.end();
++i)
Index: graph.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/graph.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- graph.hxx 23 Aug 2002 15:49:56 -0000 1.5
+++ graph.hxx 7 Sep 2002 19:29:04 -0000 1.6
@@ -28,7 +28,30 @@
{
namespace WorldMap
{
+#if 0
+ /** */
+ class Graph
+ {
+ public:
+ /** Load a graph from file */
+ Graph (const std::string& filename);
+ ~Graph ();
+
+ /** Draw the graph to the given GC
+ @param gc The GraphicContext to draw on */
+ void draw (GraphicContext& gc);
+ /** @return a reference to the nodes of this graph */
+ const std::vector<>& get_nodes ();
+
+ /** @return a reference to the edges of this graph */
+ const std::vector<>& get_edges ();
+ };
+#endif
+
+ /** The path on the WorldMap is a bidirectional graph, this class
+ managed it FIXME: needs a complete rewrite, EmptyNodes need to
+ be handled differently */
class Graph
{
private:
@@ -44,20 +67,55 @@
Graph ();
~Graph ();
+ /** FIXME: We shouldn't have a background, but instead multiple
+ layers of images */
ResDescriptor get_background ();
- //Graph<Node>* get_graph ();
+
+ /** @return The name of the music file which should be used for
+ @return this level, filename is relative to "data/music/"
+ @return Example: pingus1.it */
std::string get_music ();
-
- void draw (const CL_Vector&);
- /// Some functions to parse the data out of an xml file
- //@{
+ /** Draw the edges of the graph to the screen
+ @param offset FIXME: should be handled by GraphicContext instead */
+ void draw (const CL_Vector& offset);
+
+ /** Some functions to parse the data out of an xml file
+
+ File Syntax (FIXME: the current implementation is different):
+
+ <pingus-worldmap>
+ <graph>
+ <nodes>
+ <node id="node_1">
+ <position>...</>
+ <data><tube>...</></>
+ </node>
+ <node id="node_2">
+ <position>...</>
+ <data><level>...</></>
+ </node>
+ ...
+ <nodes>
+ <edges>
+ <edge id="egde_1" source="1" destination="2">
+ <!-- The path which connect two nodes -->
+ <data>
+ <position>...</>
+ <position>...</>
+ </data>
+ </edge>
+ </edges>
+ <graph>
+ </pingus-worldmap>
+
+ @{ */
void parse_file (std::string filename);
private:
void parse_node_list (xmlNodePtr);
void parse_music (xmlNodePtr);
void parse_background (xmlNodePtr);
- //@}
+ /** @} */
Graph (const Graph&);
Graph operator= (const Graph&);
Index: manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/manager.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- manager.cxx 5 Sep 2002 12:24:02 -0000 1.8
+++ manager.cxx 7 Sep 2002 19:29:04 -0000 1.9
@@ -35,12 +35,11 @@
is_init = false;
exit_worldmap = false;
- init ();
-
+ // FIXME: The default startup map should be configurable by some file
worldmap = boost::shared_ptr<WorldMap::WorldMap>
(new WorldMap::WorldMap (path_manager.complete("worldmaps/volcano.xml")));
- worldmap->init ();
+ worldmap->on_startup ();
// FIXME: a bit ugly because of the proteced member, but should work
// FIXME: well enough. GUIScreen could also use multi-inheritage,
@@ -58,40 +57,6 @@
{
}
-void
-WorldMapManager::init ()
-{
- if (!is_init)
- {
- //sur = PingusResource::load_surface ("volcano", "worldmaps");
- is_init = true;
- }
-}
-
- /*
-
-void
-WorldMapManager::display ()
-{
- DeltaManager delta;
- while (!worldmap->do_exit ())
- {
- worldmap->draw ();
- worldmap->update (delta.getset ());
-
- if (new_worldmap.get ())
- {
- worldmap = new_worldmap;
- new_worldmap = boost::shared_ptr<WorldMap::WorldMap>();
- }
-
- CL_System::sleep (20);
- CL_System::keep_alive ();
- Display::flip_display ();
- }
-}
- */
-
void
WorldMapManager::on_escape_press ()
{
@@ -102,8 +67,16 @@
void
WorldMapManager::update (float)
{
+ // Exit the word
if (exit_worldmap)
ScreenManager::instance ()->pop_screen ();
+
+ // Check if new worldmap is set and if so, change it
+ if (new_worldmap.get ())
+ {
+ worldmap = new_worldmap;
+ new_worldmap = boost::shared_ptr<WorldMap::WorldMap>();
+ }
}
void
@@ -115,7 +88,6 @@
void
WorldMapManager::WorldMapComponent::update (float delta)
{
- //std::cout << "update press" << std::endl;
WorldMapManager::instance ()->worldmap->update (delta);
}
@@ -129,6 +101,7 @@
void
WorldMapManager::change_map (const std::string& filename, int node)
{
+ // Create the new worldmap and make it the current one
new_worldmap = boost::shared_ptr<WorldMap::WorldMap>
(new WorldMap::WorldMap (path_manager.complete("worldmaps/" + filename)));
new_worldmap->set_pingus (node);
Index: manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/manager.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- manager.hxx 5 Sep 2002 12:24:02 -0000 1.8
+++ manager.hxx 7 Sep 2002 19:29:04 -0000 1.9
@@ -37,9 +37,12 @@
class WorldMap;
}
- /** */
+ /** The WorldMapManager manages the worldmaps and the translation
+ between two worldmaps */
class WorldMapManager : public GUIScreen
{
+ /** FIXME: Workaround class to let the worldmap play with well
+ FIXME: with the Screen, should be deleted at a later point. */
class WorldMapComponent : public GUI::Component
{
public:
@@ -72,18 +75,35 @@
public:
~WorldMapManager ();
+ /** Check if WorldMap manager still needs to run and exit if if
+ not */
void update (float);
+
+ /** @defgroup WorldMapManagerBindings Controller bindings of the
WorldMapManager
+ @{*/
+ /** Calculate the node that was clicked and set the pingu to walk
+ to that node. If a node is double-cliked, the pingu should go
+ faster. */
+ void on_primary_button_press (int x, int y);
+
+ /** Exit the WorldMapManager and return to the previous screen */
void on_escape_press ();
- void on_startup ();
- private:
- /// Load all required resources if not already done
- void init ();
+ /** @}*/
- public:
+ /** Change the current map to the given map
+
+ @param filename the filename of the new map, filename must be
+ @param filename relative to the worldmap directory
+ @param filename Example: "volcano.xml" */
void change_map (const std::string& filename, int node);
+
+ /** Singleton access function */
static WorldMapManager* instance ();
private:
+ /** Startup Hook of the Screen */
+ void on_startup ();
+
WorldMapManager (const WorldMapManager&);
WorldMapManager operator= (const WorldMapManager&);
};
Index: node.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/node.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- node.hxx 23 Aug 2002 15:49:57 -0000 1.4
+++ node.hxx 7 Sep 2002 19:29:04 -0000 1.5
@@ -30,7 +30,7 @@
{
namespace WorldMap
{
- /** An object on the worldmap */
+ /** An node in the WorldmapGraph on which the Pingu walks */
class Node
{
public:
@@ -54,8 +54,10 @@
Node operator= (const Node&);
};
- /** A wrap object which brings you to the next worldmap */
- class TubeNode : public Node, public TubeNodeData
+ /** A wrap/beam object which brings you to the next worldmap
+ FIXME: Multi-Inheritage is evil */
+ class TubeNode : public Node,
+ public TubeNodeData
{
public:
std::string worldmap_name;
@@ -76,7 +78,8 @@
TubeNode operator= (const TubeNode&);
};
- /** The entrance to a level */
+ /** The entrance to a level
+ FIXME: Multi-Inheritage is evil */
class LevelNode : public Pingus::WorldMap::Node,
public Pingus::WorldMap::LevelNodeData
{
Index: pingus.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/pingus.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pingus.hxx 23 Aug 2002 15:49:57 -0000 1.7
+++ pingus.hxx 7 Sep 2002 19:29:04 -0000 1.8
@@ -46,10 +46,24 @@
void draw (const CL_Vector& offset);
void update (float delta);
+
+ /** Let the pingu walk to the given node
+ @param node The node to walk to */
void walk_to (Pingus::WorldMap::Node* node);
+
+ /** @return If the pingu is currently between two nodes return
+ true */
bool is_walking ();
+
+ /** Set the pingu to the position of a node */
void set_position (boost::shared_ptr<Pingus::WorldMap::Node> node);
+
+ /** @return Current position of the pingu on the screen */
CL_Vector get_pos () { return pos; }
+
+ /** @return The node where the pingu is current on
+
+ FIXME: What should happen if the pingu is between two nodes? */
Pingus::WorldMap::Node* get_node ();
private:
Index: worldmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/worldmap.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- worldmap.cxx 6 Sep 2002 17:33:29 -0000 1.8
+++ worldmap.cxx 7 Sep 2002 19:29:04 -0000 1.9
@@ -24,6 +24,7 @@
#include <ClanLib/Display/Input/keyboard.h>
#include <ClanLib/Display/Font/font.h>
#include <ClanLib/Display/Input/mouse.h>
+#include "../fonts.hxx"
#include "../path_manager.hxx"
#include "../system.hxx"
#include "../pingus_resource.hxx"
@@ -34,15 +35,12 @@
using namespace Pingus::WorldMap;
-WorldMap::WorldMap (std::string filename) :
- font (PingusResource::load_font ("Fonts/pingus_small", "fonts")),
- green_dot ("worldmap/dot_green", "core"),
- red_dot ("worldmap/dot_red", "core"),
- dot_border ("Game/dot_border", "game"),
- green_flag ("worldmap/flaggreen", "core"),
- catch_input (true),
- do_quit (false),
- last_node (0)
+WorldMap::WorldMap (std::string filename)
+ : green_dot ("worldmap/dot_green", "core"),
+ red_dot ("worldmap/dot_red", "core"),
+ dot_border ("Game/dot_border", "game"),
+ green_flag ("worldmap/flaggreen", "core"),
+ last_node (0)
{
green_flag.set_align (-24, -36);
green_dot.set_align_center ();
@@ -52,8 +50,6 @@
graph_data.parse_file (filename);
background = PingusResource::load_surface (graph_data.get_background ());
-
- //background = Blitter::scale_surface (background, CL_Display::get_width (),
CL_Display::get_height ());
pingus = new PingusWorldMapPingus;
@@ -132,7 +128,7 @@
}
void
-WorldMap::init ()
+WorldMap::on_startup ()
{
std::cout << "PingusWorldMap::init" << std::endl;
if (!graph_data.get_music ().empty ())
@@ -140,22 +136,8 @@
}
void
-WorldMap::disable_button_events ()
-{
- catch_input = false;
-}
-
-void
-WorldMap::enable_button_events ()
-{
- catch_input = true;
-}
-
-void
WorldMap::on_primary_button_press (int x, int y)
{
- if (!catch_input) return;
-
CL_Vector offset = get_offset ();
{
@@ -177,7 +159,6 @@
if (pingus_node && pingus_node->get_id () == node->get_id ())
{
- disable_button_events ();
node->on_click ();
// FIXME: Ugly marking code... should be rewritten
@@ -196,9 +177,7 @@
// Save the changes
save ();
-
- enable_button_events ();
- }
+ }
else
{
pingus->walk_to (node.get ());
@@ -212,7 +191,7 @@
}
- /*
+ /**
case CL_MOUSE_MIDDLEBUTTON:
{
if (maintainer_mode)
@@ -227,12 +206,6 @@
}
void
-WorldMap::start_level (Pingus::WorldMap::Node* /*node*/)
-{
-
-}
-
-void
WorldMap::draw (GraphicContext& gc)
{
CL_Vector offset = get_offset ();
@@ -246,8 +219,9 @@
{
dot_border.put_screen (last_node->get_pos () + offset);
- font->print_center (CL_Display::get_width ()/2, CL_Display::get_height
() - 40,
- last_node->get_string().c_str ());
+ gc.print_center (Fonts::pingus_small,
+ CL_Display::get_width ()/2, CL_Display::get_height () -
40,
+ last_node->get_string().c_str ());
/*
if (last_node->finished)
@@ -271,6 +245,7 @@
NodePtr node
= get_node (CL_Mouse::get_x () - (int) offset.x,
CL_Mouse::get_y () - (int) offset.y);
+
// The mouse is over a node
if (node.get ())
{
@@ -321,7 +296,7 @@
{
for (GraphIter i = graph_data.nodes.begin ();
i != graph_data.nodes.end ();
- i++)
+ ++i)
{
if ((*i)->get_id () == node_id)
{
@@ -329,12 +304,6 @@
return;
}
}
-}
-
-bool
-WorldMap::do_exit ()
-{
- return do_quit;
}
/* EOF */
Index: worldmap.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/worldmap.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- worldmap.hxx 5 Sep 2002 12:24:02 -0000 1.7
+++ worldmap.hxx 7 Sep 2002 19:29:04 -0000 1.8
@@ -33,12 +33,15 @@
namespace WorldMap
{
- /** A class for loading, displaying and managing the worldmap. */
+ /** A class for loading, displaying and managing the worldmap. The
+ worldmap is basically a multi-layered image and a path
+ (bidirectional graph) where a pingu can walk on. Parts of the
+ worldmap are hidable and will only get displayed at specific
+ events (successfull level completions). */
class WorldMap
{
private:
CL_Surface background;
- CL_Font* font;
Sprite green_dot;
Sprite red_dot;
@@ -49,30 +52,30 @@
Graph graph_data;
typedef Graph::iterator GraphIter;
+ /** FIXME: Should this be part of the worldmap manager? */
PingusWorldMapPingus* pingus;
-
- bool catch_input;
- bool do_quit;
+ /** FIXME: What is this? */
boost::shared_ptr<Pingus::WorldMap::Node> last_node;
typedef boost::shared_ptr<Pingus::WorldMap::Node> NodePtr;
unsigned int last_node_time;
+ /** This should be the state saving object, which tells which
+ nodes are accessible and which are not. FIXME: might needs a
+ reimplementation. */
boost::shared_ptr<PingusWorldMapStat> stat;
public:
- /** Load a worldmap from a given worldmap description file */
+ /** Load a worldmap from a given worldmap description file
+ @param filename The fully qualified filename (as fopen()
+ @param and friends filename likes it) */
WorldMap (std::string filename);
/** Destruct the worldmap */
~WorldMap ();
- /** Launch the level at the given node
- @param node The current node from which the level should be started */
- void start_level (Pingus::WorldMap::Node* node);
-
/** Start up the music and other things that need only to me run
once on startup of a new WorldMap */
- void init ();
+ void on_startup ();
/** Save the current status to a file */
void save ();
@@ -92,10 +95,6 @@
/** Draw the world worldmap */
void draw (GraphicContext& gc);
- /** Returns true if the worldmap is finished and the
- PingusWorldMapManager can quit */
- bool do_exit ();
-
/** Let the woldmap do some stuff, like animating smoke, playing
sounds or reacting on special events */
void update (float delta);
@@ -106,6 +105,11 @@
/** Callculate the offset which is used for drawing and collision
detection. The offset will be used for scrolling when the
background is larger than the screen.
+
+ FIXME: Do we need this one public? Other classes could
+ FIXME: handle the draw offset via the GraphicContext,
+ FIXME: collision handling should be done in world-co's
+
@return the currently used draw offset */
CL_Vector get_offset ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.cxx,1.3,1.4 graph.hxx,1.5,1.6 manager.cxx,1.8,1.9 manager.hxx,1.8,1.9 node.hxx,1.4,1.5 pingus.hxx,1.7,1.8 worldmap.cxx,1.8,1.9 worldmap.hxx,1.7,1.8,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src surface_button.cxx,1.12,1.13
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src story.cxx,1.7,1.8 story.hxx,1.7,1.8
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src surface_button.cxx,1.12,1.13
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src story.cxx,1.7,1.8 story.hxx,1.7,1.8
- Index(es):