diff options
author | Indrajith K L | 2021-08-03 17:53:10 +0530 |
---|---|---|
committer | Indrajith K L | 2021-08-03 17:53:10 +0530 |
commit | 705886d371cf2cfa619b321c0d87caca0773a789 (patch) | |
tree | 0e860ca10c6cfd122b403b02e84d4fef72078b63 /level_map.wren | |
parent | 5bd12d5a658c1cd710bc950be971ebe3993ed11d (diff) | |
download | rebirth-wren-705886d371cf2cfa619b321c0d87caca0773a789.tar.gz rebirth-wren-705886d371cf2cfa619b321c0d87caca0773a789.tar.bz2 rebirth-wren-705886d371cf2cfa619b321c0d87caca0773a789.zip |
Bug Fixes
Player Placement
Basic Player Movement
Diffstat (limited to 'level_map.wren')
-rw-r--r-- | level_map.wren | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/level_map.wren b/level_map.wren index 2bfb941..88ce9c6 100644 --- a/level_map.wren +++ b/level_map.wren @@ -1,8 +1,8 @@ import "json" for Json import "graphics" for ImageData import "math" for Math -import "./layer_type" for LayerType - +import "./layer_type" for LayerType, ObjectType +import "./entities/player_entity" for Player class LevelMap { construct new(mapName) { _mapData = Json.load("assets/%(mapName).json") @@ -17,9 +17,45 @@ class LevelMap { _layers = _mapData["layers"] _rows = Math.floor(_tileSheetW/_tileW) _cols = Math.floor(_tileSheetH/_tileH) + _playerPos = { + "x": 0, + "y": 0 + } + placeObjects() + + } + + playerPos = (position) { + _playerPos = position + } + + playerPos { _playerPos } + + placeObjects() { + for(layer in _layers) { + if(layer["type"] == LayerType.Object) { + for(object in layer["objects"]) { + if(object["type"]==ObjectType.PLAYER) { + playerPos = { + "x": object["x"], + "y": object["y"] + } + _player = Player.new(playerPos["x"], playerPos["y"]) + } + } + } + } + } + + draw(dt) { + _player.draw(dt) + } + + update() { + _player.update() } - draw(x, y) { + render(x, y) { var startX = x var startY = y for(layer in _layers) { |