RPG tile map
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
<haxelib name="kiss" />
|
||||
|
||||
<!--In case you want to use the addons package-->
|
||||
<!--<haxelib name="flixel-addons" />-->
|
||||
<haxelib name="flixel-addons" />
|
||||
|
||||
<!--In case you want to use the ui package-->
|
||||
<!--<haxelib name="flixel-ui" />-->
|
||||
|
36
projects/flixel/rpg-tutorial/assets/data/room-001.json
Normal file
36
projects/flixel/rpg-tutorial/assets/data/room-001.json
Normal file
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
79
projects/flixel/rpg-tutorial/assets/data/turnBasedRPG.ogmo
Normal file
79
projects/flixel/rpg-tutorial/assets/data/turnBasedRPG.ogmo
Normal file
@@ -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+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjp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rpg-tutorial/assets/images/tiles.png
Normal file
BIN
projects/flixel/rpg-tutorial/assets/images/tiles.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@@ -1,7 +1,4 @@
|
||||
package;
|
||||
|
||||
import flixel.FlxGame;
|
||||
import openfl.display.Sprite;
|
||||
|
||||
@:build(kiss.Kiss.build("source/Main.kiss"))
|
||||
class Main extends Sprite {}
|
||||
|
@@ -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 {}
|
||||
|
@@ -1,6 +1,4 @@
|
||||
package;
|
||||
|
||||
import flixel.FlxState;
|
||||
|
||||
@:build(kiss.Kiss.build("source/PlayState.kiss"))
|
||||
class PlayState extends FlxState {}
|
||||
|
@@ -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))
|
@@ -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 {}
|
||||
|
@@ -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 []
|
||||
|
12
projects/flixel/rpg-tutorial/source/import.hx
Normal file
12
projects/flixel/rpg-tutorial/source/import.hx
Normal file
@@ -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;
|
Reference in New Issue
Block a user