123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- (global GAMENAME "Hats in the Deep")
- (var LOOP :game)
- (var creditsv (point 110 64))
- (var depth 0)
- (var change-level (fn []))
- (global world [[]])
- (global tiles [[]])
- (global entities [])
- (global items [])
- (global triggers [])
- (global fx [])
- (global msgs [])
- (var _song -1)
- (var music? true)
- (var quickstart? false)
- (var GENERAL [])
- (var ARMORY [])
- (var MAGIC [])
- (var DEATHMSG false)
- (var DEEPEST 0)
- (var cache {})
- (fn cache-level []
- (tset cache depth {
- :world world
- :tiles tiles
- :entities entities
- :items items
- :triggers triggers
- :playerpos player.pos}))
- (fn load-cache [lvl]
- (trace "load-cache")
- (var c (. cache lvl))
- (when c
- (trace "LOADING")
- (global world c.world)
- (global tiles c.tiles)
- (global entities c.entities)
- (global triggers c.triggers)
- (global items c.items)
- (set player.pos (copy c.playerpos)))
- (if c true false))
- (fn clear-cache [] ;remove cached more than 1 depth away from player
- (var c {})
- (each [k v (pairs cache)]
- (if (or (= k 0) ; never uncache town
- true ; uncache nothing hahaha
- (<= (dec depth) k (inc depth)))
- (tset c k v)))
- (set cache c))
- (fn song! [n]
- (when music?
- (when (= false (= n _song))
- (music n)
- (set _song n))))
- (fn sound! [k]
- (var sound-map {
- :levelup 60
- :cancel 61
- :select 62
- :beep 63
- :miss 59
- :hit 58})
- (sfx (. sound-map k) "C#4" -1 3))
- (var greystone [128 128 128 128 128 128 128 128 129 129 129 130 131 132 132 132])
- (global themes {
- :stone {:0 96 :1 greystone :0->1 112 :2 144 :0->2 176 :1->2 160}
- :bright {:0 97 :1 greystone :0->1 113 :2 145 :0->2 177 :1->2 161}
- :woods {:0 [98 99 100] :1 greystone :0->1 114 :2 146 :0->2 178 :1->2 162}})
- (global base-entity {
- :pos (point 0 0)
- :offset (point 0 0)
- :sprite 1
- :hp 5
- :maxhp 5
- :speed 1
- :level 1 ;multiplier for a lot of things
- :exp 0 ;level benchmark can be calculated
- :ac 2 ;lol no clue
- :attack [1 2]})
- (fn reset-player []
- (global player (merge base-entity {
- :player true
- :sprite 32
- :hp 14
- :maxhp 14
- :gold 24
- :inventory []
- :inventory-limit 6
- :weapon false
- :clip-tile true ;stair animation
- :equip {
- :head false
- :body false
- :feet false}})))
- (reset-player)
- (global cardinals [
- (point -1 0)
- (point 1 0)
- (point 0 -1)
- (point 0 1)])
- (global DEBUG "DEBUG")
- (var shop (fn []))
|