Skip to content

Commit

Permalink
Style cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bendmorris committed Oct 8, 2016
1 parent 281c013 commit e8af4a5
Show file tree
Hide file tree
Showing 69 changed files with 582 additions and 713 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ unit:
@echo "Running unit tests"
@cd tests && haxe compile.hxml && neko unit.n

checkstyle:
haxelib run checkstyle -c checkstyle.json -s com

unit-travis:
# copy ndll to base path
@cp $(LIME_PATH)/`cat $(LIME_PATH)/.current | sed -e 's/\./,/g'`/legacy/ndll/Linux64/* .
Expand Down
4 changes: 3 additions & 1 deletion checkstyle.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"type": "ModifierOrder",
"props": {
"modifiers": [
"MACRO",
"OVERRIDE",
"PUBLIC_PRIVATE",
"STATIC",
"MACRO",
"INLINE",
"DYNAMIC"
]
Expand Down Expand Up @@ -157,6 +157,7 @@
{
"type": "EmptyPackage",
"props": {
"severity": "INFO",
"enforceEmptyPackage": true
}
},
Expand All @@ -169,6 +170,7 @@
{
"type": "UnusedImport",
"props": {
"severity": "INFO",
"ignoreModules": [
"haxe.macro.Expr"
]
Expand Down
28 changes: 12 additions & 16 deletions com/haxepunk/Engine.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.haxepunk;

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageDisplayState;
Expand All @@ -10,12 +8,9 @@ import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.Lib;
import haxe.EnumFlags;
import haxe.Timer;
import com.haxepunk.graphics.atlas.AtlasData;
import com.haxepunk.utils.Draw;
import com.haxepunk.utils.Input;
import com.haxepunk.Tweener;

/**
* Main game Sprite class, added to the Flash Stage.
Expand Down Expand Up @@ -103,17 +98,17 @@ class Engine extends Sprite
/**
* Override this, called after Engine has been added to the stage.
*/
public function init() { }
public function init() {}

/**
* Override this, called when game gains focus
*/
public function focusGained() { }
public function focusGained() {}

/**
* Override this, called when game loses focus
*/
public function focusLost() { }
public function focusLost() {}

