diff --git a/zero/ext/flx/FlxTilemapExt.hx b/zero/ext/flx/FlxTilemapExt.hx index 0122be2..89e4d2c 100644 --- a/zero/ext/flx/FlxTilemapExt.hx +++ b/zero/ext/flx/FlxTilemapExt.hx @@ -2,20 +2,41 @@ package zero.ext.flx; import flixel.tile.FlxTilemap; import flixel.math.FlxPoint; -import zero.util.IntPoint; -import zero.util.Vector; using Math; -using zero.ext.FloatExt; -using zero.ext.flx.FlxPointExt; using zero.ext.flx.FlxTilemapExt; class FlxTilemapExt { + /** + * Returns the tile index at a given point + * @param t tilemap + * @param p point + * @return Int + */ 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()); + + /** + * Returns a tile's allowCollisions value at a given point + * @param t tilemap + * @param p point + * @return Int + */ public static inline function get_collisions_from_point(t:FlxTilemap, p:FlxPoint):Int return t.getTileCollisions(t.get_index_from_point(p)); - public static inline function get_tile_width(t:FlxTilemap) return t.width / t.widthInTiles; - public static inline function get_tile_height(t:FlxTilemap) return t.height / t.heightInTiles; + + /** + * Returns the tile width of a tilemap + * @param t tilemap + * @return return + */ + public static inline function get_tile_width(t:FlxTilemap):Float return t.width / t.widthInTiles; + + /** + * Returns the tile height of a tilemap + * @param t tilemap + * @return return + */ + public static inline function get_tile_height(t:FlxTilemap):Float return t.height / t.heightInTiles; } \ No newline at end of file diff --git a/zero/flxutil/ecs/components/CallbackAfterTimer.hx b/zero/flxutil/ecs/components/CallbackAfterTimer.hx index 9a3b1ff..2c06200 100644 --- a/zero/flxutil/ecs/components/CallbackAfterTimer.hx +++ b/zero/flxutil/ecs/components/CallbackAfterTimer.hx @@ -8,17 +8,27 @@ class CallbackAfterTimer extends Component var timer:Float = 0; var callback: Void -> Void; + /** + * Creates a timer object that executes a callback function when time has run out. Use reset() to start timer. + * @param callback callback function + * @param name component name + */ public function new(callback:Void -> Void, name:String = 'callback_after_timer') { super(name); this.callback = callback; } + /** + * Start the timer with a given time + * @param time + */ public function reset(time:Float) { timer = time; } + @:dox(hide) override public function update(dt:Float) { if (timer <= 0) return; diff --git a/zero/flxutil/ecs/components/KillAfterAnimation.hx b/zero/flxutil/ecs/components/KillAfterAnimation.hx index 8b7214f..b72f722 100644 --- a/zero/flxutil/ecs/components/KillAfterAnimation.hx +++ b/zero/flxutil/ecs/components/KillAfterAnimation.hx @@ -5,14 +5,13 @@ import zero.flxutil.ecs.Component; class KillAfterAnimation extends Component { - public function new() - { - super('kill_after_animation'); - } + /** + * Kills an entity after it's animation is finished + * @return super('kill_after_animation') + */ + public function new() super('kill_after_animation'); - override public function update(dt:Float) - { - if (entity.animation.finished) entity.kill(); - } + @:dox(hide) + override public function update(dt:Float) if (entity.animation.finished) entity.kill(); } \ No newline at end of file diff --git a/zero/flxutil/ecs/components/KillAfterTimer.hx b/zero/flxutil/ecs/components/KillAfterTimer.hx index e7cbc97..622a3f3 100644 --- a/zero/flxutil/ecs/components/KillAfterTimer.hx +++ b/zero/flxutil/ecs/components/KillAfterTimer.hx @@ -3,9 +3,10 @@ package zero.flxutil.ecs.components; class KillAfterTimer extends CallbackAfterTimer { - public function new() - { - super(function() { entity.kill(); }, 'kill_after_timer'); - } + /** + * Kills an entity after a timer. Use reset() to start timer. + * @return super(function() + */ + public function new() super(function() { entity.kill(); }, 'kill_after_timer'); } \ No newline at end of file diff --git a/zero/flxutil/ecs/components/PlatformerWalker.hx b/zero/flxutil/ecs/components/PlatformerWalker.hx index 06813d4..701b8b4 100644 --- a/zero/flxutil/ecs/components/PlatformerWalker.hx +++ b/zero/flxutil/ecs/components/PlatformerWalker.hx @@ -33,7 +33,8 @@ class PlatformerWalker extends Component entity.maxVelocity.x = walk_speed; drag.x = drag_amt; } - + + @:dox(hide) override public function update(dt:Float) { acceleration.x = 0; diff --git a/zero/flxutil/ecs/components/TopDownWalker.hx b/zero/flxutil/ecs/components/TopDownWalker.hx index ca95075..a4e443e 100644 --- a/zero/flxutil/ecs/components/TopDownWalker.hx +++ b/zero/flxutil/ecs/components/TopDownWalker.hx @@ -35,7 +35,8 @@ class TopDownWalker extends Component entity.maxVelocity.set(walk_speed, walk_speed); drag.set(drag_amt, drag_amt); } - + + @:dox(hide) override public function update(dt:Float) { acceleration.set(); diff --git a/zero/flxutil/formats/BitsyFont.hx b/zero/flxutil/formats/BitsyFont.hx index 0a19589..376f64d 100644 --- a/zero/flxutil/formats/BitsyFont.hx +++ b/zero/flxutil/formats/BitsyFont.hx @@ -1,6 +1,5 @@ package zero.flxutil.formats; -import haxe.Json; import openfl.Assets; import flixel.math.FlxPoint; import flixel.system.FlxAssets; diff --git a/zero/flxutil/formats/OgmoLoader.hx b/zero/flxutil/formats/OgmoLoader.hx index 5f4e4b7..685033d 100644 --- a/zero/flxutil/formats/OgmoLoader.hx +++ b/zero/flxutil/formats/OgmoLoader.hx @@ -10,7 +10,18 @@ using zero.ext.StringExt; class OgmoLoader extends FlxOgmoLoader { + /** + * Returns 2D array of tile ids of a given tile layer + * @param tile_layer + * @return + */ public function get_tilemap_array(tile_layer:String = 'tiles'):Array> return _fastXml.node.resolve(tile_layer).innerData.csv_to_2d_int_array(); + + /** + * Returns CSV of tile ids of a given tile layer + * @param tile_layer + * @return + */ public function get_tilemap_csv(tile_layer:String = 'tiles'):String return _fastXml.node.resolve(tile_layer).innerData; } \ No newline at end of file diff --git a/zero/flxutil/formats/ZFont.hx b/zero/flxutil/formats/ZFont.hx index add112d..f642906 100644 --- a/zero/flxutil/formats/ZFont.hx +++ b/zero/flxutil/formats/ZFont.hx @@ -1,7 +1,6 @@ package zero.flxutil.formats; import flixel.math.FlxPoint; -import flixel.system.FlxAssets; import flixel.text.FlxText.FlxTextAlign; import haxe.Json; import openfl.Assets; diff --git a/zero/flxutil/shaders/ColorMix.hx b/zero/flxutil/shaders/ColorMix.hx index 13e7b04..71d1082 100644 --- a/zero/flxutil/shaders/ColorMix.hx +++ b/zero/flxutil/shaders/ColorMix.hx @@ -19,6 +19,10 @@ class ColorMix extends FlxShader }' ) + /** + * Mixes a sprite with a given color - use color and uMix to update the color and mix amount. + * @param color + */ public function new(color:Int = 0xFFFFFFFF) { super(); diff --git a/zero/flxutil/shaders/FourColor.hx b/zero/flxutil/shaders/FourColor.hx index 9754834..57997a8 100644 --- a/zero/flxutil/shaders/FourColor.hx +++ b/zero/flxutil/shaders/FourColor.hx @@ -29,12 +29,20 @@ class FourColor extends FlxShader }' ) + /** + * Creates a 4 color palette shader - useful for gameboy-like games! + * @param palette + */ public function new(palette:Array) { super(); set_palette(palette); } + /** + * Sets the palette using an array of four colors (Ints), colors should be ordered from dark to light + * @param palette + */ public function set_palette(palette:Array) { if (palette.length != 4) @@ -48,6 +56,11 @@ class FourColor extends FlxShader set_color(WHITE, palette[3]); } + /** + * Set a specific palette index to the given color + * @param index + * @param color + */ public function set_color(index:PaletteIndex, color:Int) { switch (index) { diff --git a/zero/flxutil/sprites/Grid.hx b/zero/flxutil/sprites/Grid.hx index abe0c9a..782a949 100644 --- a/zero/flxutil/sprites/Grid.hx +++ b/zero/flxutil/sprites/Grid.hx @@ -9,6 +9,10 @@ using Math; class Grid extends FlxSprite { + /** + * Creates a sprite and draws a grid on it using given options. + * @param options + */ public function new(options:GridOptions) { super(options.x, options.y); diff --git a/zero/flxutil/sprites/Stack.hx b/zero/flxutil/sprites/Stack.hx index 925ad0c..8924f94 100644 --- a/zero/flxutil/sprites/Stack.hx +++ b/zero/flxutil/sprites/Stack.hx @@ -21,6 +21,10 @@ class Stack extends FlxSprite public var z_offset:Float; + /** + * Creates a stack - a set of sprites that fake 3D by layering and offsetting sprites. Use this.add() to add to state! + * @param options + */ public function new(options:StackOptions) { super(options.position.x, options.position.y); @@ -61,8 +65,14 @@ class Stack extends FlxSprite slice_post_init(slice); } + /** + * Adds stack to the given state. + * @param state + * @return state.add(group) + */ public function add(state:FlxState) state.add(group); + @:dox(hide) override public function update(dt:Float) { super.update(dt); @@ -81,6 +91,10 @@ class Stack extends FlxSprite slice.angle = angle; } + /** + * Combines this stack with a given stack + * @param stack + */ public function combine(stack:Stack) { StackManager.i.base_group.remove(stack); @@ -90,6 +104,7 @@ class Stack extends FlxSprite } +@:dox(hide) class StackGroup extends FlxTypedGroup { @@ -111,6 +126,7 @@ class StackGroup extends FlxTypedGroup } +@:dox(hide) class StackManager { diff --git a/zero/flxutil/ui/BitmapText.hx b/zero/flxutil/ui/BitmapText.hx index ce21a8c..343ef16 100644 --- a/zero/flxutil/ui/BitmapText.hx +++ b/zero/flxutil/ui/BitmapText.hx @@ -1,18 +1,13 @@ package zero.flxutil.ui; -import haxe.Json; -import openfl.Assets; import flixel.graphics.frames.FlxBitmapFont; import flixel.math.FlxPoint; import flixel.system.FlxAssets; import flixel.text.FlxBitmapText; import flixel.text.FlxText.FlxTextAlign; import flixel.FlxG; -import openfl.display.BitmapData; -import haxe.Utf8; using Math; -using StringTools; /** * A wrapper for FlxBitmapText that makes it easy to use a monospaced bitmap font image diff --git a/zero/flxutil/ui/NineSliceBox.hx b/zero/flxutil/ui/NineSliceBox.hx index 9efd5b8..1392d58 100644 --- a/zero/flxutil/ui/NineSliceBox.hx +++ b/zero/flxutil/ui/NineSliceBox.hx @@ -1,17 +1,10 @@ package zero.flxutil.ui; -import flixel.addons.ui.FlxSlider; -import flixel.math.FlxRect; import flixel.system.FlxAssets; import flixel.FlxSprite; import flixel.math.FlxPoint; import openfl.display.BitmapData; -import zero.flxutil.util.GameLog.*; -import zero.util.IntPoint; -using flixel.util.FlxSpriteUtil; -using zero.ext.FloatExt; -using zero.ext.flx.FlxSpriteExt; using Math; class NineSliceBox extends FlxSprite diff --git a/zero/flxutil/ui/RichText.hx b/zero/flxutil/ui/RichText.hx index 1de210c..f512e95 100644 --- a/zero/flxutil/ui/RichText.hx +++ b/zero/flxutil/ui/RichText.hx @@ -1,7 +1,6 @@ package zero.flxutil.ui; import flixel.FlxG; -import flixel.FlxSprite; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.system.FlxAssets; import zero.util.IntPoint; @@ -31,6 +30,10 @@ class RichText extends FlxTypedGroup var override_type_effect:Bool = false; var wiggle_timer:Float = 0; + /** + * Creates a rich text object for animated text. + * @param options + */ public function new(options:RichTextOptions) { super(); @@ -44,7 +47,7 @@ class RichText extends FlxTypedGroup FlxG.watch.add(this, 'wiggle_timer', 'WT:'); } - public function create_defaults(options:RichTextOptions) + function create_defaults(options:RichTextOptions) { if (options.position == null) options.position = FlxPoint.get(0, 0); @@ -84,10 +87,14 @@ class RichText extends FlxTypedGroup return options; } - public function get_anim_options():RichTextAnimOptions return anim_options; - public function get_current_color():Int return current_color; - public function get_wiggle_timer():Float return wiggle_timer; + @:dox(hide) public function get_anim_options():RichTextAnimOptions return anim_options; + @:dox(hide) public function get_current_color():Int return current_color; + @:dox(hide) public function get_wiggle_timer():Float return wiggle_timer; + /** + * Enqueues text to be parsed and displayed + * @param s + */ public function queue(s:String) { if (s.length == 0) return; @@ -96,7 +103,7 @@ class RichText extends FlxTypedGroup state = READY; } - public function parse_input(s:String):Array + function parse_input(s:String):Array { var out = []; var temp_s = parse_new_line_chars(remove_unavailable_characters(s)); @@ -172,6 +179,10 @@ class RichText extends FlxTypedGroup return lines.join(' '); } + /** + * Invokes queued text to be displayed, returns true if there is still text enqueued. Call during text output to interrupt/show all text. + * @return Bool + */ public function invoke():Bool { switch (state) @@ -197,6 +208,7 @@ class RichText extends FlxTypedGroup } } + @:dox(hide) override public function update(dt) { wiggle_timer = (wiggle_timer + dt) % 1; @@ -312,6 +324,7 @@ class RichText extends FlxTypedGroup } +@:dox(hide) class RichTextChar extends Particle {