Skip to content

Commit

Permalink
Move to OpenFL. Fix for latest Haxe3 release. Remove unused imports h…
Browse files Browse the repository at this point in the history
…ere and there.
  • Loading branch information
nadako committed Jun 4, 2013
1 parent 311bf45 commit 38ee562
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 77 deletions.
4 changes: 1 addition & 3 deletions project.nmml → project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

<source path="src"/>

<haxelib name="nme"/>
<haxelib name="openfl"/>
<haxelib name="HaxePunk"/>
<haxelib name="HaxePunk-gui"/>
<haxelib name="ash"/>

<ndll name="nme" haxelib="nme"/>

<assets path="assets" rename=""/>
</project>
8 changes: 4 additions & 4 deletions src/dungeons/AssetFactory.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import com.haxepunk.graphics.Spritemap;
import com.haxepunk.Graphic;
import haxe.Json;

import nme.geom.Rectangle;
import nme.geom.Matrix;
import nme.display.BitmapData;
import nme.Assets;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import flash.display.BitmapData;
import openfl.Assets;

import com.haxepunk.HXP;
import com.haxepunk.graphics.Image;
Expand Down
2 changes: 1 addition & 1 deletion src/dungeons/EntityCreator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import haxe.Json;
import ash.core.Engine;
import ash.core.Entity;

import nme.Assets;
import openfl.Assets;

import com.haxepunk.HXP;

Expand Down
51 changes: 10 additions & 41 deletions src/dungeons/GameScene.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,26 @@ package dungeons;

import Lambda;

import com.haxepunk.graphics.Image;
import com.haxepunk.graphics.Graphiclist;
import com.haxepunk.graphics.Spritemap;
import com.haxepunk.graphics.Tilemap;
import com.haxepunk.Graphic;
import com.haxepunk.HXP;
import com.haxepunk.Scene;

import haxe.Json;

import nme.display.Bitmap;
import nme.display.DisplayObjectContainer;
import nme.events.KeyboardEvent;
import nme.ui.Keyboard;
import nme.display.Shape;
import nme.Assets;
import nme.geom.Point;
import nme.geom.Rectangle;
import nme.geom.Matrix;
import nme.events.Event;
import nme.display.BitmapData;
import nme.display.StageScaleMode;
import nme.display.Sprite;
import nme.text.TextFormat;
import nme.text.TextField;
import nme.Lib;
import openfl.Assets;
import flash.text.TextFormat;
import flash.text.TextField;

import ash.core.Engine;
import ash.core.Entity;

import dungeons.components.HealthRegen;
import dungeons.components.Key;
import dungeons.components.Health;
import dungeons.components.Description;
import dungeons.components.MonsterAI;
import dungeons.components.Obstacle;
import dungeons.components.FOV;
import dungeons.components.CameraFocus;
import dungeons.components.Actor;
import dungeons.components.PlayerControls;
import dungeons.components.Position;
import dungeons.components.LightOccluder;
import dungeons.components.DoorRenderable;
import dungeons.components.Door;
import dungeons.components.Fighter;
import dungeons.components.Renderable;
import dungeons.components.Item;
import dungeons.components.Inventory;
import dungeons.components.TimeTicker;
import dungeons.components.Equipment;

import dungeons.systems.MessageLogSystem;
import dungeons.systems.FightSystem;
Expand All @@ -72,8 +42,6 @@ import dungeons.systems.ScheduleSystem;
import dungeons.systems.HealthRegenSystem;

import dungeons.mapgen.Dungeon;
import dungeons.utils.ShadowCaster;
import dungeons.utils.TransitionTileHelper;
import dungeons.utils.MapGrid;
import dungeons.utils.Vector;
import dungeons.utils.Scheduler;
Expand Down Expand Up @@ -188,7 +156,7 @@ class GameScene extends Scene
door.add(new Position(x, y));
door.add(new dungeons.components.Door(open, level));
var type:String = doorTypes[level % doorTypes.length];
door.add(new DoorRenderable("door_"+type+"_open", "door_"+type+"_closed"), Renderable);
door.add(new DoorRenderable("door_" + type + "_open", "door_" + type + "_closed"), Renderable);
engine.addEntity(door);
default:
continue;
Expand All @@ -199,14 +167,15 @@ class GameScene extends Scene
for (keyLevel in 0...dungeon.keyLevel)
{
var rooms = Lambda.array(dungeon.getLevelRooms(keyLevel));
rooms.sort(function (a, b) { return Math.round(a.intensity - b.intensity); });
rooms.sort(function(a, b)
{ return Math.round(a.intensity - b.intensity); });

var room:Room = rooms[0];
var point:Vector = getRandomRoomPoint(room);

var key:Entity = new Entity();
key.add(new Position(point.x, point.y));
key.add(new Item("key"+(keyLevel + 1), false, 1));
key.add(new Item("key" + (keyLevel + 1), false, 1));
key.add(new Description("Key " + (keyLevel + 1)));
key.add(new Key(keyLevel + 1));

Expand Down Expand Up @@ -272,7 +241,7 @@ class GameScene extends Scene
shelf.add(obstacle);
var type:String = HXP.random < 0.5 ? "bookshelf_ransacked" : "bookshelf";
var variant:Int = HXP.rand(3);
shelf.add(new Renderable(type+variant, RenderLayers.OBJECT));
shelf.add(new Renderable(type + variant, RenderLayers.OBJECT));
engine.addEntity(shelf);
}
case Fountain:
Expand Down Expand Up @@ -336,8 +305,8 @@ class GameScene extends Scene
private static function getRandomRoomPoint(room:Room):Vector
{
return {
x: room.x + 1 + HXP.rand(room.grid.width - 2),
y: room.y + 1 + HXP.rand(room.grid.height - 2)
x: room.x + 1 + HXP.rand(room.grid.width - 2),
y: room.y + 1 + HXP.rand(room.grid.height - 2)
};
}

