End of chapter 4, World map scripts.
This commit is contained in:
27
scripts/game/maps/map2d.gd
Normal file
27
scripts/game/maps/map2d.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends TileMap
|
||||
|
||||
class_name Map2d
|
||||
|
||||
enum TerrainDataTypes { TerrainType }
|
||||
|
||||
|
||||
func getTerrainDataForTile(layer, data, x, y):
|
||||
var tile: TileData = get_cell_tile_data(layer, Vector2i(x, y))
|
||||
if tile != null:
|
||||
return tile.get_custom_data(TerrainDataTypes.keys()[data])
|
||||
else:
|
||||
return null
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
print(getTerrainDataForTile(0, TerrainDataTypes.TerrainType, 39, 17))
|
||||
print(getTerrainDataForTile(0, TerrainDataTypes.TerrainType, 0, 0))
|
||||
print(getTerrainDataForTile(0, TerrainDataTypes.TerrainType, 11, 11))
|
||||
print(getTerrainDataForTile(0, TerrainDataTypes.TerrainType, 6, 9))
|
||||
print(getTerrainDataForTile(0, TerrainDataTypes.TerrainType, 22, 22))
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
Reference in New Issue
Block a user