[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src capture_rectangle.cxx,1.2,1.3 capture
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src capture_rectangle.cxx,1.2,1.3 capture_rectangle.hxx,1.1,1.2 client.cxx,1.3,1.4 client.hxx,1.1,1.2 pingu.cxx,1.9,1.10 pingu.hxx,1.2,1.3 pingu_action.hxx,1.2,1.3 playfield.cxx,1.5,1.6 playfield.hxx,1.3,1.4 view.cxx,1.3,1.4 view.hxx,1.1,1.2 |
Date: |
24 Jun 2002 14:25:05 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv31922
Modified Files:
capture_rectangle.cxx capture_rectangle.hxx client.cxx
client.hxx pingu.cxx pingu.hxx pingu_action.hxx playfield.cxx
playfield.hxx view.cxx view.hxx
Log Message:
- moved some stuff in Pingu into private
- added PinguAction::change_allowed() along with the good/bad check in
capture_rectangle
Index: capture_rectangle.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/capture_rectangle.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- capture_rectangle.cxx 13 Jun 2002 14:25:12 -0000 1.2
+++ capture_rectangle.cxx 24 Jun 2002 14:25:03 -0000 1.3
@@ -23,24 +23,25 @@
#include "pingus_resource.hxx"
#include "capture_rectangle.hxx"
#include "pingu_action.hxx"
+#include "button_panel.hxx"
using namespace boost;
-CaptureRectangle::CaptureRectangle()
+CaptureRectangle::CaptureRectangle(ButtonPanel* arg_button_panel)
: pingu (0),
- button_action (0),
owner_id (0),
good (PingusResource::load_surface("Cursors/capgood", "game")),
bad (PingusResource::load_surface("Cursors/capbad", "game")),
arrow_left (PingusResource::load_surface("Cursors/arrow_left", "game")),
arrow_right (PingusResource::load_surface("Cursors/arrow_right", "game")),
+ button_panel(arg_button_panel),
font (PingusResource::load_font("Fonts/courier_small", "fonts"))
{
good.set_align_center ();
bad.set_align_center ();
arrow_left.set_align_center ();
arrow_right.set_align_center ();
-}
+}
CaptureRectangle::~CaptureRectangle()
{
@@ -53,16 +54,18 @@
{
Sprite * sur;
- if (button_action && (button_action->get_environment() &
pingu->get_environment()))
- sur = &bad;
- else
+ // FIXME: A check for surface good/bad should be placed here
+ if (pingu->change_allowed (button_panel->get_action_name ()))
sur = &good;
+ else
+ sur = &bad;
if (s == 1.0)
{
std::string action_str = pingu->get_action()->get_name();
std::vector<PinguAction*>* persitant = pingu->get_persistent_actions
();
+ // FIXME: This needs to get changed if we want to use action slots
if (persitant->size() > 0)
{
action_str += " [";
@@ -104,14 +107,6 @@
sur->put_screen(pingu->get_center_pos() + CL_Vector (x_offset,
y_offset));
}
}
-}
-
-// Sets the current buttons action, it is used to change the color of
-// the cap rect, if the action can't be applied.
-void
-CaptureRectangle::set_action(PinguAction* action)
-{
- button_action = action;
}
void
Index: capture_rectangle.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/capture_rectangle.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- capture_rectangle.hxx 12 Jun 2002 19:09:37 -0000 1.1
+++ capture_rectangle.hxx 24 Jun 2002 14:25:03 -0000 1.2
@@ -28,10 +28,11 @@
class CL_Font;
namespace boost {
-
template <class T> class shared_ptr;
}
+class ButtonPanel;
+
/** The rectangle that is shown when the mouse cursor is above a
pingu. The rectangle shows the current pingu direction along with
the current active action.
@@ -40,7 +41,6 @@
{
private:
Pingu* pingu;
- PinguAction* button_action;
/// The id of the owner of this capture rectangle
int owner_id;
@@ -50,13 +50,13 @@
Sprite arrow_left;
Sprite arrow_right;
+ ButtonPanel* button_panel;
CL_Font* font;
public:
- CaptureRectangle();
+ CaptureRectangle(ButtonPanel*);
~CaptureRectangle();
void set_pingu(Pingu* pingu);
- void set_action(PinguAction*);
void draw_offset(int x_offset, int y_offset, float s = 1.0);
};
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- client.cxx 19 Jun 2002 15:19:26 -0000 1.3
+++ client.cxx 24 Jun 2002 14:25:03 -0000 1.4
@@ -109,9 +109,8 @@
PingusResource::get("game")));
Display::show_cursor();
- playfield = new Playfield(plf, server->get_world(), controller);
-
button_panel = new ButtonPanel(plf, controller, 2,
CL_Display::get_height()/2);
+ pcounter = new PingusCounter(); playfield = new Playfield(this, plf,
server->get_world(), controller);
pcounter = new PingusCounter();
small_map = new SmallMap();
time_display = new TimeDisplay();
Index: client.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- client.hxx 12 Jun 2002 19:09:37 -0000 1.1
+++ client.hxx 24 Jun 2002 14:25:03 -0000 1.2
@@ -124,6 +124,8 @@
/** Update all parts of the world */
void update (float delta);
+ ButtonPanel* get_button_panel () { return button_panel; }
+
virtual void on_button_press(CL_InputDevice *device, const CL_Key &key);
virtual void on_button_release(CL_InputDevice *device, const CL_Key &key);
Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- pingu.cxx 24 Jun 2002 09:40:58 -0000 1.9
+++ pingu.cxx 24 Jun 2002 14:25:03 -0000 1.10
@@ -54,7 +54,7 @@
velocity.x = 0;
velocity.y = 0;
- set_action("faller");
+ set_paction("faller");
}
Pingu::~Pingu()
@@ -86,6 +86,13 @@
Pingu::get_environment()
{
return environment;
+}
+
+bool
+Pingu::change_allowed (const std::string& new_action)
+{
+ assert (action);
+ return action->change_allowed (new_action);
}
// Set the position of the pingu
Index: pingu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pingu.hxx 21 Jun 2002 16:51:22 -0000 1.2
+++ pingu.hxx 24 Jun 2002 14:25:03 -0000 1.3
@@ -38,7 +38,7 @@
objects. */
class Pingu : public WorldObj
{
-public:
+private:
/** Static id_counter, which holds the id last pingu, which
got created. */
static int id_counter;
@@ -46,14 +46,15 @@
/** The primary action with is currently in use */
PinguAction* action;
- /** A secondary action with will turn active after a given amount of time
+ /** A secondary action which will turn active after a given amount of time
The only example is currently the bomber. */
PinguAction* countdown_action;
- /** A list of action with are activated on-demand, so when the pingu
- is in the air a floater will get activated, if he needs to climb
- a climber gets active. */
- std::vector<PinguAction*> persist;
+ /** the action that gets triggered when the pingu hits a wall */
+ PinguAction* wall_action;
+
+ /** the action that gets triggered when the pingu falls */
+ PinguAction* fall_action;
/** The uniq id of the Pingu, this is used to refer to the Pingu in
a demo file or in a network connection */
@@ -61,11 +62,23 @@
CL_Font* font;
int action_time;
- PinguStatus status;
- PinguEnvironment environment;
int owner_id;
- // The postion of the pingu (CL_Vector::z is always zero)
+public:
+ /** A list of action with are activated on-demand, so when the pingu
+ is in the air a floater will get activated, if he needs to climb
+ a climber gets active.
+
+ FIXME: This will get obsolete sooner or later
+ */
+ std::vector<PinguAction*> persist;
+
+
+ // The stat of the pingu, these can be modified by PinguActions
+
+ PinguStatus status;
+ PinguEnvironment environment;
+ /// The postion of the pingu (CL_Vector::z is always zero)
CL_Vector pos;
Direction direction;
CL_Vector velocity;
@@ -99,6 +112,9 @@
///
PinguEnvironment get_environment();
+ /** Checks if this action allows to be overwritten with the given new action
*/
+ bool change_allowed (const std::string&);
+
/// Check if the pingu is still alive
bool is_alive(void);
@@ -123,11 +139,15 @@
// Set the pingu in the gives direction
void set_direction(Direction d);
+ /** Set an action if it is appliable to the current pingu, if its a
+ persistent action, it will be hold back for later execution */
bool set_action (PinguAction*);
void set_action (const std::string& action_name);
- /// FIXME: Stupid function name, need a better one.
+ /** Set an action without any checking, the action will take
+ instantly control */
void set_paction (PinguAction*);
+
void set_paction (const std::string& action_name);
///
Index: pingu_action.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pingu_action.hxx 24 Jun 2002 09:40:58 -0000 1.2
+++ pingu_action.hxx 24 Jun 2002 14:25:03 -0000 1.3
@@ -70,6 +70,9 @@
/** Returns the enviroment, used to check if an action can be
applied. */
virtual PinguEnvironment get_environment() const =0;
+
+ /** Checks if this action allows to be overwritten with the given new action
*/
+ virtual bool change_allowed (const std::string&) { return true; }
/** Used to load all data, which is needed by the action, its
seperated and called in set_pingu(), because some data will be
Index: playfield.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- playfield.cxx 20 Jun 2002 11:23:53 -0000 1.5
+++ playfield.cxx 24 Jun 2002 14:25:03 -0000 1.6
@@ -31,7 +31,7 @@
using boost::shared_ptr;
-Playfield::Playfield(PLF* level_data, World* w,
+Playfield::Playfield(Client* client, PLF* level_data, World* w,
Controller* arg_controller)
: current_view(0), controller (arg_controller)
{
@@ -70,13 +70,13 @@
{
if (verbose)
std::cout << "Playfield: Using gimmick" << std::endl;
- view.push_back(new View(0, 21, x2/2, y2/2, 0.5f));
- view.push_back(new View(x2/2, y1, x2, y2, 1.0f));
- view.push_back(new View(0, y2/2, x2/2, y2, 2.0f));
+ view.push_back(new View(client, 0, 21, x2/2, y2/2, 0.5f));
+ view.push_back(new View(client, x2/2, y1, x2, y2, 1.0f));
+ view.push_back(new View(client, 0, y2/2, x2/2, y2, 2.0f));
}
else
{ // !gimmicks_enabled
- view.push_back(new View(x1, y1, x2, y2));
+ view.push_back(new View(client, x1, y1, x2, y2));
view[0]->set_x_offset(((x2 - x1) / 2) - level_data->get_startx());
view[0]->set_y_offset(((y2 - y1) / 2) - level_data->get_starty());
Index: playfield.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- playfield.hxx 18 Jun 2002 21:17:16 -0000 1.3
+++ playfield.hxx 24 Jun 2002 14:25:03 -0000 1.4
@@ -70,7 +70,7 @@
Controller* controller;
public:
- Playfield(PLF* plf, World*,
+ Playfield(Client*, PLF* plf, World*,
Controller*);
~Playfield();
Index: view.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/view.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- view.cxx 21 Jun 2002 07:45:35 -0000 1.3
+++ view.cxx 24 Jun 2002 14:25:03 -0000 1.4
@@ -22,12 +22,14 @@
#include "mouse_controller.hxx"
#include "view.hxx"
#include "world.hxx"
+#include "client.hxx"
// static variables
World* View::world;
-View::View(int x1, int y1, int x2, int y2, float s)
- : current_pingu (0),
+View::View(Client* client, int x1, int y1, int x2, int y2, float s)
+ : cap (client->get_button_panel ()),
+ current_pingu (0),
controller (new MouseController ())
{
assert(world);
Index: view.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/view.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- view.hxx 12 Jun 2002 19:09:38 -0000 1.1
+++ view.hxx 24 Jun 2002 14:25:03 -0000 1.2
@@ -27,21 +27,20 @@
class Pingu;
class World;
class Controller;
+class Client;
/** A class to controll the rentering of the playfield, each display on
the screen, which displays the pingus world is an view object. */
class View
{
private:
- ///
CL_ClipRect clip_rect;
- ///
- Range x_offset, y_offset; /// The position of the view in the world
+ /// The position of the view in the world
+ Range x_offset, y_offset;
bool mouse_over;
- ///
- double size; /// The zoom of the View, 1 is default
+ /// The zoom of the View, 1 is default
+ double size;
CaptureRectangle cap;
- ///
Pingu* current_pingu;
/// Static objects which are equal for all Views
static World* world;
@@ -65,7 +64,7 @@
int y2_pos;
//@}
- View(int, int, int, int, float s = 1.0);
+ View(Client*, int, int, int, int, float s = 1.0);
~View();
void draw();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src capture_rectangle.cxx,1.2,1.3 capture_rectangle.hxx,1.1,1.2 client.cxx,1.3,1.4 client.hxx,1.1,1.2 pingu.cxx,1.9,1.10 pingu.hxx,1.2,1.3 pingu_action.hxx,1.2,1.3 playfield.cxx,1.5,1.6 playfield.hxx,1.3,1.4 view.cxx,1.3,1.4 view.hxx,1.1,1.2,
grumbel <=
- Prev by Date:
[Pingus-CVS] [Bug #740] Jumper has no own animation
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/actions faller.cxx,1.4,1.5 faller.hxx,1.2,1.3 walker.cxx,1.4,1.5
- Previous by thread:
[Pingus-CVS] [Bug #740] Jumper has no own animation
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/actions faller.cxx,1.4,1.5 faller.hxx,1.2,1.3 walker.cxx,1.4,1.5
- Index(es):