[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/actions basher.cxx,1.22,1.23 basher.h
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/actions basher.cxx,1.22,1.23 basher.hxx,1.14,1.15 |
Date: |
14 Oct 2002 11:15:17 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/actions
In directory dark:/tmp/cvs-serv13100/src/actions
Modified Files:
basher.cxx basher.hxx
Log Message:
- applied the outstanding patches from the ML
- optimized force_vector a little
Index: basher.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/basher.cxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- basher.cxx 13 Oct 2002 20:25:00 -0000 1.22
+++ basher.cxx 14 Oct 2002 11:15:15 -0000 1.23
@@ -40,6 +40,13 @@
{
sprite.set_align_center_bottom();
+ bash_radius_width = bash_radius.get_width();
+ bash_radius_gfx_width = bash_radius_gfx.get_width();
+
+ // The +1 is just in case bash_radius is an odd no. In which case, want to
+ // round up the result.
+ bash_reach = static_cast<int>(bash_radius_width + 1) / 2;
+
// Start a bash even so the action will stops instantly after the
// first bash
bash();
@@ -84,11 +91,11 @@
Basher::bash()
{
WorldObj::get_world()->get_colmap()->remove(bash_radius,
- static_cast<int>(pingu->get_x ()
- (bash_radius.get_width()/2)),
- static_cast<int>(pingu->get_y ()
- 31));
+ static_cast<int>(pingu->get_x ()
- (bash_radius_width / 2)),
+ static_cast<int>(pingu->get_y ()
- bash_radius_width - 1));
WorldObj::get_world()->get_gfx_map()->remove(bash_radius_gfx,
- static_cast<int>(pingu->get_x ()
- (bash_radius_gfx.get_width()/2)),
- static_cast<int>(pingu->get_y ()
- 31));
+ static_cast<int>(pingu->get_x ()
- (bash_radius_gfx_width / 2)),
+ static_cast<int>(pingu->get_y ()
- bash_radius_gfx_width - 1));
}
void
@@ -127,12 +134,10 @@
return true;
}
- for(int x = 0; x <= 16; ++x)
+ // Check that there is something "within" the Basher's reach
+ for(int x = 0; x <= bash_reach; ++x)
{
- // Check that there is a high enough wall (i.e. not 1 pixel) to bash.
- // Probably best to check from where Pingu can't automatically walk up
- // up to head collision height.
- for (int y = bash_height + 1; y <= bash_height + pingu_height + 1; ++y)
+ for (int y = min_bash_height; y <= max_bash_height; ++y)
{
if (rel_getpixel(x, y) == Groundtype::GP_GROUND)
{
Index: basher.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/basher.hxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- basher.hxx 13 Oct 2002 16:40:00 -0000 1.14
+++ basher.hxx 14 Oct 2002 11:15:15 -0000 1.15
@@ -33,9 +33,24 @@
CL_Surface bash_radius_gfx;
int basher_c;
bool first_bash;
+
+ /** Width of the bash_radius surface */
+ unsigned int bash_radius_width;
+
+ /** Width of the bash_radius_gfx surface */
+ unsigned int bash_radius_gfx_width;
+
+ /** The no. of pixels ahead that a Basher checks for something bashable.
+ This is initialised using the size of the bash_radius surface. */
+ int bash_reach;
- /// Defines "wall" height needed so as to determine whether it should be
bashed.
- enum { bash_height = 4 };
+ /** Defines the minimum "wall" height needed for a bash to happen. */
+ enum { min_bash_height = 5 };
+
+ /** Defines the maximum height up to which a check is made to see if there
+ is anything to bash. Best to make this at least (min_bash_height +
+ pingu_height). */
+ enum { max_bash_height = 33 };
/** Defines the maximum no. of steps down a Basher can go down before it
stops being a Basher and turns into a Faller. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/actions basher.cxx,1.22,1.23 basher.hxx,1.14,1.15,
torangan <=