added packages

cleaned up messy things
fixed emoji not moving when prefix is a direction
fixed input message get deleted when game not active
fixed more errors
maybe something else i forgot
This commit is contained in:
AffluentAvo
2020-08-07 16:22:11 +02:00
parent 5f09809a6c
commit 6c3a422295
19 changed files with 659 additions and 257 deletions
@@ -0,0 +1,102 @@
package me.polymarsdev.sokobot.entity;
import me.polymarsdev.sokobot.objects.Grid;
public class Player
{
int x = 0;
int y = 0;
Grid currentGrid;
public Player(int x, int y, Grid currentGrid)
{
this.x = x;
this.y = y;
this.currentGrid = currentGrid;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public void setPosition(int x, int y)
{
this.x = x;
this.y = y;
}
public boolean moveUp()
{
if (!currentGrid.isWall(x, y - 1))
{
if (currentGrid.isBox(x, y - 1))
{
if (currentGrid.getBox(x, y - 1).moveUp())
{
y -= 1;
return true;
}
return false;
}
y -= 1;
return true;
}
return false;
}
public boolean moveDown()
{
if (!currentGrid.isWall(x, y + 1))
{
if (currentGrid.isBox(x, y + 1))
{
if (currentGrid.getBox(x, y + 1).moveDown())
{
y += 1;
return true;
}
return false;
}
y += 1;
return true;
}
return false;
}
public boolean moveLeft()
{
if (!currentGrid.isWall(x - 1, y))
{
if (currentGrid.isBox(x - 1, y))
{
if (currentGrid.getBox(x - 1, y).moveLeft())
{
x -= 1;
return true;
}
return false;
}
x -= 1;
return true;
}
return false;
}
public boolean moveRight()
{
if (!currentGrid.isWall(x + 1, y))
{
if (currentGrid.isBox(x + 1, y))
{
if (currentGrid.getBox(x + 1, y).moveRight())
{
x += 1;
return true;
}
return false;
}
x += 1;
return true;
}
return false;
}
}