38 lines
1,001 B
CoffeeScript
38 lines
1,001 B
CoffeeScript
add_level = (map) ->
|
|
levels.push map
|
|
|
|
draw_level = (level) ->
|
|
for block, position in level
|
|
switch block
|
|
when 0 then color = colors.floor
|
|
when 3 then color = colors.wall
|
|
when 1 then color = colors.key
|
|
when 2 then color = colors.door
|
|
when 7 then color = colors.exit
|
|
when 5 then color = colors.breakable
|
|
|
|
pixel(position, config.pixelsize, config.pixelsize, color)
|
|
|
|
reset_layers = () ->
|
|
shadow_layer = [0..(config.map.width*config.map.height)].map -> 0
|
|
enemy_layer = [0..(config.map.width*config.map.height)].map -> 0
|
|
|
|
init_level = () ->
|
|
level = [0..(config.map.width*config.map.height)].map -> 0
|
|
|
|
inventar.key = false
|
|
|
|
load_level = (number) ->
|
|
if number is levels.length
|
|
config.gamestate = gamestates.WIN
|
|
else
|
|
init_level()
|
|
level = levels[number]
|
|
parse_levelentities(level)
|
|
|
|
parse_levelentities = ->
|
|
for block, position in level
|
|
switch block
|
|
when 4
|
|
player.position = position
|
|
level[position] = 0 |