forked from pyrex/chameleonic
Implement hint system and music mute.
This commit is contained in:
parent
f052186c97
commit
5ce2f24a21
@ -8,6 +8,7 @@ real_modules={}
|
||||
frame=0
|
||||
function _init()
|
||||
-- printh("restarting")
|
||||
music_on()
|
||||
_doall("init") end
|
||||
function _update()
|
||||
frame+=1
|
||||
@ -15,6 +16,16 @@ function _update()
|
||||
function _draw()
|
||||
_doall("draw") end
|
||||
|
||||
function music_on()
|
||||
music(0)
|
||||
menuitem(3, "music: on", music_off)
|
||||
end
|
||||
|
||||
function music_off()
|
||||
music(-1)
|
||||
menuitem(3, "music: off", music_on)
|
||||
end
|
||||
|
||||
mnames={}
|
||||
function names(root)
|
||||
local n=mnames[root]
|
||||
@ -97,6 +108,15 @@ function sgn0(x)
|
||||
return x!=0 and sgn(x) or 0
|
||||
end
|
||||
|
||||
function inorder(tbl)
|
||||
local prev
|
||||
for v in all(tbl) do
|
||||
if (prev and v < prev) return
|
||||
prev = v
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function _mnmx(x,y)
|
||||
if (x>y)return y,x
|
||||
return x,y
|
||||
@ -266,6 +286,7 @@ function level:init()
|
||||
end
|
||||
|
||||
function level:reinit(n)
|
||||
self.hintlevel = 0
|
||||
self.ix=n
|
||||
self.todo={}
|
||||
self.bigx,self.bigy=n%8,n\8
|
||||
@ -1704,6 +1725,62 @@ function level_text:draw()
|
||||
print(xys[4],xys[2],xys[3],6)
|
||||
end
|
||||
end
|
||||
|
||||
-->8
|
||||
--hint system
|
||||
function gsv(s)
|
||||
local ret=split(s,"\n")
|
||||
for i,v in ipairs(ret) do
|
||||
ret[i] = type(v) == "string" and split(v,"`") or {v} end
|
||||
return ret
|
||||
end
|
||||
|
||||
function rot13(s)
|
||||
local sord = pack(ord(s,1,#s))
|
||||
for i,c in ipairs(sord) do
|
||||
if (inorder{65, c, 77} or inorder{97, c, 109}) sord[i]=c+13
|
||||
if (inorder{78, c, 90} or inorder{110, c, 122}) sord[i]=c-13
|
||||
end
|
||||
return chr(unpack(sord))
|
||||
end
|
||||
--hint file format:
|
||||
-- each row is one hint. 4 columns per row
|
||||
-- separated with a grave (`) character
|
||||
-- room# ` X (screen px) ` Y (screen px) ` message
|
||||
-- message is ROT13d; works for a-zA-Z
|
||||
|
||||
hints = {}
|
||||
add(real_modules,hints)
|
||||
|
||||
function hints:init()
|
||||
local h = gsv[[1`64`64`zYRZ
|
||||
2`32`32`fCYHOC]]
|
||||
for rec in all(h) do
|
||||
rec[4]=rot13(rec[4])
|
||||
local lh = self[rec[1]]
|
||||
if not lh then
|
||||
lh = {rec}
|
||||
self[rec[1]] = lh
|
||||
else
|
||||
add(lh,rec)
|
||||
end
|
||||
end
|
||||
menuitem(1,"get hint",function() level.hintlevel+=1 end)
|
||||
menuitem(2,"hide hints",function() level.hintlevel=0 end)
|
||||
end
|
||||
|
||||
hintflicker={7,10,9,8,8,9,10,7}
|
||||
function hints:draw2()
|
||||
pal()
|
||||
local c=hintflicker[t()%1*#hintflicker\1+1]
|
||||
for i,h in ipairs(self[level.ix]) do
|
||||
if (i > level.hintlevel) return
|
||||
local _,x,y,txt=unpack(h)
|
||||
print(txt,x-1,y+1,1)
|
||||
print(txt,x,y,c)
|
||||
end
|
||||
end
|
||||
|
||||
__gfx__
|
||||
000030000000002200003000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeff1ff1ff1fffffff1ffffff1fffffff1dddddddd111111110005000000000000
|
||||
003333300000332200333330eeffffffffffffffffffffeee5e555e55e555e5eff1ff1ffffffffffffffffffffffffffdddddddd111111110000500000000000
|
||||
|
Loading…
Reference in New Issue
Block a user