ソースを参照

remove break_timer_ and jmup_timer_

opengl-renderer-broken
Martin Dørum 4年前
コミット
81d20fca74
2個のファイルの変更4行の追加6行の削除
  1. 3
    5
      core.mod/src/entities/EntPlayer.cc
  2. 1
    1
      core.mod/src/entities/EntPlayer.h

+ 3
- 5
core.mod/src/entities/EntPlayer.cc ファイルの表示

@@ -23,13 +23,11 @@ void EntPlayer::update(Swan::Game &game, Swan::WorldPlane &plane, float dt) {

mouse_tile_ = game.getMouseTile();
plane.debugBox(mouse_tile_);
break_timer_.tick(dt);
jump_timer_.tick(dt);

// Break block
if (game.isMousePressed() && break_timer_.periodic(0.25)) {
fprintf(stderr, "button pressed\n");
if (game.isMousePressed())
plane.setTile(mouse_tile_, "core::air");
}

// Move left
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A) || sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
@@ -47,7 +45,7 @@ void EntPlayer::update(Swan::Game &game, Swan::WorldPlane &plane, float dt) {
}

// Jump
if (body_.on_ground_ && sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
if (body_.on_ground_ && sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && jump_timer_.periodic(0.5)) {
body_.vel_.y_ = -JUMP_FORCE;
}


+ 1
- 1
core.mod/src/entities/EntPlayer.h ファイルの表示

@@ -35,7 +35,7 @@ private:
State state_ = State::IDLE;
Swan::Animation anims_[(int)State::COUNT];

Swan::Timer break_timer_;
Swan::Timer jump_timer_;
Swan::TilePos mouse_tile_;

Swan::Body body_;

読み込み中…
キャンセル
保存