a45cb95030
- [NEW] music.state() - [NEW] contsants music.INVALID, music.PLAYING, music.PAUSED, music.STOPPED i music.DISABLED - [NEW] El exemple en lua inclos te una secció per a mostrar les funcionalitats de la música
83 lines
2.0 KiB
Lua
83 lines
2.0 KiB
Lua
--require "ia.other"
|
|
|
|
x=0
|
|
rot=0
|
|
music_states = { "INVALID", "PLAYING", "PAUSED", "STOPPED", "DISABLED" }
|
|
music_pos = 0
|
|
|
|
function mini.init()
|
|
s = surf.load("gfx/logo.gif")
|
|
surf.source(s)
|
|
p = pal.load("gfx/logo.gif")
|
|
pal.set(p)
|
|
pal.trans(255)
|
|
--surf.save(s, "prova.gif", p)
|
|
|
|
print("=== PACKAGES LOADED ===")
|
|
for name, value in pairs(package.loaded) do
|
|
print(name, value)
|
|
end
|
|
print("========================")
|
|
|
|
f = font.load("font.fnt")
|
|
--music.play("mus_menu.ogg")
|
|
end
|
|
|
|
function mini.update()
|
|
surf.cls(0)
|
|
draw.surfrot(0, 0, 160, 144, 120, 78, rot)
|
|
|
|
draw.text("PRESS START", 60, 110, 28)
|
|
if key.press(key.ESCAPE) then sys.quit() end
|
|
draw.text(sys.fps(), 1, 1, 28)
|
|
|
|
if key.press(key.N1) then
|
|
shader.init("lynx.glsl")
|
|
shader.enable()
|
|
end
|
|
if key.press(key.N2) then
|
|
shader.init("gbc.glsl")
|
|
shader.enable()
|
|
end
|
|
if key.press(key.N3) then
|
|
shader.disable()
|
|
end
|
|
|
|
local mx, my = mouse.pos()
|
|
draw.rectf(mx, my, 4, 4, 8)
|
|
draw.text(mx .. " " .. my, 1, 8, 8)
|
|
--draw.text(other.peiv(),1,100,4)
|
|
|
|
font.current(f)
|
|
font.spacing(0)
|
|
draw.text("0146",100,50,28)
|
|
font.current(font.DEFAULT)
|
|
rot=rot+1
|
|
|
|
-- MUSICA
|
|
draw.text("music:", 1, 20, 22)
|
|
draw.text("duration:" .. music.duration(), 1, 28, 28)
|
|
draw.text("position:" .. music.pos(), 1, 36, 28)
|
|
draw.text("state: " .. music_states[music.state()+1], 1, 44, 28)
|
|
|
|
if key.press(key.P) then
|
|
if music.state() == music.PLAYING then
|
|
music.pause()
|
|
elseif music.state() == music.PAUSED then
|
|
music.resume()
|
|
else
|
|
music.play("mus_menu.ogg")
|
|
end
|
|
elseif key.press(key.S) then
|
|
music.stop()
|
|
elseif key.press(key.C) then
|
|
if music.state() == music.PLAYING then
|
|
music_pos = music.pos()
|
|
music.stop()
|
|
else
|
|
music.play("mus_menu.ogg")
|
|
music.pos(music_pos)
|
|
end
|
|
end
|
|
end
|