bacongamejam05-notsoalonein.../src/level.coffee

37 lines
1 KiB
CoffeeScript
Raw Normal View History

2013-06-13 21:15:18 +02:00
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 = () ->
2013-07-11 22:55:45 +02:00
window.shadow_layer = [0..(config.map.width*config.map.height)].map -> 0
window.enemy_layer = [0..(config.map.width*config.map.height)].map -> 0
2013-06-13 21:15:18 +02:00
init_level = () ->
level = [0..(config.map.width*config.map.height)].map -> 0
inventar.key = false
load_level = (number) ->
if number is levels.length
2013-06-13 21:46:14 +02:00
config.gamestate = gamestates.WIN
2013-06-13 21:15:18 +02:00
else
init_level()
2013-07-11 22:55:45 +02:00
window.level = levels[number]
2013-06-13 21:15:18 +02:00
parse_levelentities(level)
2013-07-11 22:55:45 +02:00
parse_levelentities = (level) ->
2013-06-13 21:15:18 +02:00
for block, position in level
switch block
when 4
player.position = position
level[position] = 0