Skip to content

Commit

Permalink
Initial work on respawn points
Browse files Browse the repository at this point in the history
  • Loading branch information
nullenvk committed May 29, 2022
1 parent e6d12ed commit 537c1b3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions res/main.map
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
B0000000000000000000000000000000
B0000000000000000000000000000000
B0000000000000000000000000000000
B00000000000000000R0000000000000
B000000BBB000BBBBBBBBBBBBBB0BBBB
B000000BBB000BBBBBBBBBBBB000000B
B000000BBB000BBBBBBBBBBBB000000B
Expand All @@ -27,7 +27,7 @@ BBBBBBBBBBBBBB00000BBBBBBBBBBBBB
BBBBBBBBBBBBBB00000BBBBBBBBBBBBB

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
0000000000000000000000000000000B
000000000000000000R000000000000B
0000000000000000000000000000000B
0000000000000000000000000000000B
B000000BBB000BBBBBBBBBBBBBB0BBBB
Expand Down
Binary file added res/tileR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/ent_player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ local function isTileBlocking(tile)
['0'] = false,
['B'] = true,
['K'] = false,
['R'] = false,
}

if tile == nil then return true end
Expand Down Expand Up @@ -303,6 +304,7 @@ function Player:reactToCol(tilemap, dPos, tFinal, isVert, tilePos)
local TILE_HANDLERS = {
['B'] = self.reactToColSlide,
['K'] = self.reactToColKill,
['R'] = self.reactToColIgnore, -- SET RESPAWN
}

local NIL_HANDLER = self.reactToColTransition
Expand Down
25 changes: 21 additions & 4 deletions src/ent_tiles.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('src.ent_sprite')

--local TILETYPE_NUM = 2
local TILETYPES = {"B", "K"}
local TILETYPES = {"B", "K", "R"}

Tiles = GameObj:new({dat = nil, colDat = nil, textures = nil})

Expand Down Expand Up @@ -68,6 +68,24 @@ function Tiles:setColorByScreen()
love.graphics.setColor(SCR_COLORS[i])
end

function Tiles:setTileColor(t)
local UNCOLORED_TILES = {"R"}

local uncolored = false
for _,v in pairs(UNCOLORED_TILES) do
if v == t then
uncolored = true
break
end
end

if uncolored then
love.graphics.setColor(1,1,1,1)
else
self:setColorByScreen()
end
end

function Tiles:drawTile(tx, ty)
local tile_w = 800 / TILESCREEN_W
local tile_h = 600 / TILESCREEN_H
Expand All @@ -81,7 +99,6 @@ function Tiles:drawTile(tx, ty)
return tile == self.dat[tx + ox][ty + oy]
end

love.graphics.rectangle("fill", (tx-1)*tile_w, (ty-1)*tile_h, tile_w, tile_h)
if self.textures[tile] == nil then return end

local qnum = 1
Expand All @@ -92,12 +109,12 @@ function Tiles:drawTile(tx, ty)

local tex = Tiles.textures[tile]
local x, y = (tx-1) * tile_w, (ty-1) * tile_h

self:setTileColor(tile)
love.graphics.draw(tex.texture, tex.quads[qnum], x, y)
end

function Tiles:draw()
self:setColorByScreen()

for x=1,TILESCREEN_W do
for y=1,TILESCREEN_H do
if self.dat[x][y] ~= "0" then self:drawTile(x, y) end
Expand Down

0 comments on commit 537c1b3

Please sign in to comment.