diff --git a/projects/flixel/rpg-tutorial/Project.xml b/projects/flixel/rpg-tutorial/Project.xml index e0cc16da..bea63206 100644 --- a/projects/flixel/rpg-tutorial/Project.xml +++ b/projects/flixel/rpg-tutorial/Project.xml @@ -38,7 +38,7 @@ - + diff --git a/projects/flixel/rpg-tutorial/assets/data/room-001.json b/projects/flixel/rpg-tutorial/assets/data/room-001.json new file mode 100644 index 00000000..c646228a --- /dev/null +++ b/projects/flixel/rpg-tutorial/assets/data/room-001.json @@ -0,0 +1,36 @@ +{ + "ogmoVersion": "3.4.0", + "width": 640, + "height": 480, + "offsetX": 0, + "offsetY": 0, + "layers": [ + { + "name": "entities", + "_eid": "65210876", + "offsetX": 0, + "offsetY": 0, + "gridCellWidth": 16, + "gridCellHeight": 16, + "gridCellsX": 40, + "gridCellsY": 30, + "entities": [ + {"name": "player", "id": 0, "_eid": "65218053", "x": 432, "y": 288, "originX": 0, "originY": 0} + ] + }, + { + "name": "walls", + "_eid": "65212980", + "offsetX": 0, + "offsetY": 0, + "gridCellWidth": 16, + "gridCellHeight": 16, + "gridCellsX": 40, + "gridCellsY": 30, + "tileset": "tiles", + "data": [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], + "exportMode": 0, + "arrayMode": 0 + } + ] +} \ No newline at end of file diff --git a/projects/flixel/rpg-tutorial/assets/data/turnBasedRPG.ogmo b/projects/flixel/rpg-tutorial/assets/data/turnBasedRPG.ogmo new file mode 100644 index 00000000..08d76127 --- /dev/null +++ b/projects/flixel/rpg-tutorial/assets/data/turnBasedRPG.ogmo @@ -0,0 +1,79 @@ +{ + "name": "HaxeFlixel Tutorial", + "ogmoVersion": "3.4.0", + "levelPaths": ["."], + "backgroundColor": "#282c34ff", + "gridColor": "#3c4049cc", + "anglesRadians": false, + "directoryDepth": 5, + "layerGridDefaultSize": {"x": 16, "y": 16}, + "levelDefaultSize": {"x": 320, "y": 240}, + "levelMinSize": {"x": 640, "y": 480}, + "levelMaxSize": {"x": 640, "y": 480}, + "levelValues": [], + "defaultExportMode": ".json", + "compactExport": false, + "externalScript": "", + "playCommand": "", + "entityTags": [], + "layers": [ + { + "definition": "entity", + "name": "entities", + "gridSize": {"x": 16, "y": 16}, + "exportID": "65210876", + "requiredTags": [], + "excludedTags": [] + }, + { + "definition": "tile", + "name": "walls", + "gridSize": {"x": 16, "y": 16}, + "exportID": "65212980", + "exportMode": 0, + "arrayMode": 0, + "defaultTileset": "" + } + ], + "entities": [ + { + "exportID": "65218053", + "name": "player", + "limit": -1, + "size": {"x": 16, "y": 16}, + "origin": {"x": 0, "y": 0}, + "originAnchored": true, + "shape": { + "label": "Rectangle", + "points": [ + {"x": -1, "y": -1}, + {"x": 1, "y": -1}, + {"x": -1, "y": 1}, + {"x": 1, "y": -1}, + {"x": -1, "y": 1}, + {"x": 1, "y": 1} + ] + }, + "color": "#ff0000ff", + "tileX": false, + "tileY": false, + "tileSize": {"x": 16, "y": 16}, + "resizeableX": false, + "resizeableY": false, + "rotatable": false, + "rotationDegrees": 360, + "canFlipX": false, + "canFlipY": false, + "canSetColor": false, + "hasNodes": false, + "nodeLimit": 0, + "nodeDisplay": 0, + "nodeGhost": true, + "tags": [], + "values": [] + } + ], + "tilesets": [ + {"label": "tiles", "path": "../images/tiles.png", "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAQCAYAAABQrvyxAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6ODRBQjNDODZENDhCMTFFMzk5N0RDMzAxQTc5NEM5RkMiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6ODRBQjNDODdENDhCMTFFMzk5N0RDMzAxQTc5NEM5RkMiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4NEFCM0M4NEQ0OEIxMUUzOTk3REMzMDFBNzk0QzlGQyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4NEFCM0M4NUQ0OEIxMUUzOTk3REMzMDFBNzk0QzlGQyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PrOLMN8AAACUSURBVHja7JWhDoAgEEBPRrERbVYCX+If8Z8Eqo2IyYi7wOYYTncYuI3XD94bDKaUErSwWZtWY0izu3NAnc3zEhpBAVyIQvAeWuKPEEAAQ7I8IjjLswso5RHZq2iNUp7lFRoBI2AEQN+vEL5A+EM/MSvV7wm8ySNnjH0GfJGvRQhu8mWE/GPz2g/5hUVrkvw94hJgALO2Vr1s43dIAAAAAElFTkSuQmCC", "tileWidth": 16, "tileHeight": 16, "tileSeparationX": 0, "tileSeparationY": 0, "tileMarginX": 0, "tileMarginY": 0} + ] +} \ No newline at end of file diff --git a/projects/flixel/rpg-tutorial/assets/images/tiles.png b/projects/flixel/rpg-tutorial/assets/images/tiles.png new file mode 100644 index 00000000..f16b622f Binary files /dev/null and b/projects/flixel/rpg-tutorial/assets/images/tiles.png differ diff --git a/projects/flixel/rpg-tutorial/source/Main.hx b/projects/flixel/rpg-tutorial/source/Main.hx index bede4bec..b91269b6 100644 --- a/projects/flixel/rpg-tutorial/source/Main.hx +++ b/projects/flixel/rpg-tutorial/source/Main.hx @@ -1,7 +1,4 @@ package; -import flixel.FlxGame; -import openfl.display.Sprite; - @:build(kiss.Kiss.build("source/Main.kiss")) class Main extends Sprite {} diff --git a/projects/flixel/rpg-tutorial/source/MenuState.hx b/projects/flixel/rpg-tutorial/source/MenuState.hx index 24e9bae6..448a61d0 100644 --- a/projects/flixel/rpg-tutorial/source/MenuState.hx +++ b/projects/flixel/rpg-tutorial/source/MenuState.hx @@ -1,8 +1,4 @@ package; -import flixel.FlxState; -import flixel.ui.FlxButton; -import flixel.FlxG; - @:build(kiss.Kiss.build("source/MenuState.kiss")) class MenuState extends FlxState {} diff --git a/projects/flixel/rpg-tutorial/source/PlayState.hx b/projects/flixel/rpg-tutorial/source/PlayState.hx index 17e555f1..5ef76e12 100644 --- a/projects/flixel/rpg-tutorial/source/PlayState.hx +++ b/projects/flixel/rpg-tutorial/source/PlayState.hx @@ -1,6 +1,4 @@ package; -import flixel.FlxState; - @:build(kiss.Kiss.build("source/PlayState.kiss")) class PlayState extends FlxState {} diff --git a/projects/flixel/rpg-tutorial/source/PlayState.kiss b/projects/flixel/rpg-tutorial/source/PlayState.kiss index 3baab729..e46378e0 100644 --- a/projects/flixel/rpg-tutorial/source/PlayState.kiss +++ b/projects/flixel/rpg-tutorial/source/PlayState.kiss @@ -1,11 +1,25 @@ (defprop &mut :Player player null) +(defprop &mut :FlxOgmo3Loader map null) +(defprop &mut :FlxTilemap walls null) +// TODO make a &void meta (defmethod &override create [] - (set player (new Player 20 20)) - (add player) + (set map (new FlxOgmo3Loader AssetPaths.turnBasedRPG__ogmo AssetPaths.room_001__json)) + (set walls (map.loadTilemap AssetPaths.tiles__png "walls")) + (walls.follow) + (walls.setTileProperties 1 FlxObject.NONE) + (walls.setTileProperties 2 FlxObject.ANY) + (add walls) + (map.loadEntities placeEntities "entities") (super.create) (return)) +(defmethod placeEntities [:EntityData entity] + (when (= "player" entity.name) + (set player (new Player entity.x entity.y)) + (add player))) + (defmethod &override update [:Float elapsed] (super.update elapsed) + (FlxG.collide player walls) (return)) \ No newline at end of file diff --git a/projects/flixel/rpg-tutorial/source/Player.hx b/projects/flixel/rpg-tutorial/source/Player.hx index 5ccb4120..bdf7e3a6 100644 --- a/projects/flixel/rpg-tutorial/source/Player.hx +++ b/projects/flixel/rpg-tutorial/source/Player.hx @@ -1,12 +1,4 @@ package; -import flixel.FlxG; -import flixel.FlxSprite; -import flixel.util.FlxColor; -import flixel.input.keyboard.FlxKey; -import flixel.math.FlxPoint; -import flixel.FlxObject; -import kiss.Prelude; - @:build(kiss.Kiss.build("source/Player.kiss")) class Player extends FlxSprite {} diff --git a/projects/flixel/rpg-tutorial/source/Player.kiss b/projects/flixel/rpg-tutorial/source/Player.kiss index cdb186a8..4ba04055 100644 --- a/projects/flixel/rpg-tutorial/source/Player.kiss +++ b/projects/flixel/rpg-tutorial/source/Player.kiss @@ -9,6 +9,8 @@ (animation.add "u" [6 7 6 8] 6 false) (animation.add "d" [0 1 0 2] 6 false) (set drag.x (set drag.y 1600)) + (setSize 8 8) + (offset.set 4 4) (return)) (defmethod updateMovement [] diff --git a/projects/flixel/rpg-tutorial/source/import.hx b/projects/flixel/rpg-tutorial/source/import.hx new file mode 100644 index 00000000..08178d26 --- /dev/null +++ b/projects/flixel/rpg-tutorial/source/import.hx @@ -0,0 +1,12 @@ +import flixel.FlxGame; +import openfl.display.Sprite; +import flixel.FlxState; +import flixel.ui.FlxButton; +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.util.FlxColor; +import flixel.input.keyboard.FlxKey; +import flixel.math.FlxPoint; +import flixel.FlxObject; +import flixel.addons.editors.ogmo.FlxOgmo3Loader; +import kiss.Prelude;