blades-engine handle wall types
This commit is contained in:
@@ -49,8 +49,7 @@
|
||||
|
||||
// TODO add any characters
|
||||
|
||||
// TODO the wall sprites will be from different sheets defined by town/outdoor section
|
||||
(let [tileSprite (data.terrainSprite terrain)]
|
||||
(let [tileSprite (data.terrainSprite terrain (map.wallSheet 1) (map.wallSheet 2))]
|
||||
(when tileSprite
|
||||
(+= tileSprite.x x)
|
||||
(+= tileSprite.y (- y yOffset))
|
||||
|
@@ -73,7 +73,7 @@ class ScenData {
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public function terrainSprite(terrainId:Int) {
|
||||
public function terrainSprite(terrainId:Int, wallSheet1:Int, wallSheet2:Int) {
|
||||
if (!(terrainId >= 0 && terrainId < 512))
|
||||
throw 'terrain $terrainId is out of range';
|
||||
if (!terrainData.exists(terrainId)) {
|
||||
@@ -81,7 +81,15 @@ class ScenData {
|
||||
}
|
||||
var td = terrainData[terrainId];
|
||||
|
||||
var sheet = floorOrTerrainSpriteSheet(td.which_sheet);
|
||||
var which_sheet = if (td.name == "Wall") {
|
||||
if (terrainId >= 38)
|
||||
wallSheet2;
|
||||
else
|
||||
wallSheet1;
|
||||
} else {
|
||||
td.which_sheet;
|
||||
};
|
||||
var sheet = floorOrTerrainSpriteSheet(which_sheet);
|
||||
if (sheet == null) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -104,8 +104,10 @@ class Scenario {
|
||||
var outdoorWidth = 48;
|
||||
var outdoorHeight = 48;
|
||||
|
||||
// TODO above ground/underground?
|
||||
|
||||
// section name, max length 21, followed by floor tile columns
|
||||
var sec = new TileMap(outdoorWidth, outdoorHeight, stream.readCString(19));
|
||||
var sec = new TileMap(outdoorWidth, outdoorHeight, stream.readCString(19), Outdoors(false));
|
||||
trace(sec.name);
|
||||
|
||||
for (x in 0...outdoorWidth) {
|
||||
|
@@ -2,6 +2,16 @@ package data.blades;
|
||||
|
||||
typedef TileArray<T> = Array<Array<T>>;
|
||||
|
||||
typedef TownDetails = {
|
||||
wallSheet1:Int,
|
||||
wallSheet2:Int
|
||||
};
|
||||
|
||||
enum MapType {
|
||||
Town(details:TownDetails);
|
||||
Outdoors(underground:Bool);
|
||||
}
|
||||
|
||||
class TileMap {
|
||||
// TODO might need encapsulation
|
||||
public var floorCodes:TileArray<Int>;
|
||||
@@ -17,15 +27,32 @@ class TileMap {
|
||||
return [for (x in 0...width) [for (y in 0...height) defaultValue]];
|
||||
}
|
||||
|
||||
public function new(width, height, name) {
|
||||
public function wallSheet(num:Int) {
|
||||
return switch (type) {
|
||||
case Town(det):
|
||||
if (num == 1)
|
||||
det.wallSheet1;
|
||||
else
|
||||
det.wallSheet2;
|
||||
case Outdoors(true):
|
||||
614;
|
||||
case Outdoors(false):
|
||||
616;
|
||||
};
|
||||
}
|
||||
|
||||
public function new(width, height, name, type) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.name = name;
|
||||
floorCodes = tileArray(255);
|
||||
terrainCodes = tileArray(0);
|
||||
floorHeights = tileArray(9);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public var type:MapType;
|
||||
|
||||
public function setFloor(x, y, code) {
|
||||
floorCodes[x][y] = code;
|
||||
}
|
||||
|
Reference in New Issue
Block a user