From: florianf Date: Fri, 26 Mar 2010 19:50:39 +0000 (+0000) Subject: Krosh: Add large (4x4) icecrusher sprite and code. X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=24d113c0f3e39cafe7b9f3bcb8f518b7cbfe2346;p=supertux.git Krosh: Add large (4x4) icecrusher sprite and code. When a big icecrusher is used, the camera shakes more, the up movement is slower and the timeouts are longer. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6627 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/data/images/creatures/icecrusher/krosh.png b/data/images/creatures/icecrusher/krosh.png new file mode 100644 index 000000000..3a750915a Binary files /dev/null and b/data/images/creatures/icecrusher/krosh.png differ diff --git a/data/images/creatures/icecrusher/krosh.sprite b/data/images/creatures/icecrusher/krosh.sprite new file mode 100644 index 000000000..1da663d2f --- /dev/null +++ b/data/images/creatures/icecrusher/krosh.sprite @@ -0,0 +1,20 @@ +(supertux-sprite + (action + (name "idle") + (hitbox 2 0 128 128) + (images "krosh.png" + ) + ) + (action + (name "crushing") + (hitbox 2 0 128 128) + (images "krosh.png" + ) + ) + (action + (name "recovering") + (hitbox 2 0 128 128) + (images "krosh.png" + ) + ) +) diff --git a/src/object/icecrusher.cpp b/src/object/icecrusher.cpp index 2874d263a..7d4b6cab8 100644 --- a/src/object/icecrusher.cpp +++ b/src/object/icecrusher.cpp @@ -20,15 +20,18 @@ #include "badguy/badguy.hpp" #include "sprite/sprite.hpp" #include "object/player.hpp" +#include "object/camera.hpp" #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" namespace { /* Maximum movement speed in pixels per LOGICAL_FPS */ const float MAX_DROP_SPEED = 10.0; -const float RECOVER_SPEED = -3.125; +const float RECOVER_SPEED_NORMAL = -3.125; +const float RECOVER_SPEED_LARGE = -2.0; const float DROP_ACTIVATION_DISTANCE = 4.0; -const float PAUSE_TIME = 0.5; +const float PAUSE_TIME_NORMAL = 0.5; +const float PAUSE_TIME_LARGE = 1.0; } IceCrusher::IceCrusher(const Reader& reader) : @@ -36,10 +39,16 @@ IceCrusher::IceCrusher(const Reader& reader) : state(IDLE), start_position(), physic(), - cooldown_timer(0.0) + cooldown_timer(0.0), + ic_size(NORMAL) { start_position = get_bbox().p1; set_state(state, true); + + float sprite_width = sprite->get_width (); + log_debug << "My width is " << sprite_width; + if (sprite_width >= 128.0) + ic_size = LARGE; } /* @@ -112,7 +121,14 @@ IceCrusher::collision_solid(const CollisionHit& hit) break; case CRUSHING: if (hit.bottom) { - cooldown_timer = PAUSE_TIME; + if (ic_size == LARGE) { + cooldown_timer = PAUSE_TIME_LARGE; + Sector::current()->camera->shake (/* frequency = */ .125f, /* x = */ 0.0, /* y = */ 16.0); + } + else { + cooldown_timer = PAUSE_TIME_NORMAL; + Sector::current()->camera->shake (/* frequency = */ .1f, /* x = */ 0.0, /* y = */ 8.0); + } set_state(RECOVERING); } break; @@ -153,11 +169,17 @@ IceCrusher::update(float elapsed_time) if (get_bbox().p1.y <= start_position.y+1) { set_pos(start_position); movement = Vector (0, 0); - cooldown_timer = PAUSE_TIME; + if (ic_size == LARGE) + cooldown_timer = PAUSE_TIME_LARGE; + else + cooldown_timer = PAUSE_TIME_NORMAL; set_state(IDLE); } else { - movement = Vector (0, RECOVER_SPEED); + if (ic_size == LARGE) + movement = Vector (0, RECOVER_SPEED_LARGE); + else + movement = Vector (0, RECOVER_SPEED_NORMAL); } break; default: diff --git a/src/object/icecrusher.hpp b/src/object/icecrusher.hpp index 096fdfb5c..224ee79ab 100644 --- a/src/object/icecrusher.hpp +++ b/src/object/icecrusher.hpp @@ -57,6 +57,12 @@ protected: bool found_victim(); void set_state(IceCrusherState state, bool force = false); +private: + enum IceCrusherSize { + NORMAL, + LARGE + }; + IceCrusherSize ic_size; }; #endif