-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added resort lantern entity
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local drawableSprite = require("structs.drawable_sprite") | ||
|
||
local checkpoint = {} | ||
|
||
checkpoint.name = "checkpoint" | ||
checkpoint.depth = 9990 | ||
|
||
function checkpoint.sprite(room, entity) | ||
local bg = entity.bg or "1" | ||
local texture = string.format("objects/checkpoint/bg/%s", bg) | ||
local sprite = drawableSprite.spriteFromTexture(texture, entity) | ||
|
||
sprite:setJustification(0.5, 1.0) | ||
|
||
return sprite | ||
end | ||
|
||
return checkpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
local drawableSprite = require("structs.drawable_sprite") | ||
|
||
local holderTexture = "objects/resortLantern/holder" | ||
local lanternTexture = "objects/resortLantern/lantern00" | ||
|
||
local resortLantern = {} | ||
|
||
resortLantern.name = "resortLantern" | ||
resortLantern.depth = 2000 | ||
resortLantern.placements = { | ||
name = "lantern" | ||
} | ||
|
||
function resortLantern.sprite(room, entity) | ||
local checkX, checkY = math.floor(entity.x / 8) + 2, math.floor(entity.y / 8) | ||
local connected = room.tilesFg.matrix:get(checkX, checkY, "0") | ||
|
||
local holderSprite = drawableSprite.spriteFromTexture(holderTexture, entity) | ||
local lanternSprite = drawableSprite.spriteFromTexture(lanternTexture, entity) | ||
|
||
if connected ~= "0" and connected ~= " " then | ||
holderSprite.scaleX = -1 | ||
end | ||
|
||
return { | ||
holderSprite, | ||
lanternSprite | ||
} | ||
end | ||
|
||
return resortLantern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters