Skip to content

Commit

Permalink
Fix some indent inconsistencies
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
Gama11 committed Mar 21, 2017
1 parent 4eb3a79 commit b039056
Show file tree
Hide file tree
Showing 18 changed files with 307 additions and 305 deletions.
2 changes: 1 addition & 1 deletion Arcade/Breakout/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class PlayState extends FlxState
if (touch.pressed)
{
if (touch.x > 10 && touch.x < 270)
_bat.x = touch.x;
_bat.x = touch.x;
}
}
// Vertical long swipe up or down resets game state
Expand Down
2 changes: 1 addition & 1 deletion Arcade/Flappybalt/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class PlayState extends FlxState
override public function update(elapsed:Float):Void
{
if (FlxG.pixelPerfectOverlap(_player, _spikeBottom) || FlxG.pixelPerfectOverlap(_player, _spikeTop)
|| FlxG.pixelPerfectOverlap(_player, _paddleLeft) || FlxG.pixelPerfectOverlap(_player, _paddleRight))
|| FlxG.pixelPerfectOverlap(_player, _paddleLeft) || FlxG.pixelPerfectOverlap(_player, _paddleRight))
{
_player.kill();
}
Expand Down
14 changes: 8 additions & 6 deletions Arcade/FlxPongApi/source/MenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ class MenuState extends FlxState

private static inline function API_TEST_BUTTONS():Array<Array<String>>
{
return [["fetchUser", "authUser", "openSession", "pingSession"],
["closeSession", "fetchTrophy", "addTrophy", "fetchScore"],
["addScore", "getTables", "fetchData", "setData"],
["updateData", "removeData", "getAllKeys", "resetUser"],
["fetchTrophyImage", "fetchAvatarImage", "username", "usertoken"],
["isQuickPlay", "isEmbeddedFlash"]];
return [
["fetchUser", "authUser", "openSession", "pingSession"],
["closeSession", "fetchTrophy", "addTrophy", "fetchScore"],
["addScore", "getTables", "fetchData", "setData"],
["updateData", "removeData", "getAllKeys", "resetUser"],
["fetchTrophyImage", "fetchAvatarImage", "username", "usertoken"],
["isQuickPlay", "isEmbeddedFlash"]
];
}

override public function create():Void
Expand Down
28 changes: 14 additions & 14 deletions Features/FlxNapeTilemap/source/Constants.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import nape.phys.Material;

class Constants
{
public static inline var TILE_SIZE = 16;
public static var oneWayType:CbType;
public static var platformMaterial(default, null) = new Material(0.2, 0.8, 0.4, 1);
public static var playerMaterial(default, null) = new Material(0.5, 0.001, 0.005, 1);
public static inline var TILE_SIZE = 16;
public static var oneWayType:CbType;
public static var platformMaterial(default, null) = new Material(0.2, 0.8, 0.4, 1);
public static var playerMaterial(default, null) = new Material(0.5, 0.001, 0.005, 1);
}

class TileType
{
public static inline var AIR = 0;
public static inline var SPAWN = 6;
public static inline var FLAG = 7;
public static var EMPTY(default, null) = [0, 7];
public static var BLOCK(default, null) = [1, 6];
public static var SLOPE_NE(default, null) = [2];
public static var SLOPE_NW(default, null) = [3];
public static var SLOPE_SE(default, null) = [4];
public static var SLOPE_SW(default, null) = [5];
public static var ONE_WAY(default, null) = [8, 9, 10];
public static inline var AIR = 0;
public static inline var SPAWN = 6;
public static inline var FLAG = 7;
public static var EMPTY(default, null) = [0, 7];
public static var BLOCK(default, null) = [1, 6];
public static var SLOPE_NE(default, null) = [2];
public static var SLOPE_NW(default, null) = [3];
public static var SLOPE_SE(default, null) = [4];
public static var SLOPE_SW(default, null) = [5];
public static var ONE_WAY(default, null) = [8, 9, 10];
}
112 changes: 56 additions & 56 deletions Features/FlxNapeTilemap/source/gameobj/CustomNapeTilemap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,66 @@ using Lambda;

class CustomNapeTilemap extends FlxNapeTilemap
{
public var spawnPoints(default, null) = new Array<FlxPoint>();
public var spawnPoints(default, null) = new Array<FlxPoint>();

public function new(tiles:String, graphics:FlxTilemapGraphicAsset, tileSize:Int)
{
super();
loadMapFromCSV(tiles, graphics, tileSize, tileSize);
setupTileIndices(TileType.BLOCK);
public function new(tiles:String, graphics:FlxTilemapGraphicAsset, tileSize:Int)
{
super();
loadMapFromCSV(tiles, graphics, tileSize, tileSize);
setupTileIndices(TileType.BLOCK);

var vertices = new Array<Vec2>();
vertices.push(Vec2.get(16, 0));
vertices.push(Vec2.get(16, 16));
vertices.push(Vec2.get(0, 16));
placeCustomPolygon(TileType.SLOPE_SE, vertices);
vertices[0] = Vec2.get(0, 0);
placeCustomPolygon(TileType.SLOPE_SW, vertices);
vertices[1] = Vec2.get(16, 0);
placeCustomPolygon(TileType.SLOPE_NW, vertices);
vertices[2] = Vec2.get(16, 16);
placeCustomPolygon(TileType.SLOPE_NE, vertices);
var vertices = new Array<Vec2>();
vertices.push(Vec2.get(16, 0));
vertices.push(Vec2.get(16, 16));
vertices.push(Vec2.get(0, 16));
placeCustomPolygon(TileType.SLOPE_SE, vertices);
vertices[0] = Vec2.get(0, 0);
placeCustomPolygon(TileType.SLOPE_SW, vertices);
vertices[1] = Vec2.get(16, 0);
placeCustomPolygon(TileType.SLOPE_NW, vertices);
vertices[2] = Vec2.get(16, 16);
placeCustomPolygon(TileType.SLOPE_NE, vertices);

for (ty in 0...heightInTiles)
{
var prevOneWay = false;
var length:Int = 0;
var startX:Int = 0;
var startY:Int = 0;
for (ty in 0...heightInTiles)
{
var prevOneWay = false;
var length:Int = 0;
var startX:Int = 0;
var startY:Int = 0;

for (tx in 0...widthInTiles)
{
if (TileType.ONE_WAY.has(getTileByIndex(ty * widthInTiles + tx)))
{
if (!prevOneWay)
{
prevOneWay = true;
length = 0;
startX = tx;
startY = ty;
}
length++;
}
else if (prevOneWay)
{
prevOneWay = false;
var startPos = getTileCoordsByIndex(startY * widthInTiles + startX, false);
PhysUtil.setOneWayLong(this, startPos, length);
}
}
for (tx in 0...widthInTiles)
{
if (TileType.ONE_WAY.has(getTileByIndex(ty * widthInTiles + tx)))
{
if (!prevOneWay)
{
prevOneWay = true;
length = 0;
startX = tx;
startY = ty;
}
length++;
}
else if (prevOneWay)
{
prevOneWay = false;
var startPos = getTileCoordsByIndex(startY * widthInTiles + startX, false);
PhysUtil.setOneWayLong(this, startPos, length);
}
}

if (prevOneWay)
{
prevOneWay = false;
var startPos = getTileCoordsByIndex(startY * widthInTiles + startX, false);
PhysUtil.setOneWayLong(this, startPos, length);
}
}
if (prevOneWay)
{
prevOneWay = false;
var startPos = getTileCoordsByIndex(startY * widthInTiles + startX, false);
PhysUtil.setOneWayLong(this, startPos, length);
}
}

for (point in getTileCoords(TileType.SPAWN, false))
{
point.x += _scaledTileHeight * 0.5;
spawnPoints.push(point);
}
}
for (point in getTileCoords(TileType.SPAWN, false))
{
point.x += _scaledTileHeight * 0.5;
spawnPoints.push(point);
}
}
}
26 changes: 13 additions & 13 deletions Features/FlxNapeTilemap/source/gameobj/Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import nape.shape.Polygon;

class Player extends FlxNapeSprite
{
public function new(x:Float, y:Float, fillColor:FlxColor)
{
super(x, y);
makeGraphic(18, 26, fillColor);
public function new(x:Float, y:Float, fillColor:FlxColor)
{
super(x, y);
makeGraphic(18, 26, fillColor);

if (body != null)
destroyPhysObjects();
if (body != null)
destroyPhysObjects();

centerOffsets(false);
setBody(new Body(BodyType.DYNAMIC, Vec2.weak(x, y)));
centerOffsets(false);
setBody(new Body(BodyType.DYNAMIC, Vec2.weak(x, y)));

var box = new Polygon(Polygon.box(16, 25));
body.shapes.add(box);
body.setShapeMaterials(Constants.playerMaterial);
body.allowRotation = true;
}
var box = new Polygon(Polygon.box(16, 25));
body.shapes.add(box);
body.setShapeMaterials(Constants.playerMaterial);
body.allowRotation = true;
}
}
16 changes: 8 additions & 8 deletions Features/FlxNapeTilemap/source/logic/MathUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package logic;

class MathUtil
{
public static function sortRandomly<T>(collection:Array<T>)
{
collection.sort(fakeRandomCompare);
}
public static function sortRandomly<T>(collection:Array<T>)
{
collection.sort(fakeRandomCompare);
}

private static function fakeRandomCompare<T>(x:T, y:T)
{
return if (Math.random() < 0.5) -1 else 1;
}
private static function fakeRandomCompare<T>(x:T, y:T)
{
return if (Math.random() < 0.5) -1 else 1;
}
}
110 changes: 55 additions & 55 deletions Features/FlxNapeTilemap/source/logic/PhysUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,63 +13,63 @@ import nape.shape.Polygon;

class PhysUtil
{
public static function onTop(thing:Body, ?surface:Body, error:Float = 0.80):Bool
{
for (contact in thing.arbiters)
{
if ((surface == null || contact.body1 == thing || contact.body2 == thing)
&& contact.type == ArbiterType.COLLISION)
{
var normal:Float = contact.collisionArbiter.normal.angle;
if (contact.body1 == thing)
normal = normal - Math.PI;
if (Math.abs(normal + Math.PI / 2) < error)
return true;
}
}
return false;
}
public static function onTop(thing:Body, ?surface:Body, error:Float = 0.80):Bool
{
for (contact in thing.arbiters)
{
if ((surface == null || contact.body1 == thing || contact.body2 == thing)
&& contact.type == ArbiterType.COLLISION)
{
var normal:Float = contact.collisionArbiter.normal.angle;
if (contact.body1 == thing)
normal = normal - Math.PI;
if (Math.abs(normal + Math.PI / 2) < error)
return true;
}
}
return false;
}

public static function setOneWay(tilemap:FlxNapeTilemap, index:Int, vertices:Array<Vec2>,
?mat:Material)
{
tilemap.body.space = null;
var polygon:Polygon;
var coords:Array<FlxPoint> = tilemap.getTileCoords(index, false);
for (point in coords)
{
polygon = new Polygon(vertices, mat);
polygon.translate(Vec2.get(point.x, point.y));
polygon.cbTypes.add(Constants.oneWayType);
tilemap.body.shapes.add(polygon);
}
tilemap.body.space = FlxNapeSpace.space;
}
public static function setOneWay(tilemap:FlxNapeTilemap, index:Int, vertices:Array<Vec2>,
?mat:Material)
{
tilemap.body.space = null;
var polygon:Polygon;
var coords:Array<FlxPoint> = tilemap.getTileCoords(index, false);
for (point in coords)
{
polygon = new Polygon(vertices, mat);
polygon.translate(Vec2.get(point.x, point.y));
polygon.cbTypes.add(Constants.oneWayType);
tilemap.body.shapes.add(polygon);
}
tilemap.body.space = FlxNapeSpace.space;
}

public static function setOneWayLong(tilemap:FlxNapeTilemap, startPos:FlxPoint, length:Int,
?mat:Material)
{
tilemap.body.space = null;
var vertices = [
Vec2.get(0, -0.1),
Vec2.get(Constants.TILE_SIZE * length, -0.1),
Vec2.get(Constants.TILE_SIZE * length, Constants.TILE_SIZE),
Vec2.get(0, Constants.TILE_SIZE)
];
public static function setOneWayLong(tilemap:FlxNapeTilemap, startPos:FlxPoint, length:Int,
?mat:Material)
{
tilemap.body.space = null;
var vertices = [
Vec2.get(0, -0.1),
Vec2.get(Constants.TILE_SIZE * length, -0.1),
Vec2.get(Constants.TILE_SIZE * length, Constants.TILE_SIZE),
Vec2.get(0, Constants.TILE_SIZE)
];

var polygon = new Polygon(vertices, mat);
polygon.translate(Vec2.get(startPos.x, startPos.y));
polygon.cbTypes.add(Constants.oneWayType);
tilemap.body.shapes.add(polygon);
tilemap.body.space = FlxNapeSpace.space;
}
var polygon = new Polygon(vertices, mat);
polygon.translate(Vec2.get(startPos.x, startPos.y));
polygon.cbTypes.add(Constants.oneWayType);
tilemap.body.shapes.add(polygon);
tilemap.body.space = FlxNapeSpace.space;
}

public static function oneWayHandler(cb:PreCallback):PreFlag
{
var colArb = cb.arbiter.collisionArbiter;
if ((colArb.normal.y >= 0) != cb.swapped)
return PreFlag.IGNORE;
else
return PreFlag.ACCEPT;
}
public static function oneWayHandler(cb:PreCallback):PreFlag
{
var colArb = cb.arbiter.collisionArbiter;
if ((colArb.normal.y >= 0) != cb.swapped)
return PreFlag.IGNORE;
else
return PreFlag.ACCEPT;
}
}
Loading

0 comments on commit b039056

Please sign in to comment.