+Player::handle_input_ghost()
+{
+ float vx = 0;
+ float vy = 0;
+ if (controller->hold(Controller::LEFT)) {
+ dir = LEFT;
+ vx -= MAX_RUN_XM * 2;
+ }
+ if (controller->hold(Controller::RIGHT)) {
+ dir = RIGHT;
+ vx += MAX_RUN_XM * 2;
+ }
+ if ((controller->hold(Controller::UP)) || (controller->hold(Controller::JUMP))) {
+ vy -= MAX_RUN_XM * 2;
+ }
+ if (controller->hold(Controller::DOWN)) {
+ vy += MAX_RUN_XM * 2;
+ }
+ if (controller->hold(Controller::ACTION)) {
+ set_ghost_mode(false);
+ }
+ physic.set_velocity(vx, vy);
+ physic.set_acceleration(0, 0);
+}
+
+void
+Player::add_coins(int count)
+{
+ player_status->add_coins(count);
+}
+
+bool
+Player::add_bonus(const std::string& bonustype)
+{
+ BonusType type = NO_BONUS;
+
+ if(bonustype == "grow") {
+ type = GROWUP_BONUS;
+ } else if(bonustype == "fireflower") {
+ type = FIRE_BONUS;
+ } else if(bonustype == "iceflower") {
+ type = ICE_BONUS;
+ } else if(bonustype == "none") {
+ type = NO_BONUS;
+ } else {
+ std::ostringstream msg;
+ msg << "Unknown bonus type " << bonustype;
+ throw std::runtime_error(msg.str());
+ }
+
+ return add_bonus(type);
+}
+
+bool
+Player::add_bonus(BonusType type, bool animate)
+{
+ // always ignore NO_BONUS
+ if (type == NO_BONUS) {
+ return true;
+ }
+
+ // ignore GROWUP_BONUS if we're already big
+ if (type == GROWUP_BONUS) {
+ if (player_status->bonus == GROWUP_BONUS)
+ return true;
+ if (player_status->bonus == FIRE_BONUS)
+ return true;
+ if (player_status->bonus == ICE_BONUS)
+ return true;
+ }
+
+ return set_bonus(type, animate);
+}
+
+bool