Exemplo n.º 1
0
  void update(float delta)
  {
    x_axis->update(delta);
    y_axis->update(delta);
    if (speed_button) speed_button->update(delta);

    Vector2f new_pos = pos;
    float c_speed = speed;
    
    if (speed_button && speed_button->get_state() == BUTTON_PRESSED)
    {
      c_speed *= 5.0f;
    }

    new_pos.x += x_axis->get_pos() * c_speed * delta;
    new_pos.y += y_axis->get_pos() * c_speed * delta;

    // FIXME: shouldn't depend on Display
    new_pos.x = Math::clamp(0.0f, new_pos.x, static_cast<float>(Display::get_width()));
    new_pos.y = Math::clamp(0.0f, new_pos.y, static_cast<float>(Display::get_height()));

    if (new_pos != pos)
    {
      pos = new_pos;
      notify_parent();
    }
  }
Exemplo n.º 2
0
  void update(float delta_)
  {
    x_axis->update(delta_);
    y_axis->update(delta_);

    if (speed_button) speed_button->update(delta_);

    float    c_speed = speed;
    
    if (speed_button && speed_button->get_state() == BUTTON_PRESSED)
    {
      c_speed *= 5.0f;
    }

    this->delta.x = -x_axis->get_pos() * c_speed * delta_;
    this->delta.y = y_axis->get_pos() * c_speed * delta_;

    notify_parent();
  }