/**
* Updates the game, updating the Scene and Entities.
Expand Down Expand Up @@ -185,24 +180,25 @@ class Engine extends Sprite
resize(); // call resize once to initialize the screen

// set resize event
HXP.stage.addEventListener(Event.RESIZE, function (e:Event) {
resize();
});
HXP.stage.addEventListener(Event.RESIZE, function (e:Event) resize());

HXP.stage.addEventListener(Event.ACTIVATE, function (e:Event) {
HXP.stage.addEventListener(Event.ACTIVATE, function (e:Event)
{
HXP.focused = true;
focusGained();
_scene.focusGained();
});

HXP.stage.addEventListener(Event.DEACTIVATE, function (e:Event) {
HXP.stage.addEventListener(Event.DEACTIVATE, function (e:Event)
{
HXP.focused = false;
focusLost();
_scene.focusLost();
});

#if (!(flash || html5) && openfl_legacy)
flash.display.Stage.shouldRotateInterface = function(orientation:Int):Bool {
flash.display.Stage.shouldRotateInterface = function(orientation:Int):Bool
{
if (HXP.indexOf(HXP.orientations, orientation) == -1) return false;
var tmp = HXP.height;
HXP.height = HXP.width;
Expand All @@ -227,7 +223,7 @@ class Engine extends Sprite
}

/** @private Event handler for stage entry. */
private function onStage(e:Event = null)
private function onStage(?e:Event)
{
// remove event listener
#if flash
Expand Down Expand Up @@ -417,7 +413,7 @@ class Engine extends Sprite
* to switch, but won't actually do so until the end of the current frame.
*/
public var scene(get, set):Scene;
private inline function get_scene():Scene { return _scene; }
private inline function get_scene():Scene return _scene;
private function set_scene(value:Scene):Scene
{
if (_scene == value) return value;
Expand Down
50 changes: 24 additions & 26 deletions com/haxepunk/Entity.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package com.haxepunk;

import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;
import com.haxepunk.graphics.Image;
import com.haxepunk.graphics.Graphiclist;
import com.haxepunk.ds.Either;

Expand All @@ -15,7 +13,7 @@ import com.haxepunk.ds.Either;
abstract SolidType(Either<String, Array<String>>)
{
@:dox(hide) public inline function new( e:Either<String, Array<String>> ) this = e;
@:dox(hide) public var type(get,never):Either<String, Array<String>>;
@:dox(hide) public var type(get, never):Either<String, Array<String>>;
@:to inline function get_type() return this;
@:from static function fromLeft(v:String) return new SolidType(Left(v));
@:from static function fromRight(v:Array<String>) return new SolidType(Right(v));
Expand Down Expand Up @@ -107,7 +105,7 @@ class Entity extends Tweener
* @param graphic Graphic to assign to the Entity.
* @param mask Mask to assign to the Entity.
*/
public function new(x:Float = 0, y:Float = 0, graphic:Graphic = null, mask:Mask = null)
public function new(x:Float = 0, y:Float = 0, ?graphic:Graphic, ?mask:Mask)
{
super();
this.x = x;
Expand All @@ -134,17 +132,17 @@ class Entity extends Tweener
/**
* Override this, called when the Entity is added to a Scene.
*/
public function added():Void { }
public function added():Void {}

/**
* Override this, called when the Entity is removed from a Scene.
*/
public function removed():Void { }
public function removed():Void {}

/**
* Updates the Entity.
*/
override public function update():Void { }
override public function update():Void {}

/**
* Renders the Entity. If you override this for special behaviour,
Expand Down Expand Up @@ -449,7 +447,7 @@ class Entity extends Tweener
* The world object is deprecated, use scene instead.
*/
@:deprecated public var world(get, never):Scene;
private inline function get_world():Scene { return _scene; }
private inline function get_world():Scene return _scene;

/**
* The Scene object this Entity has been added to.
Expand All @@ -464,55 +462,55 @@ class Entity extends Tweener
* Half the Entity's width.
*/
public var halfWidth(get, null):Float;
private inline function get_halfWidth():Float { return width / 2; }
private inline function get_halfWidth():Float return width / 2;

/**
* Half the Entity's height.
*/
public var halfHeight(get, null):Float;
private inline function get_halfHeight():Float { return height / 2; }
private inline function get_halfHeight():Float return height / 2;

/**
* The center x position of the Entity's hitbox.
*/
public var centerX(get, null):Float;
private inline function get_centerX():Float { return x - originX + width / 2; }
private inline function get_centerX():Float return x - originX + width / 2;

/**
* The center y position of the Entity's hitbox.
*/
public var centerY(get, null):Float;
private inline function get_centerY():Float { return y - originY + height / 2; }
private inline function get_centerY():Float return y - originY + height / 2;

/**
* The leftmost position of the Entity's hitbox.
*/
public var left(get, null):Float;
private inline function get_left():Float { return x - originX; }
private inline function get_left():Float return x - originX;

/**
* The rightmost position of the Entity's hitbox.
*/
public var right(get, null):Float;
private inline function get_right():Float { return x - originX + width; }
private inline function get_right():Float return x - originX + width;

/**
* The topmost position of the Entity's hitbox.
*/
public var top(get, null):Float;
private inline function get_top():Float { return y - originY; }
private inline function get_top():Float return y - originY;

/**
* The bottommost position of the Entity's hitbox.
*/
public var bottom(get, null):Float;
private inline function get_bottom():Float { return y - originY + height; }
private inline function get_bottom():Float return y - originY + height;

/**
* The rendering layer of this Entity. Higher layers are rendered first.
*/
public var layer(get, set):Int;
private inline function get_layer():Int { return _layer; }
private inline function get_layer():Int return _layer;
private function set_layer(value:Int):Int
{
if (_layer == value) return _layer;
Expand All @@ -531,7 +529,7 @@ class Entity extends Tweener
* The collision type, used for collision checking.
*/
public var type(get, set):String;
private inline function get_type():String { return _type; }
private inline function get_type():String return _type;
private function set_type(value:String):String
{
if (_type == value) return _type;
Expand All @@ -551,7 +549,7 @@ class Entity extends Tweener
* not assigned, collision checks will use the Entity's hitbox by default.
*/
public var mask(get, set):Mask;
private inline function get_mask():Mask { return _mask; }
private inline function get_mask():Mask return _mask;
private function set_mask(value:Mask):Mask
{
if (_mask == value) return value;
Expand All @@ -565,7 +563,7 @@ class Entity extends Tweener
* Graphical component to render to the screen.
*/
public var graphic(get, set):Graphic;
private inline function get_graphic():Graphic { return _graphic; }
private inline function get_graphic():Graphic return _graphic;
private function set_graphic(value:Graphic):Graphic
{
if (_graphic == value) return value;
Expand All @@ -577,7 +575,7 @@ class Entity extends Tweener
* An optional name for the entity.
*/
public var name(get, set):String;
private inline function get_name():String { return _name; }
private inline function get_name():String return _name;
private function set_name(value:String):String
{
if (_name == value) return _name;
Expand Down Expand Up @@ -799,7 +797,7 @@ class Entity extends Tweener
* @param solidType An optional collision type to stop flush against upon collision.
* @param sweep If sweeping should be used (prevents fast-moving objects from going through solidType).
*/
public inline function moveTo(x:Float, y:Float, solidType:SolidType = null, sweep:Bool = false)
public inline function moveTo(x:Float, y:Float, ?solidType:SolidType, sweep:Bool = false)
{
moveBy(x - this.x, y - this.y, solidType, sweep);
}
Expand All @@ -812,7 +810,7 @@ class Entity extends Tweener
* @param solidType An optional collision type to stop flush against upon collision.
* @param sweep If sweeping should be used (prevents fast-moving objects from going through solidType).
*/
public inline function moveTowards(x:Float, y:Float, amount:Float, solidType:SolidType = null, sweep:Bool = false)
public inline function moveTowards(x:Float, y:Float, amount:Float, ?solidType:SolidType, sweep:Bool = false)
{
_point.x = x - this.x;
_point.y = y - this.y;
Expand All @@ -830,7 +828,7 @@ class Entity extends Tweener
* @param solidType An optional collision type to stop flush against upon collision.
* @param sweep If sweeping should be used (prevents fast-moving objects from going through solidType).
*/
public inline function moveAtAngle(angle:Float, amount:Float, solidType:SolidType = null, sweep:Bool = false):Void
public inline function moveAtAngle(angle:Float, amount:Float, ?solidType:SolidType, sweep:Bool = false):Void
{
angle *= HXP.RAD;
moveBy(Math.cos(angle) * amount, Math.sin(angle) * amount, solidType, sweep);
Expand Down Expand Up @@ -921,6 +919,6 @@ class Entity extends Tweener
private var _graphic:Graphic;
private var _point:Point;
private var _camera:Point;
static private var _EMPTY = new Entity();

static var _EMPTY:Entity = new Entity();
}
2 changes: 0 additions & 2 deletions com/haxepunk/EntityList.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.haxepunk;


/**
* A group of entities which can be added to or removed from the Scene and
* moved together. Also supports object pooling.
Expand All @@ -22,7 +21,6 @@ class EntityList<T:Entity> extends Entity
super();
}


/**
* Add an Entity to this EntityList and its Scene.
* @param entity The Entity to be added.
Expand Down
Loading

0 comments on commit e8af4a5

Please sign in to comment.