projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Short Fuse runs dead-script when exploding, not just when kill_fall() is called
[supertux.git]
/
src
/
badguy
/
yeti.cpp
diff --git
a/src/badguy/yeti.cpp
b/src/badguy/yeti.cpp
index
08631e5
..
f7f8a4d
100644
(file)
--- a/
src/badguy/yeti.cpp
+++ b/
src/badguy/yeti.cpp
@@
-36,19
+36,19
@@
const float JUMP_DOWN_VY = -250; /**< vertical speed while jumping off the dais
const float RUN_VX = 350; /**< horizontal speed while running */
const float JUMP_UP_VX = 350; /**< horizontal speed while jumping on the dais */
const float RUN_VX = 350; /**< horizontal speed while running */
const float JUMP_UP_VX = 350; /**< horizontal speed while jumping on the dais */
-const float JUMP_UP_VY = -
8
00; /**< vertical speed while jumping on the dais */
+const float JUMP_UP_VY = -
7
00; /**< vertical speed while jumping on the dais */
-const float STOMP_VY = -
25
0; /** vertical speed while stomping on the dais */
+const float STOMP_VY = -
30
0; /** vertical speed while stomping on the dais */
-const float LEFT_STAND_X =
16
; /**< x-coordinate of left dais' end position */
-const float RIGHT_STAND_X =
800-60-16
; /**< x-coordinate of right dais' end position */
-const float LEFT_JUMP_X = LEFT_STAND_X+
224
; /**< x-coordinate of from where to jump on the left dais */
-const float RIGHT_JUMP_X = RIGHT_STAND_X-
224
; /**< x-coordinate of from where to jump on the right dais */
+const float LEFT_STAND_X =
80
; /**< x-coordinate of left dais' end position */
+const float RIGHT_STAND_X =
1280-LEFT_STAND_X-60
; /**< x-coordinate of right dais' end position */
+const float LEFT_JUMP_X = LEFT_STAND_X+
448
; /**< x-coordinate of from where to jump on the left dais */
+const float RIGHT_JUMP_X = RIGHT_STAND_X-
448
; /**< x-coordinate of from where to jump on the right dais */
const float STOMP_WAIT = .5; /**< time we stay on the dais before jumping again */
const float SAFE_TIME = .5; /**< the time we are safe when tux just hit us */
const float STOMP_WAIT = .5; /**< time we stay on the dais before jumping again */
const float SAFE_TIME = .5; /**< the time we are safe when tux just hit us */
-const int INITIAL_HITPOINTS =
3
; /**< number of hits we can take */
+const int INITIAL_HITPOINTS =
5
; /**< number of hits we can take */
-const float SQUISH_TIME = 5;
+const float
YETI_
SQUISH_TIME = 5;
}
Yeti::Yeti(const Reader& reader) :
}
Yeti::Yeti(const Reader& reader) :
@@
-64,7
+64,7
@@
Yeti::Yeti(const Reader& reader) :
countMe = false;
sound_manager->preload("sounds/yeti_gna.wav");
sound_manager->preload("sounds/yeti_roar.wav");
countMe = false;
sound_manager->preload("sounds/yeti_gna.wav");
sound_manager->preload("sounds/yeti_roar.wav");
- hud_head
.reset(new Surface("images/creatures/yeti/hudlife.png")
);
+ hud_head
= Surface::create("images/creatures/yeti/hudlife.png"
);
}
Yeti::~Yeti()
}
Yeti::~Yeti()
@@
-95,19
+95,18
@@
Yeti::draw_hit_points(DrawingContext& context)
{
int i;
{
int i;
- Surface *hh = hud_head.get();
- if (!hh)
- return;
+ if (hud_head)
+ {
+ context.push_transform();
+ context.set_translation(Vector(0, 0));
- context.push_transform();
- context.set_translation(Vector(0, 0));
+ for (i = 0; i < hit_points; ++i)
+ {
+ context.draw_surface(hud_head, Vector(BORDER_X + (i * hud_head->get_width()), BORDER_Y + 1), LAYER_FOREGROUND1);
+ }
- for (i = 0; i < hit_points; ++i)
- {
- context.draw_surface(hh, Vector(BORDER_X + (i * hh->get_width()), BORDER_Y + 1), LAYER_FOREGROUND1);
+ context.pop_transform();
}
}
-
- context.pop_transform();
}
void
}
void
@@
-173,23
+172,16
@@
void
Yeti::be_angry()
{
//turn around
Yeti::be_angry()
{
//turn around
- dir = (dir==RIGHT)
?LEFT:
RIGHT;
+ dir = (dir==RIGHT)
? LEFT :
RIGHT;
- sprite->set_action((dir==RIGHT)
?"stand-right":
"stand-left");
+ sprite->set_action((dir==RIGHT)
? "stand-right" :
"stand-left");
physic.set_velocity_x(0);
physic.set_velocity_y(0);
physic.set_velocity_x(0);
physic.set_velocity_y(0);
- if (hit_points < INITIAL_HITPOINTS) summon_snowball();
stomp_count = 0;
state = BE_ANGRY;
state_timer.start(STOMP_WAIT);
}
stomp_count = 0;
state = BE_ANGRY;
state_timer.start(STOMP_WAIT);
}
-void
-Yeti::summon_snowball()
-{
- Sector::current()->add_object(new BouncingSnowball(Vector(get_pos().x+(dir == RIGHT ? 64 : -64), get_pos().y), dir));
-}
-
bool
Yeti::collision_squished(GameObject& object)
{
bool
Yeti::collision_squished(GameObject& object)
{
@@
-223,7
+215,7
@@
void Yeti::take_hit(Player& )
physic.set_velocity_y(0);
state = SQUISHED;
physic.set_velocity_y(0);
state = SQUISHED;
- state_timer.start(SQUISH_TIME);
+ state_timer.start(
YETI_
SQUISH_TIME);
set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC);
sprite->set_action("dead");
set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC);
sprite->set_action("dead");
@@
-238,7
+230,6
@@
void
Yeti::kill_fall()
{
// shooting bullets or being invincible won't work :)
Yeti::kill_fall()
{
// shooting bullets or being invincible won't work :)
- //take_hit(*get_nearest_player()); // FIXME: debug only(?)
}
void
}
void
@@
-247,9
+238,6
@@
Yeti::drop_stalactite()
// make a stalactite falling down and shake camera a bit
Sector::current()->camera->shake(.1f, 0, 10);
// make a stalactite falling down and shake camera a bit
Sector::current()->camera->shake(.1f, 0, 10);
- YetiStalactite* nearest = 0;
- float dist = FLT_MAX;
-
Player* player = this->get_nearest_player();
if (!player) return;
Player* player = this->get_nearest_player();
if (!player) return;
@@
-258,17
+246,22
@@
Yeti::drop_stalactite()
i != sector->gameobjects.end(); ++i) {
YetiStalactite* stalactite = dynamic_cast<YetiStalactite*> (*i);
if(stalactite && stalactite->is_hanging()) {
i != sector->gameobjects.end(); ++i) {
YetiStalactite* stalactite = dynamic_cast<YetiStalactite*> (*i);
if(stalactite && stalactite->is_hanging()) {
- float sdist
- = fabsf(stalactite->get_pos().x - player->get_pos().x);
- if(sdist < dist) {
- nearest = stalactite;
- dist = sdist;
+ float distancex;
+ if (hit_points >= 3) {
+ // drop stalactites within 3 of player, going out with each jump
+ distancex = fabsf(stalactite->get_bbox().get_middle().x - player->get_bbox().get_middle().x);
+ if(distancex < stomp_count*32) {
+ stalactite->start_shaking();
+ }
}
}
- }
+ else { /* if (hitpoints < 3) */
+ // drop every 3rd pair of stalactites
+ if(((((int)stalactite->get_pos().x + 16) / 64) % 3) == (stomp_count % 3)) {
+ stalactite->start_shaking();
+ }
+ }
+ } /* if(stalactite && stalactite->is_hanging()) */
}
}
-
- if(nearest)
- nearest->start_shaking();
}
void
}
void
@@
-310,6
+303,4
@@
Yeti::collision_solid(const CollisionHit& hit)
}
}
}
}
-IMPLEMENT_FACTORY(Yeti, "yeti");
-
/* EOF */
/* EOF */