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

@@ -8,7 +8,11 @@
(method &override :Void create []
(super.create)
(set data (ScenData.coreData))
(addFloorLayer (groups (collect (range 255)) 32)))
(addFloorLayer (groups (collect (range 255)) 32))
(addTerrainLayer (groups (concat
(for _ (range 255) -1)
(collect (range 512)))
32)))
(method :Void addFloorLayer [:Array<Array<Int>> tiles]
(let [&mut rowStartX 0
@@ -26,6 +30,23 @@
(-= rowStartX (/ FLOOR_WIDTH 2))
(+= rowStartY (/ FLOOR_HEIGHT 2)))))
(method :Void addTerrainLayer [:Array<Array<Int>> tiles]
(let [&mut rowStartX 0
&mut rowStartY 0]
(doFor row tiles
(let [&mut x rowStartX
&mut y rowStartY]
(doFor tile row
(let [tileSprite (data.terrainSprite tile)]
(set tileSprite.x x)
(set tileSprite.y y)
(add tileSprite))
(+= x (/ FLOOR_WIDTH 2))
(+= y (/ FLOOR_HEIGHT 2))))
(-= rowStartX (/ FLOOR_WIDTH 2))
(+= rowStartY (/ FLOOR_HEIGHT 2)))))
(var CAMERA_SPEED 500)
(method &override :Void update [:Float elapsed]

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