diff --git a/CMakeLists.txt b/CMakeLists.txt index a576ff1..d2b30d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,10 @@ add_executable(${TARGET} src/engine/object/game_object.cpp src/engine/component/sprite_component.cpp src/engine/component/transform_component.cpp + src/engine/component/parallax_component.cpp src/engine/scene/scene.cpp src/engine/scene/scene_manager.cpp + src/engine/scene/level_loader.cpp src/game/scene/game_scene.cpp ) diff --git a/Tiled地图解析思路.md b/Tiled地图解析思路.md new file mode 100644 index 0000000..41a71d4 --- /dev/null +++ b/Tiled地图解析思路.md @@ -0,0 +1,7 @@ +# Tiled地图解析思路 +- 获取layers数组并遍历对象 + - 如果 type : imagelayer,载入单一图片 + - 关注"parallax","repeat","offset"字段 + - 创建包含 ParallaxComponent 的游戏对象 + - 如果 type : tilelayer …… + - 如果 type : objectgroup …… \ No newline at end of file diff --git a/assets/maps/actor.tsj b/assets/maps/actor.tsj new file mode 100644 index 0000000..15c1091 --- /dev/null +++ b/assets/maps/actor.tsj @@ -0,0 +1,216 @@ +{ "columns":0, + "grid": + { + "height":1, + "orientation":"orthogonal", + "width":1 + }, + "margin":0, + "name":"actor", + "spacing":0, + "tilecount":6, + "tiledversion":"1.11.2", + "tileheight":41, + "tiles":[ + { + "height":41, + "id":0, + "image":"..\/textures\/Actors\/eagle-attack.png", + "imageheight":41, + "imagewidth":160, + "objectgroup": + { + "draworder":"index", + "id":2, + "name":"", + "objects":[ + { + "height":39, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":32, + "x":3, + "y":0 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + "width":40, + "x":0, + "y":0 + }, + { + "height":32, + "id":1, + "image":"..\/textures\/Actors\/foxy.png", + "imageheight":384, + "imagewidth":198, + "objectgroup": + { + "draworder":"index", + "id":3, + "name":"", + "objects":[ + { + "height":19, + "id":2, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":11, + "x":11, + "y":13 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + "width":32, + "x":0, + "y":0 + }, + { + "height":32, + "id":2, + "image":"..\/textures\/Actors\/frog.png", + "imageheight":64, + "imagewidth":140, + "objectgroup": + { + "draworder":"index", + "id":2, + "name":"", + "objects":[ + { + "height":19, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":26, + "x":4, + "y":8 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + "width":35, + "x":0, + "y":0 + }, + { + "height":28, + "id":3, + "image":"..\/textures\/Actors\/opossum.png", + "imageheight":28, + "imagewidth":216, + "objectgroup": + { + "draworder":"index", + "id":2, + "name":"", + "objects":[ + { + "height":25, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":28, + "x":1, + "y":2 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + "width":36, + "x":0, + "y":0 + }, + { + "height":21, + "id":4, + "image":"..\/textures\/Items\/cherry.png", + "imageheight":21, + "imagewidth":105, + "objectgroup": + { + "draworder":"index", + "id":2, + "name":"", + "objects":[ + { + "height":15, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":17, + "x":0, + "y":3 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + "width":21, + "x":0, + "y":0 + }, + { + "height":13, + "id":5, + "image":"..\/textures\/Items\/gem.png", + "imageheight":13, + "imagewidth":75, + "objectgroup": + { + "draworder":"index", + "id":2, + "name":"", + "objects":[ + { + "height":11, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":13, + "x":1, + "y":1 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + "width":15, + "x":0, + "y":0 + }], + "tilewidth":40, + "type":"tileset", + "version":"1.10" +} \ No newline at end of file diff --git a/assets/maps/level1.tmj b/assets/maps/level1.tmj new file mode 100644 index 0000000..b97900b --- /dev/null +++ b/assets/maps/level1.tmj @@ -0,0 +1,341 @@ +{ "compressionlevel":-1, + "height":29, + "infinite":false, + "layers":[ + { + "id":3, + "image":"..\/textures\/Layers\/back.png", + "imageheight":240, + "imagewidth":384, + "name":"far", + "opacity":1, + "parallaxx":0.2, + "repeatx":true, + "type":"imagelayer", + "visible":true, + "x":0, + "y":0 + }, + { + "id":4, + "image":"..\/textures\/Layers\/middle.png", + "imageheight":368, + "imagewidth":176, + "name":"mid", + "offsetx":0, + "offsety":96, + "opacity":1, + "parallaxx":0.6, + "repeatx":true, + "type":"imagelayer", + "visible":true, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 377, 378, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 380, 381, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 402, 403, 472, 518, 472, 472, 412, 472, 472, 518, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 405, 406, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 427, 428, 472, 472, 472, 472, 437, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 430, 431, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 452, 453, 472, 472, 472, 461, 462, 463, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 455, 456, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 380, 381, 0, 0, 0, 0, 0, 0, 0, 0, 587, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 377, 378, 472, 472, 472, 472, 405, 406, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 402, 403, 472, 472, 472, 472, 430, 431, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 605, 0, 0, 0, 0, 0, 0, 0, 0, 0, 427, 428, 472, 472, 472, 472, 455, 456, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 452, 453, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 470, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 412, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 418, 419, 420, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 470, 472, 418, 419, 420, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 412, 418, 419, 420, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 470, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 412, 472, 472, 472, 472, 412, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 470, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 437, 472, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 418, 419, 420, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 461, 462, 463, 472, 472, 472, 472, 472, 412, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 472, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":29, + "id":5, + "name":"back", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":91, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 252, 253, 253, 253, 253, 79, 79, 183, 79, 183, 183, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 255, 280, 281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 277, 278, 253, 79, 181, 79, 79, 183, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 79, 79, 79, 181, 181, 181, 79, 79, 79, 79, 183, 183, 79, 255, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 253, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 255, 280, 281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 277, 278, 253, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 129, 129, 337, 129, 129, 129, 129, 337, 129, 337, 333, 129, 129, 129, 129, 129, 129, 129, 333, 129, 129, 337, 129, 129, 129, 131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 362, 0, 0, 0, 0, 362, 0, 362, 358, 0, 0, 0, 0, 0, 0, 0, 358, 0, 0, 362, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 602, 602, 602, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 366, 368, 368, 368, 368, 368, 368, 368, 370, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 261, 0, 0, 0, 0, 0, 0, 261, 0, 0, 0, 0, 0, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 0, 0, 0, 27, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 117, 0, 0, 0, 0, 0, 0, 0, 0, 39, 40, 33, 29, 29, 29, 123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 121, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 262, 262, 262, 262, 262, 262, 27, 29, 29, 29, 29, 29, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 77, 79, 181, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 142, 117, 0, 0, 0, 585, 0, 115, 33, 33, 65, 79, 181, 79, 79, 148, 123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 468, 0, 0, 0, 0, 0, 0, 0, 0, 121, 146, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 181, 79, 79, 79, 79, 79, 79, 79, 79, 83, 84, 0, 0, 77, 79, 79, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 79, 79, 79, 142, 33, 33, 258, 33, 33, 140, 79, 79, 79, 79, 79, 79, 79, 79, 148, 29, 29, 29, 29, 29, 29, 48, 49, 0, 0, 0, 0, 0, 0, 468, 0, 0, 121, 29, 29, 29, 146, 79, 79, 183, 79, 79, 183, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 183, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 77, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 79, 79, 81, 258, 77, 79, 183, 79, 79, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 79, 79, 79, 73, 74, 29, 29, 29, 29, 29, 29, 29, 29, 29, 146, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 133, 134, 135, 0, 77, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 79, 183, 79, 81, 258, 77, 79, 183, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 183, 79, 79, 183, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 183, 79, 81, 0, 0, 0, 77, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 181, 79, 79, 81, 258, 77, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 181, 79, 79, 79, + 79, 79, 79, 79, 181, 79, 79, 79, 79, 81, 0, 0, 0, 77, 181, 79, 79, 79, 181, 79, 79, 79, 79, 79, 183, 181, 79, 79, 79, 79, 79, 81, 258, 77, 79, 79, 79, 502, 79, 79, 79, 181, 79, 79, 504, 505, 79, 183, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 181, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 77, 193, 193, 193, 193, 193, 193, 193, 295, 335, 291, 193, 193, 193, 193, 193, 193, 193, 295, 258, 291, 193, 193, 502, 502, 193, 335, 193, 333, 193, 502, 529, 530, 502, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 502, 181, 183, 79, 181, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 183, 183, 79, 79, 79, + 79, 79, 79, 79, 183, 79, 79, 79, 79, 81, 0, 0, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 360, 0, 0, 0, 0, 0, 0, 0, 0, 0, 258, 0, 0, 0, 0, 0, 0, 360, 0, 358, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 183, 181, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 183, 79, + 79, 79, 79, 183, 79, 79, 79, 183, 79, 81, 0, 0, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 385, 0, 0, 0, 0, 0, 0, 0, 0, 0, 258, 0, 0, 0, 0, 0, 0, 385, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 183, 79, 79, + 79, 79, 183, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 591, 0, 0, 0, 0, 0, 0, 0, 258, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 599, 591, 0, 599, 599, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 79, 79, 181, 79, 79, 79, 79, 79, 79, 183, 79, 181, 181, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 183, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 258, 0, 0, 0, 0, 591, 0, 0, 586, 0, 0, 0, 599, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 183, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 258, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 181, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 181, 79, 81, 0, 0, 0, 77, 0, 576, 0, 0, 0, 583, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, 602, 504, 505, 0, 0, 0, 578, 0, 0, 579, 0, 0, 0, 241, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 191, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 502, 193, 193, 504, 505, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 529, 530, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 502, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 183, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 241, 181, 79, 183, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 502, 529, 530, 502, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 79, 79, 183, 79, 79, 79, 183, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 183, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 241, 79, 79, 79, 79, 79, 79, 181, 79, 183, 79, 183, 79, 79, 183, 79, 79, 79, 79, 79, 79, 79, 502, 183, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 241, 79, 181, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 183, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 181, 79, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 81, 0, 0, 0, 241, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 181, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 183, 79, 79, 79, 181, 79, 79, 79, 79, 79, 79, 79, 79, 181, 81, 0, 0, 0, 0, 0, 0, 77, 79, 79, 79, 79, 181], + "height":29, + "id":1, + "name":"main", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":91, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":6, + "name":"object", + "objects":[ + { + "gid":608, + "height":32, + "id":1, + "name":"player", + "rotation":0, + "type":"", + "visible":true, + "width":32, + "x":32, + "y":160 + }, + { + "gid":607, + "height":41, + "id":2, + "name":"eagle", + "rotation":0, + "type":"", + "visible":true, + "width":40, + "x":720, + "y":144 + }, + { + "gid":607, + "height":41, + "id":3, + "name":"eagle", + "rotation":0, + "type":"", + "visible":true, + "width":40, + "x":1024, + "y":144 + }, + { + "gid":609, + "height":32, + "id":4, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":35, + "x":958, + "y":148 + }, + { + "gid":610, + "height":28, + "id":5, + "name":"opossum", + "rotation":0, + "type":"", + "visible":true, + "width":36, + "x":416, + "y":160 + }, + { + "gid":612, + "height":13, + "id":6, + "name":"gem", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":848, + "y":96 + }, + { + "gid":612, + "height":13, + "id":7, + "name":"gem", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":880, + "y":96 + }, + { + "gid":612, + "height":13, + "id":8, + "name":"gem", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":912, + "y":96 + }, + { + "gid":611, + "height":21, + "id":9, + "name":"fruit", + "rotation":0, + "type":"", + "visible":true, + "width":21, + "x":1088, + "y":128 + }, + { + "gid":611, + "height":21, + "id":10, + "name":"fruit", + "rotation":0, + "type":"", + "visible":true, + "width":21, + "x":464, + "y":352 + }, + { + "gid":612, + "height":13, + "id":11, + "name":"gem", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":176, + "y":112 + }, + { + "gid":598, + "height":10, + "id":12, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":16, + "x":704, + "y":384 + }, + { + "gid":601, + "height":9, + "id":13, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":272, + "y":297 + }, + { + "gid":601, + "height":9, + "id":14, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":288, + "y":297 + }, + { + "gid":601, + "height":9, + "id":16, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":304, + "y":297 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + { + "id":2, + "image":"..\/textures\/Preview.png", + "imageheight":464, + "imagewidth":1456, + "name":"ref", + "opacity":0.5, + "type":"imagelayer", + "visible":false, + "x":0, + "y":0 + }], + "nextlayerid":7, + "nextobjectid":17, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.11.2", + "tileheight":16, + "tilesets":[ + { + "firstgid":1, + "source":"tileset.tsj" + }, + { + "firstgid":576, + "source":"prop.tsj" + }, + { + "firstgid":607, + "source":"actor.tsj" + }], + "tilewidth":16, + "type":"map", + "version":"1.10", + "width":91 +} \ No newline at end of file diff --git a/assets/maps/prop.tsj b/assets/maps/prop.tsj new file mode 100644 index 0000000..0be65cb --- /dev/null +++ b/assets/maps/prop.tsj @@ -0,0 +1,278 @@ +{ "columns":0, + "grid": + { + "height":1, + "orientation":"orthogonal", + "width":1 + }, + "margin":0, + "name":"prop", + "spacing":0, + "tilecount":30, + "tiledversion":"1.11.2", + "tileheight":176, + "tiles":[ + { + "id":0, + "image":"..\/textures\/Props\/big-crate.png", + "imageheight":32, + "imagewidth":32, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":1, + "image":"..\/textures\/Props\/big-house.png", + "imageheight":144, + "imagewidth":170 + }, + { + "id":2, + "image":"..\/textures\/Props\/block-big.png", + "imageheight":32, + "imagewidth":32, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":3, + "image":"..\/textures\/Props\/block.png", + "imageheight":16, + "imagewidth":16, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":4, + "image":"..\/textures\/Props\/bush.png", + "imageheight":28, + "imagewidth":46 + }, + { + "id":5, + "image":"..\/textures\/Props\/crank-down.png", + "imageheight":16, + "imagewidth":22 + }, + { + "id":6, + "image":"..\/textures\/Props\/crank-up.png", + "imageheight":16, + "imagewidth":22 + }, + { + "id":7, + "image":"..\/textures\/Props\/crate.png", + "imageheight":16, + "imagewidth":16, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":8, + "image":"..\/textures\/Props\/door-opened.png", + "imageheight":33, + "imagewidth":22 + }, + { + "id":9, + "image":"..\/textures\/Props\/door.png", + "imageheight":33, + "imagewidth":22 + }, + { + "id":10, + "image":"..\/textures\/Props\/face-block.png", + "imageheight":32, + "imagewidth":32 + }, + { + "id":11, + "image":"..\/textures\/Props\/house.png", + "imageheight":108, + "imagewidth":87 + }, + { + "id":12, + "image":"..\/textures\/Props\/palm.png", + "imageheight":176, + "imagewidth":79 + }, + { + "id":13, + "image":"..\/textures\/Props\/pine.png", + "imageheight":130, + "imagewidth":82 + }, + { + "id":14, + "image":"..\/textures\/Props\/plant-house.png", + "imageheight":103, + "imagewidth":123 + }, + { + "id":15, + "image":"..\/textures\/Props\/platform-long.png", + "imageheight":16, + "imagewidth":32, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":17, + "image":"..\/textures\/Props\/rock-1.png", + "imageheight":53, + "imagewidth":53 + }, + { + "id":18, + "image":"..\/textures\/Props\/rock-2.png", + "imageheight":57, + "imagewidth":66 + }, + { + "id":19, + "image":"..\/textures\/Props\/rock.png", + "imageheight":15, + "imagewidth":28 + }, + { + "id":20, + "image":"..\/textures\/Props\/shrooms.png", + "imageheight":15, + "imagewidth":16 + }, + { + "id":21, + "image":"..\/textures\/Props\/sign.png", + "imageheight":20, + "imagewidth":18 + }, + { + "id":22, + "image":"..\/textures\/Props\/skulls.png", + "imageheight":10, + "imagewidth":16 + }, + { + "id":23, + "image":"..\/textures\/Props\/small-platform.png", + "imageheight":16, + "imagewidth":16, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":24, + "image":"..\/textures\/Props\/spike-skull.png", + "imageheight":12, + "imagewidth":17 + }, + { + "id":25, + "image":"..\/textures\/Props\/spikes-top.png", + "imageheight":9, + "imagewidth":15, + "objectgroup": + { + "draworder":"index", + "name":"", + "objects":[ + { + "height":9, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":0, + "y":0 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + } + }, + { + "id":26, + "image":"..\/textures\/Props\/spikes.png", + "imageheight":10, + "imagewidth":15, + "objectgroup": + { + "draworder":"index", + "name":"", + "objects":[ + { + "height":9, + "id":1, + "name":"", + "rotation":0, + "type":"", + "visible":true, + "width":15, + "x":0, + "y":1 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + } + }, + { + "id":27, + "image":"..\/textures\/Props\/straw-house.png", + "imageheight":96, + "imagewidth":128 + }, + { + "id":28, + "image":"..\/textures\/Props\/tree-house.png", + "imageheight":144, + "imagewidth":119 + }, + { + "id":29, + "image":"..\/textures\/Props\/tree.png", + "imageheight":111, + "imagewidth":119 + }, + { + "id":30, + "image":"..\/textures\/Props\/wooden-house.png", + "imageheight":98, + "imagewidth":112 + }], + "tilewidth":170, + "type":"tileset", + "version":"1.10" +} \ No newline at end of file diff --git a/assets/maps/tileset.tsj b/assets/maps/tileset.tsj new file mode 100644 index 0000000..ee1eb7b --- /dev/null +++ b/assets/maps/tileset.tsj @@ -0,0 +1,419 @@ +{ "columns":25, + "image":"..\/textures\/Layers\/tileset.png", + "imageheight":368, + "imagewidth":400, + "margin":0, + "name":"tileset", + "spacing":0, + "tilecount":575, + "tiledversion":"1.11.2", + "tileheight":16, + "tiles":[ + { + "id":26, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":28, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":30, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":32, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":36, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":63, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":64, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":69, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":70, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":72, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":73, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":76, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":80, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":82, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":86, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":126, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":128, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":130, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":132, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":139, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":141, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":145, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":147, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":180, + "probability":0.0500000007450581 + }, + { + "id":182, + "probability":0.0500000007450581 + }, + { + "id":190, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":192, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":194, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":240, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":244, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":261, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":290, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":292, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":294, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":332, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":334, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":336, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":338, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":365, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":367, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":369, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":501, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":503, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":504, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":528, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }, + { + "id":529, + "properties":[ + { + "name":"solid", + "type":"bool", + "value":true + }] + }], + "tilewidth":16, + "type":"tileset", + "version":"1.10" +} \ No newline at end of file diff --git a/src/engine/component/parallax_component.cpp b/src/engine/component/parallax_component.cpp new file mode 100644 index 0000000..b372175 --- /dev/null +++ b/src/engine/component/parallax_component.cpp @@ -0,0 +1,40 @@ +#include "parallax_component.h" +#include "transform_component.h" +#include "../render/renderer.h" +#include "../render/camera.h" +#include "../render/sprite.h" +#include "../object/game_object.h" +#include "../core/context.h" +#include + +namespace engine::component { + +ParallaxComponent::ParallaxComponent(const std::string& texture_id, const glm::vec2& scroll_factor, const glm::bvec2& repeat) + : sprite_(engine::render::Sprite(texture_id)), // 视差背景默认为整张图片 + scroll_factor_(scroll_factor), + repeat_(repeat) +{ + spdlog::trace("ParallaxComponent 初始化完成,纹理 ID: {}", texture_id); +} + +void ParallaxComponent::init() { + if (!owner_) { + spdlog::error("ParallaxComponent 初始化时,GameObject 为空。"); + return; + } + transform_ = owner_->getComponent(); + if (!transform_) { + spdlog::error("ParallaxComponent 初始化时,GameObject 上没有找到 TransformComponent 组件。"); + return; + } +} + +void ParallaxComponent::render(engine::core::Context& context) { + if (is_hidden_ || !transform_) { + return; + } + // 直接调用视差滚动绘制函数 + context.getRenderer().drawParallax(context.getCamera(), sprite_, transform_->getPosition(), scroll_factor_, repeat_, transform_->getScale()); +} + +} // namespace engine::component \ No newline at end of file diff --git a/src/engine/component/parallax_component.h b/src/engine/component/parallax_component.h new file mode 100644 index 0000000..6469ee4 --- /dev/null +++ b/src/engine/component/parallax_component.h @@ -0,0 +1,55 @@ +#pragma once +#include "component.h" +#include "../render/sprite.h" +#include +#include + +namespace engine::component { +class TransformComponent; + +/** + * @brief 在背景中渲染可滚动纹理的组件,以创建视差效果。 + * + * 该组件根据相机的位置和滚动因子来移动纹理。 + */ +class ParallaxComponent final : public Component { + friend class engine::object::GameObject; +private: + TransformComponent* transform_ = nullptr; ///< @brief 缓存变换组件 + + engine::render::Sprite sprite_; ///< @brief 精灵对象 + glm::vec2 scroll_factor_; ///< @brief 滚动速度因子 (0=静止, 1=随相机移动, <1=比相机慢) + glm::bvec2 repeat_; ///< @brief 是否沿着X和Y轴周期性重复 + bool is_hidden_ = false; ///< @brief 是否隐藏(不渲染) + +public: + /** + * @brief 构造函数 + * @param texture_id 背景纹理的资源 ID。 + * @param scroll_factor 控制背景相对于相机移动速度的因子。 + * (0, 0) 表示完全静止。 + * (1, 1) 表示与相机完全同步移动。 + * (0.5, 0.5) 表示以相机一半的速度移动。 + */ + ParallaxComponent(const std::string& texture_id, const glm::vec2& scroll_factor, const glm::bvec2& repeat); + + // --- 设置器 --- + void setSprite(const engine::render::Sprite& sprite) { sprite_ = sprite; } ///< @brief 设置精灵对象 + void setScrollFactor(const glm::vec2& factor) { scroll_factor_ = factor; } ///< @brief 设置滚动速度因子 + void setRepeat(const glm::bvec2& repeat) { repeat_ = repeat; } ///< @brief 设置是否重复 + void setHidden(bool hidden) { is_hidden_ = hidden; } ///< @brief 设置是否隐藏(不渲染) + + // --- 获取器 --- + const engine::render::Sprite& getSprite() const { return sprite_; } ///< @brief 获取精灵对象 + const glm::vec2& getScrollFactor() const { return scroll_factor_; } ///< @brief 获取滚动速度因子 + const glm::bvec2& getRepeat() const { return repeat_; } ///< @brief 获取是否重复 + bool isHidden() const { return is_hidden_; } ///< @brief 获取是否隐藏(不渲染) + +protected: + // 核心循环函数覆盖 + void update(float, engine::core::Context&) override {} // 必须实现纯虚函数,留空 + void init() override; + void render(engine::core::Context& context) override; +}; + +} // namespace engine::component \ No newline at end of file diff --git a/src/engine/scene/level_loader.cpp b/src/engine/scene/level_loader.cpp new file mode 100644 index 0000000..d80448c --- /dev/null +++ b/src/engine/scene/level_loader.cpp @@ -0,0 +1,119 @@ +#include "level_loader.h" +#include "../component/parallax_component.h" +#include "../component/transform_component.h" +#include "../object/game_object.h" +#include "../scene/scene.h" +#include "../core/context.h" +#include "../render/sprite.h" +#include +#include +#include +#include +#include + +namespace engine::scene { + +bool LevelLoader::loadLevel(const std::string& level_path, Scene& scene) { + map_path_ = level_path; + // 1. 加载 JSON 文件 + std::ifstream file(level_path); + if (!file.is_open()) { + spdlog::error("无法打开关卡文件: {}", level_path); + return false; + } + + // 2. 解析 JSON 数据 + nlohmann::json json_data; + try { + file >> json_data; + } catch (const nlohmann::json::parse_error& e) { + spdlog::error("解析 JSON 数据失败: {}", e.what()); + return false; + } + + // 3. 加载图层数据 + if (!json_data.contains("layers") || !json_data["layers"].is_array()) { // 地图文件中必须有 layers 数组 + spdlog::error("地图文件 '{}' 中缺少或无效的 'layers' 数组。", level_path); + return false; + } + for (const auto& layer_json : json_data["layers"]) { + // 获取各图层对象中的类型(type)字段 + std::string layer_type = layer_json.value("type", "none"); + if (!layer_json.value("visible", true)) { + spdlog::info("图层 '{}' 不可见,跳过加载。", layer_json.value("name", "Unnamed")); + continue; + } + + // 根据图层类型决定加载方法 + if (layer_type == "imagelayer") { + loadImageLayer(layer_json, scene); + } else if (layer_type == "tilelayer") { + loadTileLayer(layer_json, scene); + } else if (layer_type == "objectgroup") { + loadObjectLayer(layer_json, scene); + } else { + spdlog::warn("不支持的图层类型: {}", layer_type); + } + } + + spdlog::info("关卡加载完成: {}", level_path); + return true; +} + +void LevelLoader::loadImageLayer(const nlohmann::json& layer_json, Scene& scene) { + // 获取纹理相对路径 (会自动处理'\/'符号) + const std::string& image_path = layer_json.value("image", ""); + if (image_path.empty()) { + spdlog::error("图层 '{}' 缺少 'image' 属性。", layer_json.value("name", "Unnamed")); + return; + } + auto texture_id = resolvePath(image_path); + + // 获取图层偏移量(json中没有则代表未设置,给默认值即可) + const glm::vec2 offset = glm::vec2(layer_json.value("offsetx", 0.0f), layer_json.value("offsety", 0.0f)); + + // 获取视差因子及重复标志 + const glm::vec2 scroll_factor = glm::vec2(layer_json.value("parallaxx", 1.0f), layer_json.value("parallaxy", 1.0f)); + const glm::bvec2 repeat = glm::bvec2(layer_json.value("repeatx", false), layer_json.value("repeaty", false)); + + // 获取图层名称 + const std::string& layer_name = layer_json.value("name", "Unnamed"); + + /* 可用类似方法获取其它各种属性,这里我们暂时用不上 */ + + // 创建游戏对象 + auto game_object = std::make_unique(layer_name); + // 依次添加Transform,Parallax组件 + game_object->addComponent(offset); + game_object->addComponent(texture_id, scroll_factor, repeat); + // 添加到场景中 + scene.addGameObject(std::move(game_object)); + spdlog::info("加载图层: '{}' 完成", layer_name); +} + +void LevelLoader::loadTileLayer(const nlohmann::json&, Scene&) +{ + // TODO +} + +void LevelLoader::loadObjectLayer(const nlohmann::json&, Scene&) +{ + // TODO +} + +std::string LevelLoader::resolvePath(std::string image_path) +{ + try { + // 获取地图文件的父目录(相对于可执行文件) “assets/maps/level1.tmj” -> “assets/maps” + auto map_dir = std::filesystem::path(map_path_).parent_path(); + // 合并路径(相对于可执行文件)并返回。 /* std::filesystem::canonical:解析路径中的当前目录(.)和上级目录(..)导航符, + /* 得到一个干净的路径 */ + auto final_path = std::filesystem::canonical(map_dir / image_path); + return final_path.string(); + } catch (const std::exception& e) { + spdlog::error("解析路径失败: {}", e.what()); + return image_path; + } +} + +} // namespace engine::scene \ No newline at end of file diff --git a/src/engine/scene/level_loader.h b/src/engine/scene/level_loader.h new file mode 100644 index 0000000..506b8e1 --- /dev/null +++ b/src/engine/scene/level_loader.h @@ -0,0 +1,37 @@ +#pragma once +#include +#include + +namespace engine::scene { +class Scene; + +class LevelLoader final { + std::string map_path_; ///< @brief 地图路径(拼接路径时需要) +public: + LevelLoader() = default; + + /** + * @brief 加载关卡数据到指定的 Scene 对象中。 + * @param map_path Tiled JSON 地图文件的路径。 + * @param scene 要加载数据的目标 Scene 对象。 + * @return bool 是否加载成功。 + */ + bool loadLevel(const std::string& map_path, Scene& scene); + +private: + void loadImageLayer(const nlohmann::json& layer_json, Scene& scene); ///< @brief 加载图片图层 + void loadTileLayer(const nlohmann::json& layer_json, Scene& scene); ///< @brief 加载瓦片图层 + void loadObjectLayer(const nlohmann::json& layer_json, Scene& scene); ///< @brief 加载对象图层 + + /** + * @brief 解析图片路径,合并地图路径和相对路径。例如: + * 1. 地图路径:"assets/maps/level1.tmj" + * 2. 相对路径:"../textures/Layers/back.png" + * 3. 最终路径:"assets/textures/Layers/back.png" + * @param image_path (图片)相对路径 + * @return std::string 解析后的完整路径。 + */ + std::string resolvePath(std::string image_path); +}; + +} // namespace engine::scene \ No newline at end of file diff --git a/src/game/scene/game_scene.cpp b/src/game/scene/game_scene.cpp index 09c90e7..2b47aa1 100644 --- a/src/game/scene/game_scene.cpp +++ b/src/game/scene/game_scene.cpp @@ -3,6 +3,9 @@ #include "../../engine/object/game_object.h" #include "../../engine/component/transform_component.h" #include "../../engine/component/sprite_component.h" +#include "../../engine/scene/level_loader.h" +#include "../../engine/input/input_manager.h" +#include "../../engine/render/camera.h" #include #include @@ -15,6 +18,10 @@ GameScene::GameScene(std::string name, engine::core::Context& context, engine::s } void GameScene::init() { + // 加载关卡(level_loader通常加载完成后即可销毁,因此不存为成员变量) + engine::scene::LevelLoader level_loader; + level_loader.loadLevel("assets/maps/level1.tmj", *this); + // 创建 test_object createTestObject(); @@ -32,13 +39,14 @@ void GameScene::render() { void GameScene::handleInput() { Scene::handleInput(); + testCamera(); } void GameScene::clean() { Scene::clean(); } -// --- 私有方法 --- +// --- 测试方法 --- void GameScene::createTestObject() { spdlog::trace("在 GameScene 中创建 test_object..."); @@ -53,4 +61,13 @@ void GameScene::createTestObject() { spdlog::trace("test_object 创建并添加到 GameScene 中。"); } +void GameScene::testCamera() { + auto& camera = context_.getCamera(); + auto& input_manager = context_.getInputManager(); + if (input_manager.isActionDown("move_up")) camera.move(glm::vec2(0, -1)); + if (input_manager.isActionDown("move_down")) camera.move(glm::vec2(0, 1)); + if (input_manager.isActionDown("move_left")) camera.move(glm::vec2(-1, 0)); + if (input_manager.isActionDown("move_right")) camera.move(glm::vec2(1, 0)); +} + } // namespace game::scene \ No newline at end of file diff --git a/src/game/scene/game_scene.h b/src/game/scene/game_scene.h index c054890..602caf1 100644 --- a/src/game/scene/game_scene.h +++ b/src/game/scene/game_scene.h @@ -27,6 +27,7 @@ public: private: // 测试函数 void createTestObject(); + void testCamera(); }; } // namespace game::scene \ No newline at end of file