[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src action_holder.cxx,1.7,1.8 button_pane
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src action_holder.cxx,1.7,1.8 button_panel.cxx,1.20,1.21 pingu.hxx,1.23,1.24 pingu_action.cxx,1.12,1.13 pingu_action.hxx,1.23,1.24 pingus_main.cxx,1.33,1.34 |
Date: |
3 Nov 2002 13:29:11 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv7727
Modified Files:
action_holder.cxx button_panel.cxx pingu.hxx pingu_action.cxx
pingu_action.hxx pingus_main.cxx
Log Message:
- some minor bugfixes
- move_with_forces() needs quite a lot of cleanup
- faller is broken, it doesn't die
Index: action_holder.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_holder.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- action_holder.cxx 12 Oct 2002 00:24:26 -0000 1.7
+++ action_holder.cxx 3 Nov 2002 13:29:09 -0000 1.8
@@ -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 <iostream>
#include "globals.hxx"
#include "plf.hxx"
@@ -26,6 +27,12 @@
ActionHolder::ActionHolder (PLF* plf)
{
std::vector<ActionData> action_data = plf->get_actions();
+
+ if (action_data.size() == 0)
+ {
+ std::cout << "Error: ActionHolder: No actions given in this level! Using
defaults" << std::endl;
+ action_data = default_actions;
+ }
for (std::vector<ActionData>::iterator i = action_data.begin(); i !=
action_data.end(); ++i) {
set_actions(i->name, i->number_of);
Index: button_panel.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- button_panel.cxx 2 Nov 2002 18:01:10 -0000 1.20
+++ button_panel.cxx 3 Nov 2002 13:29:09 -0000 1.21
@@ -45,20 +45,18 @@
std::vector<ActionData> buttons_data = plf->get_actions();
+ if (buttons_data.size() == 0)
+ {
+ std::cout << "Error: ButtonPanel: No actions given in this level! Using
defaults" << std::endl;
+ buttons_data = default_actions;
+ }
+
// Sort the action so that they always have the same order in the
// panel
std::sort(buttons_data.begin(), buttons_data.end(), action_sorter());
y_pos -= (buttons_data.size() * 38)/2 + 70;
- if (buttons_data.size() == 0)
- {
- std::cout << "ButtonPanel: No actions given in this level, fall back to
default" << std::endl;
- buttons_data.push_back(ActionData(Bridger, 20));
- buttons_data.push_back(ActionData(Basher, 20));
- buttons_data.push_back(ActionData(Digger, 20));
- buttons_data.push_back(ActionData(Miner, 20));
- }
for(std::vector<ActionData>::size_type i = 0; i < buttons_data.size(); ++i)
{
Index: pingu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.hxx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- pingu.hxx 12 Oct 2002 13:30:51 -0000 1.23
+++ pingu.hxx 3 Nov 2002 13:29:09 -0000 1.24
@@ -119,8 +119,6 @@
(number of blocks, etc.) */
std::string get_name();
- Actions::ActionName get_action ();
-
/// Returns the unique id of the pingu
unsigned int get_id (void);
@@ -200,7 +198,17 @@
another action can be applied, false otherwise (exiter,
splashed, etc.) */
bool catchable ();
-
+
+ /** @return the name of the action the Pingu currently has */
+ Actions::ActionName get_action ();
+
+ /** @return the action that was active before the action returned by
+ get_action() took place. This is used in a few situations where
+ an action needs to now what the Pingu was doing before the
+ action took place (faller->bomber translation is different
+ walker->bomber, etc.). */
+ Actions::ActionName get_previous_action() const { return previous_action; }
+
private:
Pingu (const Pingu&);
Pingu& operator= (const Pingu&);
Index: pingu_action.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- pingu_action.cxx 2 Nov 2002 17:13:56 -0000 1.12
+++ pingu_action.cxx 3 Nov 2002 13:29:09 -0000 1.13
@@ -51,6 +51,7 @@
int
PinguAction::rel_getpixel (int x, int y)
{
+ // FIXME: Inline me
return
WorldObj::get_world()->get_colmap()->getpixel(static_cast<int>(pingu->get_x() +
(x * pingu->direction)),
static_cast<int>(pingu->get_y() - y));
}
@@ -100,14 +101,10 @@
}
void
-PinguAction::move_with_forces (float x_to_add, float y_to_add)
+PinguAction::move_with_forces ()
{
Vector force_to_apply = pingu->get_velocity();
- // Add any additional forces that are required
- force_to_apply.x += x_to_add;
- force_to_apply.y += y_to_add;
-
// Put the force together with any existing forces, including gravity
pingu->set_velocity( ForcesHolder::apply_forces(pingu->get_pos(),
force_to_apply) );
@@ -144,8 +141,10 @@
Vector force_counter = resultant_force;
// Keep moving the Pingu until there is only a fraction left
- while (force_counter.x <= -1 || force_counter.x >= 1
- || force_counter.y <= -1 || force_counter.y >= 1)
+ while ( force_counter.x <= -1
+ || force_counter.x >= 1
+ || force_counter.y <= -1
+ || force_counter.y >= 1)
{
x_numerator += x_inc;
@@ -155,6 +154,8 @@
// Revert back to being a fraction
x_numerator -= denominator;
+ // FIXME: Symmetric code is EXTREMLY UGLY!!!!
+
// Move the Pingu depending on what the direction of the force is
if (force_counter.x >= 1)
{
@@ -183,7 +184,7 @@
{
// Make the Pingu reflect off the wall
force_counter.x = -(force_counter.x);
- resultant_force.x = -(resultant_force.x);
+ resultant_force.x = -(resultant_force.x/3);
pingu->set_velocity(resultant_force);
@@ -244,7 +245,7 @@
}
}
}
- }
+ }
}
Index: pingu_action.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action.hxx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- pingu_action.hxx 28 Oct 2002 15:41:42 -0000 1.23
+++ pingu_action.hxx 3 Nov 2002 13:29:09 -0000 1.24
@@ -113,7 +113,7 @@
virtual void on_failed_apply (Pingu*) { }
/** Move Pingu according to the forces applied to it */
- void move_with_forces (float x_to_add, float y_to_add);
+ void move_with_forces ();
private:
PinguAction (const PinguAction&);
Index: pingus_main.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_main.cxx,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- pingus_main.cxx 2 Nov 2002 22:10:52 -0000 1.33
+++ pingus_main.cxx 3 Nov 2002 13:29:09 -0000 1.34
@@ -862,6 +862,14 @@
void
PingusMain::init_pingus()
{
+ // Init error/warning/notice streams
+ pout.add (std::cout);
+ pout.add (console);
+ pwarn.add (std::cout);
+ pout.add (console);
+ perr.add (std::cout);
+ perr.add (console);
+
PingusSound::init();
PingusResource::init();
@@ -869,13 +877,9 @@
fps_counter.init();
console.init();
XMLhelper::init();
-
- pout.add (std::cout);
- pout.add (console);
- pwarn.add (std::cout);
- pout.add (console);
- perr.add (std::cout);
- perr.add (console);
+
+ // FIXME: See action_data.hxx, a bit ugly
+ init_default_actions();
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src action_holder.cxx,1.7,1.8 button_panel.cxx,1.20,1.21 pingu.hxx,1.23,1.24 pingu_action.cxx,1.12,1.13 pingu_action.hxx,1.23,1.24 pingus_main.cxx,1.33,1.34,
grumbel <=