-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnormal_state.lua
35 lines (29 loc) · 916 Bytes
/
normal_state.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local Object = require "lib/classic"
local term = require "term"
local Player = require "player"
local Map = require "map"
local Generators = require "map_generator"
NormalState = Object:extend()
function NormalState:new()
self.entity_list = {}
self.map = Generators.room_map(MAP_WIDTH, MAP_HEIGHT)
self.player = Player(self, self.map.spawn_pos[1], self.map.spawn_pos[2])
self:add_entity(self.player)
self.map:update_fov(self.player.x, self.player.y)
end
function NormalState:add_entity(entity)
self.entity_list[#self.entity_list + 1] = entity
end
function NormalState:keypressed(key)
if self.player:keypressed(key) then
-- enemy's turn
end
end
function NormalState:render()
self.map:render()
for _, entity in ipairs(self.entity_list) do
--print(entity)
term.setchar(entity.x, entity.y, entity.char, entity.color)
end
console:render()
end