iso-engine blades sample terrains

This commit is contained in:
2022-06-07 22:35:10 +00:00
parent b32792d802
commit 48c7d3e6e1
2 changed files with 47 additions and 6 deletions

View File

@@ -45,20 +45,31 @@ class ScenData {
}
var path = '$data/Terrain Graphics/G$num.bmp';
if (!FileSystem.exists(path)) return null;
spriteSheets[num] = SpriteSheet.fromSimpleBmp(path, 46, 55);
return spriteSheets[num];
}
function emptySprite() {
var s = new FlxSprite(0, 0);
s.makeGraphic(46, 55, FlxColor.TRANSPARENT);
s.alpha = 0;
return s;
}
public function floorSprite(floorId:Int) {
if (!floorData.exists(floorId)) {
var s = new FlxSprite(0, 0);
s.makeGraphic(46, 55, FlxColor.TRANSPARENT);
return s;
return emptySprite();
}
var fd = floorData[floorId];
var sprite = floorOrTerrainSpriteSheet(fd.which_sheet).clone();
var sheet = floorOrTerrainSpriteSheet(fd.which_sheet);
if (sheet == null) {
return emptySprite();
}
var sprite = sheet.clone();
sprite.animation.frameIndex = fd.which_icon;
// TODO if it's animated add the animations
@@ -67,9 +78,18 @@ class ScenData {
}
public function terrainSprite(terrainId:Int) {
if (!terrainData.exists(terrainId)) {
var s = new FlxSprite(0, 0);
s.makeGraphic(46, 55, FlxColor.TRANSPARENT);
return s;
}
var td = terrainData[terrainId];
var sprite = floorOrTerrainSpriteSheet(td.which_sheet).clone();
var sheet = floorOrTerrainSpriteSheet(td.which_sheet);
if (sheet == null) {
return emptySprite();
}
var sprite = sheet.clone();
sprite.animation.frameIndex = td.which_icon;
// TODO if it's a tall terrain combine it with the upper sprite and set its origin to offset y