Fixed names for a better traceability of code errors with orignal code lesson. End of lesson 25. Player is moving on the map viewport!
This commit is contained in:
20
scripts/game/maps/WorldMap.gd
Normal file
20
scripts/game/maps/WorldMap.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
extends Map2d
|
||||
|
||||
class_name WorldMap
|
||||
|
||||
func playerCanMoveTo(position:Vector2) -> bool:
|
||||
var tilesize = tile_set.tile_size.x
|
||||
var cast_cell_1
|
||||
var cast_cell_2
|
||||
|
||||
player.updateRaycasts(position)
|
||||
|
||||
cast_cell_1 = local_to_map(position + player.collisionRay_1.position)
|
||||
cast_cell_2 = local_to_map(position + player.collisionRay_2.position)
|
||||
|
||||
if (getTerrainDataForTile(0, TerrainDataTypes.TerrainType, cast_cell_1.x, cast_cell_1.y) != "Water" and
|
||||
getTerrainDataForTile(0, TerrainDataTypes.TerrainType, cast_cell_2.x, cast_cell_2.y) != "Water"):
|
||||
return true
|
||||
else:
|
||||
CommandDispatcher.DISPLAY_MESSAGE.emit("Your path is blocked.")
|
||||
return false
|
||||
Reference in New Issue
Block a user