v0.5.0: added wall assist for tapping
This commit is contained in:
parent
87002dca6f
commit
2ec6e414d3
|
@ -54,7 +54,8 @@ public class CellSelector extends TouchArea {
|
||||||
|
|
||||||
select( ((DungeonTilemap)target).screenToTile(
|
select( ((DungeonTilemap)target).screenToTile(
|
||||||
(int)touch.current.x,
|
(int)touch.current.x,
|
||||||
(int)touch.current.y ) );
|
(int)touch.current.y,
|
||||||
|
true ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,17 +72,37 @@ public abstract class DungeonTilemap extends Tilemap {
|
||||||
|
|
||||||
protected abstract int getTileVisual(int pos, int tile, boolean flat);
|
protected abstract int getTileVisual(int pos, int tile, boolean flat);
|
||||||
|
|
||||||
public int screenToTile(int x, int y ) {
|
public int screenToTile(int x, int y ){
|
||||||
Point p = camera().screenToCamera( x, y ).
|
return screenToTile(x, y, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//wall assist is used to make raised perspective tapping a bit easier.
|
||||||
|
// If the pressed tile is a wall tile, the tap can be 'bumped' down into a none-wall tile.
|
||||||
|
// currently this happens if the bottom 1/4 of the wall tile is pressed.
|
||||||
|
public int screenToTile(int x, int y, boolean wallAssist ) {
|
||||||
|
PointF p = camera().screenToCamera( x, y ).
|
||||||
offset( this.point().negate() ).
|
offset( this.point().negate() ).
|
||||||
invScale( SIZE ).
|
invScale( SIZE );
|
||||||
floor();
|
if (p.x < 0 || p.x >= Dungeon.level.width()
|
||||||
return p.x >= 0
|
|| p.y < 0
|
||||||
&& p.x < Dungeon.level.width()
|
|| p.y >= Dungeon.level.height())
|
||||||
&& p.y >= 0
|
return -1;
|
||||||
&& p.y < Dungeon.level.height() ?
|
|
||||||
p.x + p.y * Dungeon.level.width()
|
int cell = (int)p.x + (int)p.y * Dungeon.level.width();
|
||||||
: -1;
|
|
||||||
|
if (wallAssist
|
||||||
|
&& map != null
|
||||||
|
&& DungeonTileSheet.wallStitcheable.contains(map[cell])){
|
||||||
|
|
||||||
|
if (cell + mapWidth < size
|
||||||
|
&& p.y % 1 >= 0.75f
|
||||||
|
&& !DungeonTileSheet.wallStitcheable.contains(map[cell + mapWidth])){
|
||||||
|
cell += mapWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user