blades-engine parse terrain and floor height

This commit is contained in:
2022-06-10 23:07:39 +00:00
parent b6540e8d18
commit 3f773a83ee
5 changed files with 62 additions and 52 deletions

View File

@@ -61,6 +61,8 @@ class ScenData {
}
public function floorSprite(floorId:Int) {
if (!(floorId >= 0 && floorId < 256))
throw 'floor $floorId is out of range';
if (!floorData.exists(floorId)) {
return emptySprite();
}
@@ -81,6 +83,8 @@ class ScenData {
}
public function terrainSprite(terrainId:Int) {
if (!(terrainId >= 0 && terrainId < 512))
throw 'terrain $terrainId is out of range';
if (!terrainData.exists(terrainId)) {
var s = new FlxSprite(0, 0);
s.makeGraphic(46, 55, FlxColor.TRANSPARENT);

View File

@@ -108,18 +108,28 @@ class Scenario {
var sec = new TileMap(outdoorWidth, outdoorHeight, stream.readCString(19));
trace(sec.name);
for (y in 0...outdoorHeight) {
for (x in 0...outdoorWidth) {
for (x in 0...outdoorWidth) {
for (y in 0...outdoorHeight) {
sec.setFloor(x, y, stream.readByte());
}
}
// floor heights
for (y in 0...outdoorHeight) {
for (x in 0...outdoorWidth) {
for (x in 0...outdoorWidth) {
for (y in 0...outdoorHeight) {
sec.setFloorHeight(x, y, stream.readByte());
}
}
// 1 byte of padding to align the int16s
// terrain
for (x in 0...outdoorWidth) {
for (y in 0...outdoorHeight) {
// these are big-endian
sec.setTerrain(x, y, 256 * stream.readByte() + stream.readByte());
}
}
stream.tracePosition();
// TODO all the other outdoor section stuff

View File

@@ -6,10 +6,10 @@ class TileMap {
// TODO might need encapsulation
public var floorCodes:TileArray<Int>;
public var floorHeights:TileArray<Int>;
private var terrainCodes:TileArray<Int>;
public var terrainCodes:TileArray<Int>;
private var width = 0;
private var height = 0;
public var width = 0;
public var height = 0;
public var name = "";