projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Made statistics to keep track of also: bad guys squished, shots, time needed and...
[supertux.git]
/
src
/
badguy.cpp
diff --git
a/src/badguy.cpp
b/src/badguy.cpp
index
be614f3
..
ac0e59b
100644
(file)
--- a/
src/badguy.cpp
+++ b/
src/badguy.cpp
@@
-34,6
+34,7
@@
#include "level.h"
#include "sector.h"
#include "tilemap.h"
#include "level.h"
#include "sector.h"
#include "tilemap.h"
+#include "statistics.h"
Sprite* img_mriceblock_flat_left;
Sprite* img_mriceblock_flat_right;
Sprite* img_mriceblock_flat_left;
Sprite* img_mriceblock_flat_right;
@@
-339,16
+340,23
@@
BadGuy::action_mriceblock(double elapsed_time)
{ /* FIXME: The pbad object shouldn't know about pplayer objects. */
/* If we're holding the iceblock */
dir = tux.dir;
{ /* FIXME: The pbad object shouldn't know about pplayer objects. */
/* If we're holding the iceblock */
dir = tux.dir;
- if(
dir==RIGHT
)
+ if(
tux.size == SMALL
)
{
{
- base.x = tux.base.x + 16;
- base.y = tux.base.y + tux.base.height/1.5 - base.height;
+ if(dir == RIGHT)
+ base.x = tux.base.x + 24;
+ else // dir == LEFT
+ base.x = tux.base.x - 12;
+ base.y = tux.base.y + tux.base.height/1.5 - base.height;
}
}
- else /
* facing left */
+ else /
/ TUX == BIG
{
{
- base.x = tux.base.x - 16;
- base.y = tux.base.y + tux.base.height/1.5 - base.height;
+ if(dir == RIGHT)
+ base.x = tux.base.x + 24;
+ else // dir == LEFT
+ base.x = tux.base.x - 4;
+ base.y = tux.base.y + tux.base.height/1.5 - base.height;
}
}
+
if(collision_object_map(base))
{
base.x = tux.base.x;
if(collision_object_map(base))
{
base.x = tux.base.x;
@@
-358,9
+366,9
@@
BadGuy::action_mriceblock(double elapsed_time)
if(tux.input.fire != DOWN) /* SHOOT! */
{
if(dir == LEFT)
if(tux.input.fire != DOWN) /* SHOOT! */
{
if(dir == LEFT)
- base.x
-= 24
;
+ base.x
= tux.base.x - base.width
;
else
else
- base.x
+= 24
;
+ base.x
= tux.base.x + tux.base.width
;
old_base = base;
mode=KICK;
old_base = base;
mode=KICK;
@@
-397,20
+405,27
@@
void
BadGuy::check_horizontal_bump(bool checkcliff)
{
float halfheight = base.height / 2;
BadGuy::check_horizontal_bump(bool checkcliff)
{
float halfheight = base.height / 2;
- if (dir == LEFT && issolid( base.x,
(int)
base.y + halfheight))
+ if (dir == LEFT && issolid( base.x, base.y + halfheight))
{
if (kind == BAD_MRICEBLOCK && mode == KICK)
{
if (kind == BAD_MRICEBLOCK && mode == KICK)
+ {
Sector::current()->trybreakbrick(Vector(base.x, base.y + halfheight), false);
Sector::current()->trybreakbrick(Vector(base.x, base.y + halfheight), false);
+ Sector::current()->tryemptybox(Vector(base.x, base.y + halfheight), dir);
+ }
dir = RIGHT;
physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
return;
}
dir = RIGHT;
physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
return;
}
- if (dir == RIGHT && issolid( base.x + base.width,
(int)
base.y + halfheight))
+ if (dir == RIGHT && issolid( base.x + base.width, base.y + halfheight))
{
if (kind == BAD_MRICEBLOCK && mode == KICK)
{
if (kind == BAD_MRICEBLOCK && mode == KICK)
+ {
Sector::current()->trybreakbrick(
Sector::current()->trybreakbrick(
- Vector(base.x + base.width, (int) base.y + halfheight), false);
+ Vector(base.x + base.width, base.y + halfheight), false);
+ Sector::current()->tryemptybox(
+ Vector(base.x + base.width, base.y + halfheight), dir);
+ }
dir = LEFT;
physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
dir = LEFT;
physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
@@
-1033,7
+1048,7
@@
BadGuy::squish_me(Player* player)
player->bounce(this);
Sector::current()->add_score(Vector(base.x, base.y),
player->bounce(this);
Sector::current()->add_score(Vector(base.x, base.y),
-
50
* player_status.score_multiplier);
+
25
* player_status.score_multiplier);
SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), Sector::current()->player->get_pos());
player_status.score_multiplier++;
SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), Sector::current()->player->get_pos());
player_status.score_multiplier++;
@@
-1054,8
+1069,10
@@
BadGuy::squish(Player* player)
player->bounce(this);
Sector::current()->add_score(Vector(base.x, base.y),
player->bounce(this);
Sector::current()->add_score(Vector(base.x, base.y),
-
50
* player_status.score_multiplier);
+
25
* player_status.score_multiplier);
SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), Sector::current()->player->get_pos());
SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), Sector::current()->player->get_pos());
+
+ global_stats.add_points(BADGUYS_SQUISHED_STAT, 1);
player_status.score_multiplier++;
return;
player_status.score_multiplier++;
return;
@@
-1107,6
+1124,8
@@
BadGuy::squish(Player* player)
Sector::current()->add_score(Vector(base.x, base.y),
25 * player_status.score_multiplier);
Sector::current()->add_score(Vector(base.x, base.y),
25 * player_status.score_multiplier);
+
+ global_stats.add_points(BADGUYS_SQUISHED_STAT, 1);
player_status.score_multiplier++;
// simply remove the fish...
player_status.score_multiplier++;
// simply remove the fish...
@@
-1142,7
+1161,8
@@
BadGuy::squish(Player* player)
player->bounce(this);
base.y += 66 - base.height;
player->bounce(this);
base.y += 66 - base.height;
-
+
+ global_stats.add_points(BADGUYS_SQUISHED_STAT, 1);
Sector::current()->add_score(Vector(base.x, base.y),
25 * player_status.score_multiplier);
player_status.score_multiplier++;
Sector::current()->add_score(Vector(base.x, base.y),
25 * player_status.score_multiplier);
player_status.score_multiplier++;
@@
-1325,7
+1345,8
@@
BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
// Put bad guys a part (or they get jammed)
// only needed to do to one of them
// Put bad guys a part (or they get jammed)
// only needed to do to one of them
- base.x = pbad_c->base.x + pbad_c->base.width + 1;
+ if (physic.get_velocity_x() != 0)
+ base.x = pbad_c->base.x + pbad_c->base.width + 1;
}
else if (dir == RIGHT)
{
}
else if (dir == RIGHT)
{