Skip to content

Commit

Permalink
Move touch aim code into updateControls()
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmMoltony committed Feb 8, 2024
1 parent fc6fdd5 commit 5092894
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2593,20 +2593,6 @@ Player::UpdateResult Player::updateGameplay(s16 oldX, s16 oldY, Block::List *blo
statsSetEntry(STATS_KEY_BLOCKS_BROKEN, statsGetEntry(STATS_KEY_BLOCKS_BROKEN) + 1);
}

u32 keys = keysHeld();

if (keys & KEY_TOUCH)
{
touchPosition touchPos;
touchRead(&touchPos);
if (touchPos.px != 0 && touchPos.py != 0)
{
// aiming
aimX = touchPos.px;
aimY = touchPos.py;
}
}

bool collideLadder = false;

// check if collide with ladder
Expand Down Expand Up @@ -2715,6 +2701,18 @@ void Player::updateControls(bool collideLadder)
aimY = snapToGrid(aimY) + 8;
}

// aiming with touch
if (keys & KEY_TOUCH)
{
touchPosition touchPos;
touchRead(&touchPos);
if (touchPos.px != 0 && touchPos.py != 0)
{
aimX = touchPos.px;
aimY = touchPos.py;
}
}

// horizontal movement
if (left && !right)
velX = -2;
Expand Down

0 comments on commit 5092894

Please sign in to comment.