#include "mriceblock.hpp"
#include "object/block.hpp"
-static const float WALKSPEED = 80;
-static const float KICKSPEED = 500;
-static const int MAXSQUISHES = 10;
+namespace {
+ const float WALKSPEED = 80;
+ const float KICKSPEED = 500;
+ const int MAXSQUISHES = 10;
+}
MrIceBlock::MrIceBlock(const lisp::Lisp& reader)
- : ice_state(ICESTATE_NORMAL), squishcount(0)
+ : BadGuy(reader, "images/creatures/mr_iceblock/mr_iceblock.sprite"), ice_state(ICESTATE_NORMAL), squishcount(0)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("images/creatures/mr_iceblock/mr_iceblock.sprite");
+ reader.get("direction", direction);
set_direction = false;
+ if( direction != "auto" && direction != ""){
+ set_direction = true;
+ initial_direction = str2dir( direction );
+ }
+ sound_manager->preload("sounds/iceblock_bump.wav");
+ sound_manager->preload("sounds/stomp.wav");
+ sound_manager->preload("sounds/kick.wav");
}
-MrIceBlock::MrIceBlock(float pos_x, float pos_y, Direction d)
- : ice_state(ICESTATE_NORMAL), squishcount(0)
+MrIceBlock::MrIceBlock(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/mr_iceblock/mr_iceblock.sprite"), ice_state(ICESTATE_NORMAL), squishcount(0)
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("images/creatures/mr_iceblock/mr_iceblock.sprite");
set_direction = true;
initial_direction = d;
+ sound_manager->preload("sounds/iceblock_bump.wav");
+ sound_manager->preload("sounds/stomp.wav");
+ sound_manager->preload("sounds/kick.wav");
}
void
{
writer.start_list("mriceblock");
+ writer.write_string("direction", direction);
writer.write_float("x", start_position.x);
writer.write_float("y", start_position.y);
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
+ set_state(ICESTATE_NORMAL);
}
void
else
flags &= ~FLAG_PORTABLE;
- if(ice_state == ICESTATE_KICKED) {
- bbox.set_size(31.8, 31.8);
- }
-
switch(state) {
case ICESTATE_NORMAL:
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);