Skip to content

Commit ba5a231

Browse files
committed
Cleanup and documentation
1 parent 8c346f1 commit ba5a231

File tree

16 files changed

+120
-40
lines changed

16 files changed

+120
-40
lines changed

zero/ext/flx/FlxTilemapExt.hx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,41 @@ package zero.ext.flx;
22

33
import flixel.tile.FlxTilemap;
44
import flixel.math.FlxPoint;
5-
import zero.util.IntPoint;
6-
import zero.util.Vector;
75

86
using Math;
9-
using zero.ext.FloatExt;
10-
using zero.ext.flx.FlxPointExt;
117
using zero.ext.flx.FlxTilemapExt;
128

139
class FlxTilemapExt
1410
{
1511

12+
/**
13+
* Returns the tile index at a given point
14+
* @param t tilemap
15+
* @param p point
16+
* @return Int
17+
*/
1618
public static inline function get_index_from_point(t:FlxTilemap, p:FlxPoint):Int return t.getTile((p.x / t.get_tile_width()).floor(), (p.y / t.get_tile_height()).floor());
19+
20+
/**
21+
* Returns a tile's allowCollisions value at a given point
22+
* @param t tilemap
23+
* @param p point
24+
* @return Int
25+
*/
1726
public static inline function get_collisions_from_point(t:FlxTilemap, p:FlxPoint):Int return t.getTileCollisions(t.get_index_from_point(p));
18-
public static inline function get_tile_width(t:FlxTilemap) return t.width / t.widthInTiles;
19-
public static inline function get_tile_height(t:FlxTilemap) return t.height / t.heightInTiles;
27+
28+
/**
29+
* Returns the tile width of a tilemap
30+
* @param t tilemap
31+
* @return return
32+
*/
33+
public static inline function get_tile_width(t:FlxTilemap):Float return t.width / t.widthInTiles;
34+
35+
/**
36+
* Returns the tile height of a tilemap
37+
* @param t tilemap
38+
* @return return
39+
*/
40+
public static inline function get_tile_height(t:FlxTilemap):Float return t.height / t.heightInTiles;
2041

2142
}

zero/flxutil/ecs/components/CallbackAfterTimer.hx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,27 @@ class CallbackAfterTimer extends Component
88
var timer:Float = 0;
99
var callback: Void -> Void;
1010

11+
/**
12+
* Creates a timer object that executes a callback function when time has run out. Use reset() to start timer.
13+
* @param callback callback function
14+
* @param name component name
15+
*/
1116
public function new(callback:Void -> Void, name:String = 'callback_after_timer')
1217
{
1318
super(name);
1419
this.callback = callback;
1520
}
1621

22+
/**
23+
* Start the timer with a given time
24+
* @param time
25+
*/
1726
public function reset(time:Float)
1827
{
1928
timer = time;
2029
}
2130

31+
@:dox(hide)
2232
override public function update(dt:Float)
2333
{
2434
if (timer <= 0) return;

zero/flxutil/ecs/components/KillAfterAnimation.hx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import zero.flxutil.ecs.Component;
55
class KillAfterAnimation extends Component
66
{
77

8-
public function new()
9-
{
10-
super('kill_after_animation');
11-
}
8+
/**
9+
* Kills an entity after it's animation is finished
10+
* @return super('kill_after_animation')
11+
*/
12+
public function new() super('kill_after_animation');
1213

13-
override public function update(dt:Float)
14-
{
15-
if (entity.animation.finished) entity.kill();
16-
}
14+
@:dox(hide)
15+
override public function update(dt:Float) if (entity.animation.finished) entity.kill();
1716

1817
}

zero/flxutil/ecs/components/KillAfterTimer.hx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package zero.flxutil.ecs.components;
33
class KillAfterTimer extends CallbackAfterTimer
44
{
55

6-
public function new()
7-
{
8-
super(function() { entity.kill(); }, 'kill_after_timer');
9-
}
6+
/**
7+
* Kills an entity after a timer. Use reset() to start timer.
8+
* @return super(function()
9+
*/
10+
public function new() super(function() { entity.kill(); }, 'kill_after_timer');
1011

1112
}

zero/flxutil/ecs/components/PlatformerWalker.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class PlatformerWalker extends Component
3333
entity.maxVelocity.x = walk_speed;
3434
drag.x = drag_amt;
3535
}
36-
36+
37+
@:dox(hide)
3738
override public function update(dt:Float)
3839
{
3940
acceleration.x = 0;

zero/flxutil/ecs/components/TopDownWalker.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class TopDownWalker extends Component
3535
entity.maxVelocity.set(walk_speed, walk_speed);
3636
drag.set(drag_amt, drag_amt);
3737
}
38-
38+
39+
@:dox(hide)
3940
override public function update(dt:Float)
4041
{
4142
acceleration.set();

zero/flxutil/formats/BitsyFont.hx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package zero.flxutil.formats;
22

3-
import haxe.Json;
43
import openfl.Assets;
54
import flixel.math.FlxPoint;
65
import flixel.system.FlxAssets;

zero/flxutil/formats/OgmoLoader.hx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ using zero.ext.StringExt;
1010
class OgmoLoader extends FlxOgmoLoader
1111
{
1212

13+
/**
14+
* Returns 2D array of tile ids of a given tile layer
15+
* @param tile_layer
16+
* @return
17+
*/
1318
public function get_tilemap_array(tile_layer:String = 'tiles'):Array<Array<Int>> return _fastXml.node.resolve(tile_layer).innerData.csv_to_2d_int_array();
19+
20+
/**
21+
* Returns CSV of tile ids of a given tile layer
22+
* @param tile_layer
23+
* @return
24+
*/
1425
public function get_tilemap_csv(tile_layer:String = 'tiles'):String return _fastXml.node.resolve(tile_layer).innerData;
1526

1627
}

zero/flxutil/formats/ZFont.hx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package zero.flxutil.formats;
22

33
import flixel.math.FlxPoint;
4-
import flixel.system.FlxAssets;
54
import flixel.text.FlxText.FlxTextAlign;
65
import haxe.Json;
76
import openfl.Assets;

zero/flxutil/shaders/ColorMix.hx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class ColorMix extends FlxShader
1919
}'
2020
)
2121

22+
/**
23+
* Mixes a sprite with a given color - use color and uMix to update the color and mix amount.
24+
* @param color
25+
*/
2226
public function new(color:Int = 0xFFFFFFFF)
2327
{
2428
super();

0 commit comments

Comments
 (0)