Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nayata committed Feb 4, 2024
1 parent 25c00a9 commit 032dd06
Show file tree
Hide file tree
Showing 77 changed files with 7,615 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "HashLink",
"request": "launch",
"type": "hl",
"cwd": "${workspaceFolder}",
"preLaunchTask": {
"type": "haxe",
"args": "active configuration"
}
}
]
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Vladimir Nayata
Copyright (c) 2024 Volodymyr Nayata

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# editor
# Heaps Editor
Minimal 2D editor written in Haxe Heaps

![Editor](/editor.png "Heaps Editor")

**Heaps Editor** is an open-source 2D editor designed for quick and easy level creation, especially suited for non-grid-based physics. The editor also supports images, texture atlases, grid layers for pathfinding or grid-based collisions and the creation of pathways for objects.


## Minimal manual
Check out manual on [nayata.github.io/editor](https://nayata.github.io/editor/).

## Examples
In the **examples** folder you can find various examples of how to parse and use scenes created with the editor.
7 changes: 7 additions & 0 deletions compile.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-cp src
-lib heaps
-lib hldx
-hl main.hl
-main Editor
-D windowSize=1600x900
-D windowFixed=0
Binary file added editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions examples/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "HashLink",
"request": "launch",
"type": "hl",
"cwd": "${workspaceFolder}",
"preLaunchTask": {
"type": "haxe",
"args": "active configuration"
}
}
]
}
34 changes: 34 additions & 0 deletions examples/DebugRender.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class DebugRender extends hxd.App {
var label:h2d.Text;


static function main() {
new DebugRender();
}


override function init() {
engine.backgroundColor = 0x2e2b44;
s2d.scaleMode = LetterBox(960, 600, false, Center, Center);
hxd.Res.initLocal();

var project = new Project();
project.load("Platformer.json");

var obj = project.renderDebugLayer("Collisions");
s2d.addChild(obj);

obj = project.renderDebugLayer("Entities");
s2d.addChild(obj);

label = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
label.x = label.y = 10;
}


override function update(dt:Float) {
super.update(dt);

label.text = "Draw calls: " + engine.drawCalls;
}
}
61 changes: 61 additions & 0 deletions examples/GridExample.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
class GridExample extends hxd.App {
var grid:Map<Int, Bool> = new Map();
var gridWidth:Int;
var gridSize:Int;

var label:h2d.Text;

inline function setGridCell(cx, cy, value) grid.set(gridCell(cx, cy), value);
inline function gridCell(cx, cy) return cx + cy*gridWidth;
inline function snap(value:Float, step:Int = 10) return Math.round(value / step);


static function main() {
new GridExample();
}


override function init() {
engine.backgroundColor = 0x2e2b44;
s2d.scaleMode = LetterBox(960, 600, false, Center, Center);
hxd.Res.initLocal();


var project = new Project();
var scene = project.load("grid.json");

var obj = project.debugRender();
s2d.addChild(obj);

var cWid:Int = Math.round(scene.width/scene.gridSize);
var cHei:Int = Math.round(scene.height/scene.gridSize);

gridWidth = cWid;
gridSize = scene.gridSize;

for (cy in 0...cHei) {
for(cx in 0...cWid) {
setGridCell(cx,cy, true);
}
}

var layer = project.defaultLayer();
for (cell in layer.grid) {
setGridCell(cell.cellX, cell.cellY, false);
}

label = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
label.textColor = 0xffffff;
label.x = label.y = 64;
}


override function update(dt:Float) {
super.update(dt);

var cx = snap(s2d.mouseX-gridSize*0.5, gridSize);
var cy = snap(s2d.mouseY-gridSize*0.5, gridSize);

label.text = "cell x: " + cx + "\ncell y: " + cy + "\nwalkable: " + grid.get(gridCell(cx, cy));
}
}
33 changes: 33 additions & 0 deletions examples/ImageRender.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class ImageRender extends hxd.App {
var title:h2d.Object;
var button:h2d.Object;
var bounce:Float = 0;


static function main() {
new ImageRender();
}


override function init() {
engine.backgroundColor = 0x2e2b44;
s2d.scaleMode = LetterBox(960, 600, false, Center, Center);
hxd.Res.initLocal();

var project = new Project();
project.load("UI.json");

var obj = project.render();
s2d.addChild(obj);

title = obj.getObjectByName("Title");
button = obj.getObjectByName("Button");
}


override function update(dt:Float) {
super.update(dt);

title.y += Math.sin(bounce += 0.075) * 0.25;
}
}
Loading

0 comments on commit 032dd06

Please sign in to comment.