Expand Down
3 changes: 0 additions & 3 deletions src/dungeons/components/Renderable.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package dungeons.components;

import com.haxepunk.HXP;
import com.haxepunk.Graphic;

import dungeons.systems.RenderSystem.RenderLayers;

class Renderable
Expand Down
3 changes: 0 additions & 3 deletions src/dungeons/systems/FOVSystem.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package dungeons.systems;

import dungeons.utils.MapGrid;
import nme.display.BitmapData;

import com.haxepunk.graphics.Image;

import ash.core.NodeList;
import ash.core.Engine;
Expand Down
2 changes: 1 addition & 1 deletion src/dungeons/systems/MessageLogSystem.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dungeons.systems;

import nme.text.TextField;
import flash.text.TextField;

import ash.core.System;

Expand Down
9 changes: 3 additions & 6 deletions src/dungeons/systems/RenderSystem.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package dungeons.systems;

import nme.geom.Rectangle;
import nme.display.BitmapData;
import nme.Lib;
import flash.geom.Rectangle;
import flash.display.BitmapData;

import com.haxepunk.tweens.misc.NumTween;
import com.haxepunk.tweens.motion.LinearMotion;
Expand All @@ -29,12 +28,10 @@ import dungeons.components.Item;
import dungeons.components.Inventory;
import dungeons.components.Position.PositionChangeListener;
import dungeons.components.Health;
import dungeons.components.Fighter;
import dungeons.components.Renderable;
import dungeons.mapgen.Dungeon;
import dungeons.nodes.PlayerInventoryNode;
import dungeons.nodes.TimeTickerNode;
import dungeons.nodes.PlayerStatsNode;
import dungeons.utils.Grid;
import dungeons.utils.MapGrid;
import dungeons.utils.TransitionTileHelper;
Expand Down Expand Up @@ -101,7 +98,7 @@ class RenderSystem extends System
fovOverlayImage = new Image(fovOverlayData);
fovOverlayImage.scale = assetFactory.tileSize;
fovOverlayEntity = scene.addGraphic(fovOverlayImage, RenderLayers.FOV);
// fovOverlayEntity.visible = false;
// fovOverlayEntity.visible = false;

fovOverlayDirty = true;

Expand Down
26 changes: 12 additions & 14 deletions src/dungeons/utils/Direction.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,40 @@ enum Direction

class DirectionUtil
{
public static inline function fromOffset(dx:Int, dy:Int):Direction
public static function fromOffset(dx:Int, dy:Int):Direction
{
return if (dx == 0)
if (dx == 0)
{
if (dy < 0)
North;
return North;
else if (dy > 0)
South;
return South;
}
else if (dy == 0)
{
if (dx < 0)
West;
return West;
else if (dx > 0)
East;
return East;
}
else if (dy < 0 && dx < 0)
{
NorthWest;
return NorthWest;
}
else if (dy < 0 && dx > 0)
{
NorthEast;
return NorthEast;
}
else if (dy > 0 && dx < 0)
{
SouthWest;
return SouthWest;
}
else if (dy > 0 && dx > 0)
{
SouthEast;
}
else
{
throw "unknown direction for offset " + dx + "x" + dy;
return SouthEast;
}

throw "unknown direction for offset " + dx + "x" + dy;
}

public static inline function offset(dir:Direction):Vector
Expand Down
2 changes: 1 addition & 1 deletion src/dungeons/utils/TransitionTileHelper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dungeons.utils;

import haxe.Json;

import nme.Assets;
import openfl.Assets;

/**
* Helper class for getting a wall transition tile number
Expand Down

0 comments on commit 38ee562

Please sign in to comment.