[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.113,1.114 capture_recta
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.113,1.114 capture_rectangle.cxx,1.10,1.11 demo_session.cxx,1.2,1.3 level_result.cxx,1.4,1.5 pingu_enums.hxx,1.7,1.8 pingu_holder.cxx,1.13,1.14 pingu_holder.hxx,1.11,1.12 pingus_counter.cxx,1.8,1.9 pingus_counter_bar.cxx,1.2,1.3 playfield.cxx,1.25,1.26 server_event.cxx,1.2,1.3 smallmap.cxx,1.17,1.18 world.cxx,1.28,1.29 world.hxx,1.15,1.16 |
Date: |
4 Oct 2002 13:46:58 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv22173
Modified Files:
Makefile.am capture_rectangle.cxx demo_session.cxx
level_result.cxx pingu_enums.hxx pingu_holder.cxx
pingu_holder.hxx pingus_counter.cxx pingus_counter_bar.cxx
playfield.cxx server_event.cxx smallmap.cxx world.cxx
world.hxx
Log Message:
clean up the PinguHolder/World relation ship a bit
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.am,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- Makefile.am 3 Oct 2002 01:02:12 -0000 1.113
+++ Makefile.am 4 Oct 2002 13:46:56 -0000 1.114
@@ -72,6 +72,8 @@
input/scrollers/libpingus_input_scrollers.a
pingus_SOURCES = \
+anim_counter.hxx \
+anim_counter.cxx \
action_button.cxx \
action_button.hxx \
action_data.hxx \
@@ -82,8 +84,6 @@
algo.hxx \
alpha_button.cxx \
alpha_button.hxx \
-anim_counter.cxx \
-anim_counter.hxx \
audio.cxx \
audio.hxx \
blitter.cxx \
Index: capture_rectangle.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/capture_rectangle.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- capture_rectangle.cxx 4 Oct 2002 11:38:28 -0000 1.10
+++ capture_rectangle.cxx 4 Oct 2002 13:46:56 -0000 1.11
@@ -95,25 +95,29 @@
CaptureRectangle::set_pingu (Pingu* p)
{
pingu = p;
- action_str = pingu->get_action()->get_name();
-
- if (pingu->get_wall_action() || pingu->get_fall_action())
+
+ if (pingu)
{
- action_str += "[";
+ action_str = pingu->get_action()->get_name();
+
+ if (pingu->get_wall_action() || pingu->get_fall_action())
+ {
+ action_str += "[";
- if (pingu->get_wall_action())
- action_str += pingu->get_wall_action()->get_persistent_char();
+ if (pingu->get_wall_action())
+ action_str += pingu->get_wall_action()->get_persistent_char();
- if (pingu->get_fall_action())
- action_str += pingu->get_fall_action()->get_persistent_char();
+ if (pingu->get_fall_action())
+ action_str += pingu->get_fall_action()->get_persistent_char();
- action_str += "]";
- }
+ action_str += "]";
+ }
- if (maintainer_mode)
- {
- action_str += " Id: ";
- action_str += to_string(pingu->get_id());
+ if (maintainer_mode)
+ {
+ action_str += " Id: ";
+ action_str += to_string(pingu->get_id());
+ }
}
}
Index: demo_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/demo_session.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- demo_session.cxx 3 Oct 2002 12:33:08 -0000 1.2
+++ demo_session.cxx 4 Oct 2002 13:46:56 -0000 1.3
@@ -17,6 +17,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <ClanLib/Core/System/system.h>
#include <ClanLib/Display/Input/input.h>
#include <ClanLib/Display/Input/keyboard.h>
#include "xml_pdf.hxx"
@@ -66,6 +67,11 @@
gc.move(Vector(0.0, -10.0));
server->get_world()->draw(gc);
+ while (CL_Keyboard::get_keycode(CL_KEY_D))
+ {
+ server->get_world()->draw(gc);
+ CL_System::keep_alive();
+ }
}
/** Pass a delta to the screen */
Index: level_result.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/level_result.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- level_result.cxx 4 Sep 2002 14:55:11 -0000 1.4
+++ level_result.cxx 4 Oct 2002 13:46:56 -0000 1.5
@@ -27,6 +27,7 @@
#include "display.hxx"
#include "sound.hxx"
#include "world.hxx"
+#include "pingu_holder.hxx"
/* Headers needed for i18n / gettext */
#include <clocale>
@@ -66,12 +67,12 @@
get_message(100 * world->get_saved_pingus() /
world->get_allowed_pingus()).c_str());
*/
snprintf(str, 128, _("Pingus saved: %3d/%3d"),
- world->get_saved_pingus(),
- world->get_allowed_pingus());
+ world->get_pingus()->get_number_of_exited(),
+ world->get_allowed_pingus());
font->print_center(CL_Display::get_width() / 2, 140, str);
snprintf(str, 128, _("Pingus killed: %3d/%3d"),
- world->get_allowed_pingus() - world->get_saved_pingus(),
+ world->get_allowed_pingus() -
world->get_pingus()->get_number_of_exited(),
world->get_allowed_pingus());
font->print_center(CL_Display::get_width() / 2, 160, str);
Index: pingu_enums.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_enums.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pingu_enums.hxx 25 Aug 2002 09:08:48 -0000 1.7
+++ pingu_enums.hxx 4 Oct 2002 13:46:56 -0000 1.8
@@ -23,8 +23,13 @@
#include "pingus.hxx"
#include <string>
-/** Haven't yet experimented much with pingu status, but maybe it is a
- good idea. Maybe that should be changed to a bitmask. */
+/** The Pingus Status shows the current status of a Pingu, as
+ displayed in the PingusCounter pannel. PS_DEAD are pingus that got
+ killed, PS_ALIVE are pingus that are still active in the world and
+ PS_EXITED are pingus that successfully finished a level
+
+ FIXME: different subvalues of PS_DEAD might be usefull (drowned,
+ FIXME: splashed, smashed, etc.) */
enum PinguStatus { PS_ALIVE, PS_EXITED, PS_DEAD };
enum PingusGameMode {
Index: pingu_holder.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_holder.cxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- pingu_holder.cxx 3 Oct 2002 01:02:12 -0000 1.13
+++ pingu_holder.cxx 4 Oct 2002 13:46:56 -0000 1.14
@@ -23,10 +23,9 @@
#include "pingu_action.hxx"
PinguHolder::PinguHolder()
+ : id_count(0),
+ number_of_exited(0)
{
- id_count = 0;
- total_size_count = 0;
- saved_pingus = 0;
}
PinguHolder::~PinguHolder()
@@ -38,28 +37,11 @@
delete *i;
}
-int
-PinguHolder::total_size()
-{
- return total_size_count;
-}
-
-/*
-void
-PinguHolder::add (Pingu* pingu)
-{
- total_size_count++;
- pingu->set_id(id_count++);
- pingus.push_back(pingu);
- }*/
-
Pingu*
PinguHolder::create_pingu (const Vector& pos, int owner_id)
{
Pingu* pingu = new Pingu (id_count++, pos, owner_id);
- ++total_size_count;
-
// This list will deleted
all_pingus.push_back (pingu);
@@ -82,7 +64,12 @@
}
// Draw all non-walkers, so that they are easier spotable
- // FIXME: This might be usefull, but looks kind of ugly
+
+ // FIXME: This might be usefull, but looks kind of ugly in the game
+ // FIXME: Bridgers where walkers walk behind are an example of
+ // FIMME: uglyness. Either we rip this code out again or fix the
+ // FIXME: bridger so that it looks higher and better with walkers
+ // FIXME: behind him.
for(std::list<Pingu*>::iterator pingu = pingus.begin();
pingu != pingus.end();
++pingu)
@@ -112,13 +99,13 @@
}
else if ((*pingu)->get_status() == PS_EXITED)
{
- saved_pingus++;
+ number_of_exited += 1;
pingu = pingus.erase(pingu);
}
else
{
// move to the next Pingu
- pingu++;
+ ++pingu;
}
}
}
@@ -140,6 +127,30 @@
PinguHolder::get_z_pos() const
{
return 50;
+}
+
+int
+PinguHolder::get_number_of_exited()
+{
+ return number_of_exited;
+}
+
+int
+PinguHolder::get_number_of_killed()
+{
+ return all_pingus.size() - pingus.size() - get_number_of_exited();
+}
+
+int
+PinguHolder::get_number_of_alive()
+{
+ return pingus.size();
+}
+
+int
+PinguHolder::get_number_of_released()
+{
+ return all_pingus.size();
}
/* EOF */
Index: pingu_holder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_holder.hxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- pingu_holder.hxx 3 Oct 2002 01:02:12 -0000 1.11
+++ pingu_holder.hxx 4 Oct 2002 13:46:56 -0000 1.12
@@ -33,12 +33,14 @@
class PinguHolder : public WorldObj
{
private:
- /// The uniq id for the next Pingu
+ /** The uniq id for the next Pingu, starts at 0 and is increased
+ with every Pingu. Id's are not recycled if Pingus die. */
int id_count;
- int total_size_count;
-
- int saved_pingus;
+ /** Number of pingus that made it to the exit, we cache this, since
+ else we would have to iterate over the whole list and count them
+ each time they are requested. */
+ int number_of_exited;
/** This vector holds all pingus which are ever allocated in the
world, its used to free them all on the end of this class. */
@@ -52,11 +54,34 @@
PinguHolder();
~PinguHolder();
+ /address@hidden
+ @name overloaded stuff for WorldObj
+ */
void draw (GraphicContext& gc);
+
+ /** Update all Pingus (this calls Pingu::update() which then calls
+ PinguAction::update()) */
void update();
- int total_size();
- int get_saved() { return saved_pingus; }
+ /** The z-pos at which the pingus gets draw.
+ @return 50 */
+ float get_z_pos() const;
+ /address@hidden/
+
+ /** @return the number of pingus that have successfully exit this
+ level */
+ int get_number_of_exited();
+
+ /** @return the number of pingus that got killed */
+ int get_number_of_killed();
+
+ /** @return the number of pingus that are still alive, this is shown
+ in the PingusCounter panel as 'Out' */
+ int get_number_of_alive();
+
+ /** @return the total number of pingus released, this is alive +
+ killed + exited */
+ int get_number_of_released();
/** Return a reference to a newly create Pingu, the PinguHolder will
take care of the deletion. The caller *must* not delete the
@@ -64,11 +89,10 @@
Pingu* create_pingu(const Vector& pos, int owner_id);
/** Get a pingu by id
- @return the pingu with the id, or 0 if not found */
+ @return the pingu with the id, or 0 if none found */
Pingu* get_pingu(int id);
- float get_z_pos() const;
-
+ // FIXME: Dirty cruft, needs cleanup
std::list<Pingu*>::iterator begin () { return pingus.begin (); }
std::list<Pingu*>::iterator end () { return pingus.end (); }
std::list<Pingu*>::size_type size () { return pingus.size (); }
Index: pingus_counter.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_counter.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pingus_counter.cxx 3 Oct 2002 12:33:08 -0000 1.8
+++ pingus_counter.cxx 4 Oct 2002 13:46:56 -0000 1.9
@@ -20,14 +20,11 @@
#include <stdio.h>
#include <ClanLib/Display/Display/display.h>
#include <ClanLib/Display/Font/font.h>
+#include "my_gettext.hxx"
#include "pingus_resource.hxx"
#include "pingus_counter.hxx"
#include "world.hxx"
-
-/* Headers needed for i18n / gettext */
-#include <clocale>
-#include <config.h>
-#include "my_gettext.hxx"
+#include "pingu_holder.hxx"
#include "server.hxx"
@@ -48,10 +45,10 @@
World* world = server->get_world();
snprintf(str, 128, _("Released: %3d/%3d Out: %3d Saved: %3d/%3d"),
- world->get_released_pingus(),
+ world->get_pingus()->get_number_of_released(),
world->get_allowed_pingus(),
- world->get_pingus_out(),
- world->get_saved_pingus(),
+ world->get_pingus()->get_number_of_alive(),
+ world->get_pingus()->get_number_of_exited(),
world->get_number_to_save());
font->print_center(CL_Display::get_width ()/2,3, str);
Index: pingus_counter_bar.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_counter_bar.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pingus_counter_bar.cxx 14 Sep 2002 23:46:58 -0000 1.2
+++ pingus_counter_bar.cxx 4 Oct 2002 13:46:56 -0000 1.3
@@ -20,6 +20,7 @@
#include <iostream>
#include <ClanLib/Display/Display/display.h>
#include "pingus_counter_bar.hxx"
+#include "pingu_holder.hxx"
#include "server.hxx"
#include "world.hxx"
@@ -45,8 +46,8 @@
int length = rect.y2 - rect.y1;
int complete = server->get_world ()->get_allowed_pingus ();
- int current_out = server->get_world ()->get_released_pingus ();
- int current_saved = server->get_world ()->get_saved_pingus ();
+ int current_out = server->get_world
()->get_pingus()->get_number_of_released();
+ int current_saved = server->get_world
()->get_pingus()->get_number_of_exited();
//std::cout << "Drawing Counterbar: " << rect << std::endl;
CL_Display::fill_rect (rect.x1, rect.y1, rect.x2, rect.y2,
Index: playfield.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.cxx,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- playfield.cxx 3 Oct 2002 12:33:08 -0000 1.25
+++ playfield.cxx 4 Oct 2002 13:46:56 -0000 1.26
@@ -148,8 +148,8 @@
double dist;
Pingu* c_pingu = 0;
- for (PinguIter pingu = world->get_pingu_p()->begin();
- pingu != world->get_pingu_p()->end();
+ for (PinguIter pingu = world->get_pingus()->begin();
+ pingu != world->get_pingus()->end();
++pingu)
{
if ((*pingu)->is_over(x_pos, y_pos))
Index: server_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server_event.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- server_event.cxx 3 Oct 2002 12:33:08 -0000 1.2
+++ server_event.cxx 4 Oct 2002 13:46:56 -0000 1.3
@@ -110,7 +110,7 @@
break;
case PINGU_ACTION_EVENT:
{
- Pingu* pingu = server->get_world()->get_pingu_p()->get_pingu(pingu_id);
+ Pingu* pingu = server->get_world()->get_pingus()->get_pingu(pingu_id);
if (pingu)
{
server->send_pingu_action_event(pingu,
Index: smallmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- smallmap.cxx 16 Sep 2002 20:31:09 -0000 1.17
+++ smallmap.cxx 4 Oct 2002 13:46:56 -0000 1.18
@@ -198,7 +198,7 @@
int x;
int y;
World* const& world = client->get_server()->get_world();
- PinguHolder* pingus = world->get_pingu_p();
+ PinguHolder* pingus = world->get_pingus();
for(PinguIter i = pingus->begin(); i != pingus->end(); ++i)
{
Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- world.cxx 1 Oct 2002 19:53:44 -0000 1.28
+++ world.cxx 4 Oct 2002 13:46:56 -0000 1.29
@@ -64,7 +64,6 @@
do_armageddon = false;
allowed_pingus = plf->get_pingus();
number_to_save = plf->get_number_to_save();
- released_pingus = 0;
exit_time = plf->get_time();
if (exit_time != -1 && !(exit_time > 100))
@@ -161,7 +160,8 @@
// if a exit condition is schedule a shutdown of the world in the
// next 75 ticks
- if (!exit_world && (allowed_pingus == released_pingus || do_armageddon)
+ if (!exit_world && (static_cast<int>(allowed_pingus) ==
pingus->get_number_of_released()
+ || do_armageddon)
&& pingus->size() == 0)
{
if (verbose)
@@ -197,20 +197,20 @@
}
PinguHolder*
-World::get_pingu_p(void)
+World::get_pingus()
{
return pingus;
}
int
-World::get_width(void)
+World::get_width()
{
assert(gfx_map);
return gfx_map->get_width();
}
int
-World::get_height(void)
+World::get_height()
{
assert(gfx_map);
return gfx_map->get_height();
@@ -233,18 +233,6 @@
World::get_time_passed()
{
return game_time->get_ticks();
-}
-
-unsigned int
-World::get_pingus_out()
-{
- return pingus->size();
-}
-
-unsigned int
-World::get_saved_pingus()
-{
- return pingus->get_saved();
}
void
Index: world.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.hxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- world.hxx 1 Oct 2002 19:53:44 -0000 1.15
+++ world.hxx 4 Oct 2002 13:46:56 -0000 1.16
@@ -67,9 +67,6 @@
of them, should use pingus_id instead */
std::list<Pingu*>::iterator armageddon_count;
- /** number of already released pingus */
- unsigned int released_pingus;
-
/** number of total pingus available in this level */
unsigned int allowed_pingus;
@@ -143,20 +140,12 @@
/** @return A pointer to the worlds particle holder */
ParticleHolder* get_particle_holder();
- unsigned int get_released_pingus() { return released_pingus; }
- void inc_released_pingus() { ++released_pingus; }
-
/** @return true if the world is currently doing an armageddon */
bool check_armageddon() { return do_armageddon; }
/** @return the number of totally allowed pingus */
unsigned int get_allowed_pingus() { return allowed_pingus; }
- /** @return the number of pingus currently moving around in the
- world, exited, killed and not yet released pingus are not
- counted */
- unsigned int get_pingus_out(); unsigned int get_saved_pingus();
-
/** @return number of pingus which need to get saved in this level
to finish it successfull */
unsigned int get_number_to_save() { return number_to_save; }
@@ -179,7 +168,7 @@
FIXME: like that */
void set_view (View* v);
- PinguHolder* get_pingu_p(void);
+ PinguHolder* get_pingus(void);
/** @return the pingu at the given word coordinates, an empty
shared_ptr is returned if none is there */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.113,1.114 capture_rectangle.cxx,1.10,1.11 demo_session.cxx,1.2,1.3 level_result.cxx,1.4,1.5 pingu_enums.hxx,1.7,1.8 pingu_holder.cxx,1.13,1.14 pingu_holder.hxx,1.11,1.12 pingus_counter.cxx,1.8,1.9 pingus_counter_bar.cxx,1.2,1.3 playfield.cxx,1.25,1.26 server_event.cxx,1.2,1.3 smallmap.cxx,1.17,1.18 world.cxx,1.28,1.29 world.hxx,1.15,1.16,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs bumper.cxx,1.9,1.10 conveyor_belt.cxx,1.19,1.20 entrance.cxx,1.4,1.5 exit.cxx,1.3,1.4 fake_exit.cxx,1.8,1.9 guillotine.cxx,1.6,1.7 hammer.cxx,1.8,1.9 ice_block.cxx,1.19,1.20 info_box.cxx,1.17,1.18 laser_exit.cxx,1.7,1.8 smasher.cxx,1.11,1.12 spike.cxx,1.6,1.7 switch_door.cxx,1.21,1.22 teleporter.cxx,1.13,1.14
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs entrance.cxx,1.5,1.6
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs bumper.cxx,1.9,1.10 conveyor_belt.cxx,1.19,1.20 entrance.cxx,1.4,1.5 exit.cxx,1.3,1.4 fake_exit.cxx,1.8,1.9 guillotine.cxx,1.6,1.7 hammer.cxx,1.8,1.9 ice_block.cxx,1.19,1.20 info_box.cxx,1.17,1.18 laser_exit.cxx,1.7,1.8 smasher.cxx,1.11,1.12 spike.cxx,1.6,1.7 switch_door.cxx,1.21,1.22 teleporter.cxx,1.13,1.14
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs entrance.cxx,1.5,1.6
- Index(es):