Commit 2921a08d authored by Delisa Mason's avatar Delisa Mason

feat: Add audio commands

parent bed8202a
load_resources {
map_add("level01", "game/assets/maps/level01/init.lua"),
sprite_add("player", "game/assets/images/player.png", 16, 0, 16, 16),
audio_add("explosion", "game/assets/sounds/explosion.wav"),
}
all_groups {
map_draw("level01"),
......@@ -18,6 +19,7 @@ group {
auto_dialog(240, 10, 3, "We are gonna crash!!"),
}
group {
audio_play("explosion"),
sprite_draw("player", 200, 310, 1, 1, 2.1),
shake_screen(1, 4, 60),
wait(3)
......
......@@ -92,6 +92,49 @@ local SceneDSL = function()
end
end
function scene.audio_add(id, filepath)
return {id=id, data={source=love.audio.newSource(filepath, "static")}}
end
function scene.audio_play(id)
return {
asset_id=id,
transform={
apply=function(self, asset, _, dt)
if self.applied ~= true then
love.audio.play(asset.data.source)
self.applied = true
end
end
}}
end
function scene.audio_stop(id)
return {
asset_id=id,
transform={
apply=function(self, asset, _, dt)
if self.applied ~= true then
love.audio.stop(asset.data.source)
self.applied = true
end
end
}}
end
function scene.audio_pause(id)
return {
asset_id=id,
transform={
apply=function(self, asset, _, dt)
if self.applied ~= true then
love.audio.pause(asset.data.source)
self.applied = true
end
end
}}
end
function scene.map_add(id, map_path)
return {id=id, data={map=sti(map_path)}}
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment