mirror of
https://github.com/Motschen/Adventura.git
synced 2025-12-17 04:05:10 +01:00
Add victory & death screens
This commit is contained in:
@@ -29,8 +29,14 @@ bool onInput(char lastChar, World& world, Player& player) {
|
||||
}
|
||||
}
|
||||
bool tryWalk(World& world, Player& player, bool left) {
|
||||
if (!world.getBlockAt(player.getPos()+(left ? BlockPos(-1, 1) : BlockPos(1, 1))).getSettings().hasCollision()) {
|
||||
player.move(left ? BlockPos(-1, 0) : BlockPos(1,0));
|
||||
BlockPos neighbourPosTorso = player.getPos()+(left ? BlockPos(-1, 0) : BlockPos(1, 0));
|
||||
BlockPos neighbourPosFeet = player.getPos()+(left ? BlockPos(-1, 1) : BlockPos(1, 1));
|
||||
if (!world.getBlockAt(neighbourPosFeet).getSettings().hasCollision()) {
|
||||
player.setPos(neighbourPosTorso);
|
||||
return true;
|
||||
}
|
||||
else if (!left && world.getBlockAt(neighbourPosFeet).getSettings().hasCollision() && !world.getBlockAt(neighbourPosTorso).getSettings().isSolid()) {
|
||||
left ? player.move(-1, -1) : player.move(1, -1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -47,13 +53,5 @@ bool tryGoUp(World& world, Player& player) {
|
||||
player.move(0, -1);
|
||||
return true;
|
||||
}
|
||||
else if (world.getBlockAt(player.getPos()+BlockPos(1, 1)).getSettings().hasCollision() && !world.getBlockAt(player.getPos()+BlockPos(1, 0)).getSettings().isSolid()) {
|
||||
player.move(1, -1);
|
||||
return true;
|
||||
}
|
||||
else if (world.getBlockAt(player.getPos()+BlockPos(-1, 1)).getSettings().hasCollision() && !world.getBlockAt(player.getPos()+BlockPos(-1, 0)).getSettings().isSolid()) {
|
||||
player.move(-1, -1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user