Volume control and playing sounds
This commit is contained in:
parent
b21d144c77
commit
1c8a840a7f
43 changed files with 442 additions and 66 deletions
|
|
@ -1,9 +1,12 @@
|
||||||
{
|
{
|
||||||
:code {
|
:code {
|
||||||
:find {
|
:find {
|
||||||
:term "speed"
|
:term "gui.set_position"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
:search-in-files {
|
||||||
|
:term "{"
|
||||||
|
}
|
||||||
:workflow {
|
:workflow {
|
||||||
:recent-files [
|
:recent-files [
|
||||||
[
|
[
|
||||||
|
|
@ -11,11 +14,19 @@
|
||||||
:scene
|
:scene
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
"/main/level3.script"
|
"/main/mummy.script"
|
||||||
:code
|
:code
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
"/main/mummy.script"
|
"/main/entername.collection"
|
||||||
|
:scene
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/scoreboard.collection"
|
||||||
|
:scene
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/level3.script"
|
||||||
:code
|
:code
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
|
@ -23,15 +34,35 @@
|
||||||
:code
|
:code
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
"/main/level1.collection"
|
"/main/level3.collection"
|
||||||
:scene
|
:scene
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
"/main/player.script"
|
"/main/graphics.atlas"
|
||||||
|
:scene
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/debug.gui"
|
||||||
|
:scene
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/entername.gui"
|
||||||
|
:scene
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/entername.gui_script"
|
||||||
:code
|
:code
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
"/main/curse.script"
|
"/main/score.gui_script"
|
||||||
|
:code
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/scoreboard.gui_script"
|
||||||
|
:code
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/startscreen.gui_script"
|
||||||
:code
|
:code
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
|
@ -39,7 +70,39 @@
|
||||||
:scene
|
:scene
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
"/main/level3.collection"
|
"/main/level1.script"
|
||||||
|
:code
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/player.script"
|
||||||
|
:code
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/level1.collection"
|
||||||
|
:scene
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/settings.gui"
|
||||||
|
:scene
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/settings.collection"
|
||||||
|
:scene
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/curse.script"
|
||||||
|
:code
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/settings.gui_script"
|
||||||
|
:code
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/main.script"
|
||||||
|
:code
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"/main/main.collection"
|
||||||
:scene
|
:scene
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
|
||||||
BIN
Sounds/mixkit-arcade-retro-game-over-213.wav
Normal file
BIN
Sounds/mixkit-arcade-retro-game-over-213.wav
Normal file
Binary file not shown.
BIN
Sounds/mixkit-player-jumping-in-a-video-game-2043.wav
Normal file
BIN
Sounds/mixkit-player-jumping-in-a-video-game-2043.wav
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
šr
|
–x
|
||||||
‚rlocal Movement = {
|
þwlocal Movement = {
|
||||||
STILL_LEFT = "STILL_LEFT",
|
STILL_LEFT = "STILL_LEFT",
|
||||||
STILL_RIGHT = "STILL_RIGHT",
|
STILL_RIGHT = "STILL_RIGHT",
|
||||||
MOVING_LEFT = "MOVING_LEFT",
|
MOVING_LEFT = "MOVING_LEFT",
|
||||||
|
|
@ -123,6 +123,7 @@ function init(self)
|
||||||
self.paused = false
|
self.paused = false
|
||||||
|
|
||||||
self.current_movement = Movement.STILL_RIGHT
|
self.current_movement = Movement.STILL_RIGHT
|
||||||
|
self.current_level = "level1"
|
||||||
|
|
||||||
go.set_position(vmath.vector3(100,100,0.2))
|
go.set_position(vmath.vector3(100,100,0.2))
|
||||||
end
|
end
|
||||||
|
|
@ -245,8 +246,18 @@ function update(self, dt)
|
||||||
elseif pos.x > 1030 then
|
elseif pos.x > 1030 then
|
||||||
pos.x = 1030
|
pos.x = 1030
|
||||||
end
|
end
|
||||||
if pos.y < 0 then
|
--if pos.y < 0 then
|
||||||
|
--pos.y = 100
|
||||||
|
--end
|
||||||
|
if pos.y < -20 then
|
||||||
pos.y = 100
|
pos.y = 100
|
||||||
|
pos.x = 100
|
||||||
|
msg.post("main:/controller#main", "LifeLost")
|
||||||
|
self.current_movement = Movement.MOVING_RIGHT
|
||||||
|
handleInput(self, Actions.RIGHT_ARROW_RELEASE)
|
||||||
|
go.set_position(vmath.vector3(100,100,0.2))
|
||||||
|
self.regenerating = true
|
||||||
|
self.regen_timer = 3
|
||||||
end
|
end
|
||||||
|
|
||||||
local centre = vmath.vector3(pos.x, pos.y - 10, 0)
|
local centre = vmath.vector3(pos.x, pos.y - 10, 0)
|
||||||
|
|
@ -359,6 +370,7 @@ function on_message(self, message_id, message, sender)
|
||||||
self.amulet_timer = 5
|
self.amulet_timer = 5
|
||||||
msg.post("holding_amulet", "enable_sprite")
|
msg.post("holding_amulet", "enable_sprite")
|
||||||
--print("collision with amulet")
|
--print("collision with amulet")
|
||||||
|
msg.post("main:/controller#main", "play amulet sound")
|
||||||
end
|
end
|
||||||
if message.group == hash("mummy") then
|
if message.group == hash("mummy") then
|
||||||
msg.post("main:/controller#main", "LevelCompleted")
|
msg.post("main:/controller#main", "LevelCompleted")
|
||||||
|
|
@ -369,7 +381,7 @@ function on_message(self, message_id, message, sender)
|
||||||
if message.dying == false then
|
if message.dying == false then
|
||||||
msg.post("/holding_amulet#holdingamulet", "disable_sprite")
|
msg.post("/holding_amulet#holdingamulet", "disable_sprite")
|
||||||
msg.post("main:/controller#main", "LifeLost")
|
msg.post("main:/controller#main", "LifeLost")
|
||||||
|
msg.post("main:/controller#main", "play dying sound")
|
||||||
--else
|
--else
|
||||||
self.current_movement = Movement.MOVING_RIGHT
|
self.current_movement = Movement.MOVING_RIGHT
|
||||||
handleInput(self, Actions.RIGHT_ARROW_RELEASE)
|
handleInput(self, Actions.RIGHT_ARROW_RELEASE)
|
||||||
|
|
@ -385,6 +397,13 @@ function on_message(self, message_id, message, sender)
|
||||||
if message_id == hash("unpause") then
|
if message_id == hash("unpause") then
|
||||||
self.paused = false
|
self.paused = false
|
||||||
end
|
end
|
||||||
|
if message_id == hash("level1") then
|
||||||
|
self.current_level = "level1"
|
||||||
|
elseif message_id == hash("level2") then
|
||||||
|
self.current_level = "level2"
|
||||||
|
elseif message_id == hash("level3") then
|
||||||
|
self.current_level = "level3"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_input(self, action_id, action)
|
function on_input(self, action_id, action)
|
||||||
|
|
@ -409,7 +428,9 @@ function on_input(self, action_id, action)
|
||||||
end
|
end
|
||||||
if action_id == hash("jump") and action.pressed and not self.jumped and not self.climbing then
|
if action_id == hash("jump") and action.pressed and not self.jumped and not self.climbing then
|
||||||
self.velocity.y = self.jump_velocity
|
self.velocity.y = self.jump_velocity
|
||||||
self.speed = 500
|
if self.current_level == "level2" or self.current_level == "level3" then
|
||||||
|
self.speed = 500
|
||||||
|
end
|
||||||
self.jumped = true
|
self.jumped = true
|
||||||
end
|
end
|
||||||
if action_id == hash("climb_up") then
|
if action_id == hash("climb_up") then
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
BIN
graphics/music.png
Normal file
BIN
graphics/music.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
BIN
graphics/slider.png
Normal file
BIN
graphics/slider.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 399 B |
BIN
graphics/slider_bar.png
Normal file
BIN
graphics/slider_bar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 592 B |
BIN
graphics/sound.png
Normal file
BIN
graphics/sound.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
BIN
graphics/volume.png
Normal file
BIN
graphics/volume.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
|
|
@ -16,6 +16,10 @@ embedded_instances {
|
||||||
" texture: \\\"/main/graphics.atlas\\\"\\n"
|
" texture: \\\"/main/graphics.atlas\\\"\\n"
|
||||||
"}\\n"
|
"}\\n"
|
||||||
"\"\n"
|
"\"\n"
|
||||||
|
" scale {\n"
|
||||||
|
" x: 1.17877\n"
|
||||||
|
" y: 1.169797\n"
|
||||||
|
" }\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ nodes {
|
||||||
z: 1.0
|
z: 1.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.7
|
x: 0.9
|
||||||
y: 0.7
|
y: 0.9
|
||||||
}
|
}
|
||||||
size {
|
size {
|
||||||
x: 200.0
|
x: 200.0
|
||||||
|
|
@ -32,13 +32,13 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 794.0
|
x: 825.0
|
||||||
y: 302.0
|
y: 200.0
|
||||||
z: 1.0
|
z: 1.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.7
|
x: 0.9
|
||||||
y: 0.7
|
y: 0.9
|
||||||
}
|
}
|
||||||
size {
|
size {
|
||||||
x: 200.0
|
x: 200.0
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ function init(self)
|
||||||
-- Learn more: https://defold.com/manuals/script/
|
-- Learn more: https://defold.com/manuals/script/
|
||||||
-- Remove this function if not needed
|
-- Remove this function if not needed
|
||||||
local node = gui.get_node("enter")
|
local node = gui.get_node("enter")
|
||||||
gui.set_position(node, vmath.vector3(450,250,1))
|
gui.set_position(node, vmath.vector3(425,200,1))
|
||||||
gui.set_color(gui.get_node("enter"), vmath.vector4(0.4118, 0.2863, 0.0706, 1.0))
|
gui.set_color(gui.get_node("enter"), vmath.vector4(0.4118, 0.2863, 0.0706, 1.0))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,21 @@ images {
|
||||||
images {
|
images {
|
||||||
image: "/graphics/platformsegmentup.png"
|
image: "/graphics/platformsegmentup.png"
|
||||||
}
|
}
|
||||||
|
images {
|
||||||
|
image: "/graphics/music.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/graphics/slider.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/graphics/slider_bar.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/graphics/sound.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/graphics/volume.png"
|
||||||
|
}
|
||||||
animations {
|
animations {
|
||||||
id: "run_left"
|
id: "run_left"
|
||||||
images {
|
images {
|
||||||
|
|
|
||||||
|
|
@ -760,3 +760,19 @@ embedded_instances {
|
||||||
"}\n"
|
"}\n"
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "sound"
|
||||||
|
data: "embedded_components {\n"
|
||||||
|
" id: \"amulet_sound\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/Sounds/mixkit-player-jumping-in-a-video-game-2043.wav\\\"\\n"
|
||||||
|
"\"\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"dying_sound\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/Sounds/mixkit-arcade-retro-game-over-213.wav\\\"\\n"
|
||||||
|
"\"\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ function init(self)
|
||||||
|
|
||||||
createamulets(self)
|
createamulets(self)
|
||||||
msg.post("level1:/pause#sprite", "disable")
|
msg.post("level1:/pause#sprite", "disable")
|
||||||
|
msg.post("/player#player", "level1")
|
||||||
|
print("level1")
|
||||||
end
|
end
|
||||||
|
|
||||||
function createamulets(self)
|
function createamulets(self)
|
||||||
|
|
|
||||||
|
|
@ -1482,3 +1482,19 @@ embedded_instances {
|
||||||
"}\n"
|
"}\n"
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "sound"
|
||||||
|
data: "embedded_components {\n"
|
||||||
|
" id: \"amulet_sound\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/Sounds/mixkit-player-jumping-in-a-video-game-2043.wav\\\"\\n"
|
||||||
|
"\"\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"dying_sound\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/Sounds/mixkit-arcade-retro-game-over-213.wav\\\"\\n"
|
||||||
|
"\"\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ function init(self)
|
||||||
|
|
||||||
createamulets(self)
|
createamulets(self)
|
||||||
msg.post("level2:/pause#sprite", "disable")
|
msg.post("level2:/pause#sprite", "disable")
|
||||||
|
msg.post("/player#player", "level2")
|
||||||
|
print("level2")
|
||||||
end
|
end
|
||||||
|
|
||||||
function createamulets(self)
|
function createamulets(self)
|
||||||
|
|
|
||||||
|
|
@ -1619,3 +1619,19 @@ embedded_instances {
|
||||||
"}\n"
|
"}\n"
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "sound"
|
||||||
|
data: "embedded_components {\n"
|
||||||
|
" id: \"amulet_sound\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/Sounds/mixkit-player-jumping-in-a-video-game-2043.wav\\\"\\n"
|
||||||
|
"\"\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"dying_sound\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/Sounds/mixkit-arcade-retro-game-over-213.wav\\\"\\n"
|
||||||
|
"\"\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ function init(self)
|
||||||
|
|
||||||
createamulets(self)
|
createamulets(self)
|
||||||
msg.post("level3:/pause#sprite", "disable")
|
msg.post("level3:/pause#sprite", "disable")
|
||||||
|
msg.post("/player#player", "level3")
|
||||||
|
print("level3")
|
||||||
end
|
end
|
||||||
|
|
||||||
function createamulets(self)
|
function createamulets(self)
|
||||||
|
|
|
||||||
|
|
@ -148,3 +148,20 @@ embedded_instances {
|
||||||
"}\n"
|
"}\n"
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "sound"
|
||||||
|
data: "embedded_components {\n"
|
||||||
|
" id: \"amulet_sound\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/Sounds/mixkit-player-jumping-in-a-video-game-2043.wav\\\"\\n"
|
||||||
|
"looping: 1\\n"
|
||||||
|
"\"\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"dying_sound\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/Sounds/mixkit-arcade-retro-game-over-213.wav\\\"\\n"
|
||||||
|
"\"\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@ function init(self)
|
||||||
-- show the title screen when the game is loaded
|
-- show the title screen when the game is loaded
|
||||||
|
|
||||||
msg.post("#startscreen_proxy", "load")
|
msg.post("#startscreen_proxy", "load")
|
||||||
-- msg.post("#level2_proxy", "load")
|
|
||||||
self.collection_to_load = ""
|
self.collection_to_load = ""
|
||||||
self.current_collection = "#startscreen_proxy"
|
self.current_collection = "#startscreen_proxy"
|
||||||
-- self.current_collection = "#level2_proxy"
|
|
||||||
|
|
||||||
--msg.post("#level2_proxy", "load")
|
--msg.post("#level2_proxy", "load")
|
||||||
--self.collection_to_load = ""
|
--self.collection_to_load = ""
|
||||||
|
|
@ -35,6 +33,8 @@ function init(self)
|
||||||
self.current_level = "level1"
|
self.current_level = "level1"
|
||||||
self.current_score = 0
|
self.current_score = 0
|
||||||
self.hide_banner = true
|
self.hide_banner = true
|
||||||
|
|
||||||
|
self.volume = 717
|
||||||
end
|
end
|
||||||
|
|
||||||
function final(self)
|
function final(self)
|
||||||
|
|
@ -66,6 +66,9 @@ function on_message(self, message_id, message, sender)
|
||||||
if message_id == hash("proxy_loaded") then
|
if message_id == hash("proxy_loaded") then
|
||||||
msg.post(sender, "enable")
|
msg.post(sender, "enable")
|
||||||
-- load the correct collection when a message is received
|
-- load the correct collection when a message is received
|
||||||
|
if self.current_collection == "#settings_proxy" then
|
||||||
|
msg.post("settings:/background#settings1", "new_volume", { new_volume = self.volume })
|
||||||
|
end
|
||||||
elseif message_id == hash("show level1 screen") then
|
elseif message_id == hash("show level1 screen") then
|
||||||
-- title screen
|
-- title screen
|
||||||
msg.post(self.current_collection, "unload")
|
msg.post(self.current_collection, "unload")
|
||||||
|
|
@ -74,7 +77,7 @@ function on_message(self, message_id, message, sender)
|
||||||
self.current_lives = 3
|
self.current_lives = 3
|
||||||
self.current_level = "level1"
|
self.current_level = "level1"
|
||||||
self.hide_banner = false
|
self.hide_banner = false
|
||||||
--load game over scsreen when character is dead
|
--load game over screen when character is dead
|
||||||
elseif message_id == hash("NoMoreLives") then
|
elseif message_id == hash("NoMoreLives") then
|
||||||
self.hide_banner = true
|
self.hide_banner = true
|
||||||
local show_gameover = true
|
local show_gameover = true
|
||||||
|
|
@ -144,6 +147,14 @@ function on_message(self, message_id, message, sender)
|
||||||
elseif message_id == hash("add 100 points") then
|
elseif message_id == hash("add 100 points") then
|
||||||
self.current_score = self.current_score + 100
|
self.current_score = self.current_score + 100
|
||||||
--print(self.current_score)
|
--print(self.current_score)
|
||||||
|
elseif message_id == hash("play amulet sound") then
|
||||||
|
sound.play("sound#amulet_sound", {loopcount = 0, speed = 1, gain = (self.volume - 547)/(887 - 547)})
|
||||||
|
elseif message_id == hash("play dying sound") then
|
||||||
|
sound.play("sound#dying_sound", {speed = 1, gain = (self.volume - 547)/(887 - 547)})
|
||||||
|
elseif message_id == hash("new_volume") then
|
||||||
|
self.volume = message.new_volume
|
||||||
|
local scaled_volume = (self.volume - 547)/(887 - 547)
|
||||||
|
sound.set_group_gain("sounds", scaled_volume)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ function init(self)
|
||||||
self.paused = false
|
self.paused = false
|
||||||
|
|
||||||
self.current_movement = Movement.STILL_RIGHT
|
self.current_movement = Movement.STILL_RIGHT
|
||||||
|
self.current_level = "level1"
|
||||||
|
|
||||||
go.set_position(vmath.vector3(100,100,0.2))
|
go.set_position(vmath.vector3(100,100,0.2))
|
||||||
end
|
end
|
||||||
|
|
@ -243,8 +244,18 @@ function update(self, dt)
|
||||||
elseif pos.x > 1030 then
|
elseif pos.x > 1030 then
|
||||||
pos.x = 1030
|
pos.x = 1030
|
||||||
end
|
end
|
||||||
if pos.y < 0 then
|
--if pos.y < 0 then
|
||||||
|
--pos.y = 100
|
||||||
|
--end
|
||||||
|
if pos.y < -20 then
|
||||||
pos.y = 100
|
pos.y = 100
|
||||||
|
pos.x = 100
|
||||||
|
msg.post("main:/controller#main", "LifeLost")
|
||||||
|
self.current_movement = Movement.MOVING_RIGHT
|
||||||
|
handleInput(self, Actions.RIGHT_ARROW_RELEASE)
|
||||||
|
go.set_position(vmath.vector3(100,100,0.2))
|
||||||
|
self.regenerating = true
|
||||||
|
self.regen_timer = 3
|
||||||
end
|
end
|
||||||
|
|
||||||
local centre = vmath.vector3(pos.x, pos.y - 10, 0)
|
local centre = vmath.vector3(pos.x, pos.y - 10, 0)
|
||||||
|
|
@ -357,6 +368,7 @@ function on_message(self, message_id, message, sender)
|
||||||
self.amulet_timer = 5
|
self.amulet_timer = 5
|
||||||
msg.post("holding_amulet", "enable_sprite")
|
msg.post("holding_amulet", "enable_sprite")
|
||||||
--print("collision with amulet")
|
--print("collision with amulet")
|
||||||
|
msg.post("main:/controller#main", "play amulet sound")
|
||||||
end
|
end
|
||||||
if message.group == hash("mummy") then
|
if message.group == hash("mummy") then
|
||||||
msg.post("main:/controller#main", "LevelCompleted")
|
msg.post("main:/controller#main", "LevelCompleted")
|
||||||
|
|
@ -367,7 +379,7 @@ function on_message(self, message_id, message, sender)
|
||||||
if message.dying == false then
|
if message.dying == false then
|
||||||
msg.post("/holding_amulet#holdingamulet", "disable_sprite")
|
msg.post("/holding_amulet#holdingamulet", "disable_sprite")
|
||||||
msg.post("main:/controller#main", "LifeLost")
|
msg.post("main:/controller#main", "LifeLost")
|
||||||
|
msg.post("main:/controller#main", "play dying sound")
|
||||||
--else
|
--else
|
||||||
self.current_movement = Movement.MOVING_RIGHT
|
self.current_movement = Movement.MOVING_RIGHT
|
||||||
handleInput(self, Actions.RIGHT_ARROW_RELEASE)
|
handleInput(self, Actions.RIGHT_ARROW_RELEASE)
|
||||||
|
|
@ -383,6 +395,13 @@ function on_message(self, message_id, message, sender)
|
||||||
if message_id == hash("unpause") then
|
if message_id == hash("unpause") then
|
||||||
self.paused = false
|
self.paused = false
|
||||||
end
|
end
|
||||||
|
if message_id == hash("level1") then
|
||||||
|
self.current_level = "level1"
|
||||||
|
elseif message_id == hash("level2") then
|
||||||
|
self.current_level = "level2"
|
||||||
|
elseif message_id == hash("level3") then
|
||||||
|
self.current_level = "level3"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_input(self, action_id, action)
|
function on_input(self, action_id, action)
|
||||||
|
|
@ -407,7 +426,9 @@ function on_input(self, action_id, action)
|
||||||
end
|
end
|
||||||
if action_id == hash("jump") and action.pressed and not self.jumped and not self.climbing then
|
if action_id == hash("jump") and action.pressed and not self.jumped and not self.climbing then
|
||||||
self.velocity.y = self.jump_velocity
|
self.velocity.y = self.jump_velocity
|
||||||
self.speed = 500
|
if self.current_level == "level2" or self.current_level == "level3" then
|
||||||
|
self.speed = 500
|
||||||
|
end
|
||||||
self.jumped = true
|
self.jumped = true
|
||||||
end
|
end
|
||||||
if action_id == hash("climb_up") then
|
if action_id == hash("climb_up") then
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ fonts {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 433.0
|
y: 446.0
|
||||||
z: 1.0
|
z: 1.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
|
|
@ -29,8 +29,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 403.0
|
y: 406.0
|
||||||
z: 1.0
|
z: 1.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
|
|
@ -49,8 +49,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 373.0
|
y: 366.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.4
|
x: 0.4
|
||||||
|
|
@ -68,8 +68,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 343.0
|
y: 326.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.4
|
x: 0.4
|
||||||
|
|
@ -87,8 +87,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 313.0
|
y: 286.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.4
|
x: 0.4
|
||||||
|
|
@ -106,8 +106,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 283.0
|
y: 246.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.4
|
x: 0.4
|
||||||
|
|
@ -125,8 +125,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 253.0
|
y: 206.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.4
|
x: 0.4
|
||||||
|
|
@ -144,8 +144,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 223.0
|
y: 166.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.4
|
x: 0.4
|
||||||
|
|
@ -163,8 +163,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 193.0
|
y: 126.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.4
|
x: 0.4
|
||||||
|
|
@ -182,8 +182,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 669.0
|
x: 627.5
|
||||||
y: 163.0
|
y: 86.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.4
|
x: 0.4
|
||||||
|
|
@ -201,8 +201,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 431.0
|
y: 442.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -220,8 +220,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 401.0
|
y: 402.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -239,8 +239,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 371.0
|
y: 362.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -258,8 +258,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 341.0
|
y: 322.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -277,8 +277,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 311.0
|
y: 282.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -296,8 +296,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 281.0
|
y: 242.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -315,8 +315,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 251.0
|
y: 202.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -334,8 +334,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 221.0
|
y: 162.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -353,8 +353,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 191.0
|
y: 122.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
@ -372,8 +372,8 @@ nodes {
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
position {
|
position {
|
||||||
x: 423.0
|
x: 427.5
|
||||||
y: 161.0
|
y: 82.0
|
||||||
}
|
}
|
||||||
scale {
|
scale {
|
||||||
x: 0.55
|
x: 0.55
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@ embedded_instances {
|
||||||
" id: \"settings\"\n"
|
" id: \"settings\"\n"
|
||||||
" component: \"/main/settings.script\"\n"
|
" component: \"/main/settings.script\"\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
"components {\n"
|
||||||
|
" id: \"settings1\"\n"
|
||||||
|
" component: \"/main/settings.gui\"\n"
|
||||||
|
"}\n"
|
||||||
"embedded_components {\n"
|
"embedded_components {\n"
|
||||||
" id: \"sprite\"\n"
|
" id: \"sprite\"\n"
|
||||||
" type: \"sprite\"\n"
|
" type: \"sprite\"\n"
|
||||||
|
|
@ -21,5 +25,25 @@ embedded_instances {
|
||||||
" y: 345.0\n"
|
" y: 345.0\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"sprite1\"\n"
|
||||||
|
" type: \"sprite\"\n"
|
||||||
|
" data: \"default_animation: \\\"volume\\\"\\n"
|
||||||
|
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
|
||||||
|
"textures {\\n"
|
||||||
|
" sampler: \\\"texture_sampler\\\"\\n"
|
||||||
|
" texture: \\\"/main/graphics.atlas\\\"\\n"
|
||||||
|
"}\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 522.0\n"
|
||||||
|
" y: 450.0\n"
|
||||||
|
" z: 0.1\n"
|
||||||
|
" }\n"
|
||||||
|
" scale {\n"
|
||||||
|
" x: 0.4\n"
|
||||||
|
" y: 0.4\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
100
main/settings.gui
Normal file
100
main/settings.gui
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
script: "/main/settings.gui_script"
|
||||||
|
textures {
|
||||||
|
name: "graphics"
|
||||||
|
texture: "/main/graphics.atlas"
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 311.0
|
||||||
|
y: 341.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 0.5
|
||||||
|
y: 0.5
|
||||||
|
}
|
||||||
|
type: TYPE_BOX
|
||||||
|
texture: "graphics/sound"
|
||||||
|
id: "sound"
|
||||||
|
inherit_alpha: true
|
||||||
|
size_mode: SIZE_MODE_AUTO
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 717.0
|
||||||
|
y: 339.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 0.4
|
||||||
|
y: 0.4
|
||||||
|
}
|
||||||
|
type: TYPE_BOX
|
||||||
|
texture: "graphics/slider_bar"
|
||||||
|
id: "sound_slider"
|
||||||
|
inherit_alpha: true
|
||||||
|
size_mode: SIZE_MODE_AUTO
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 719.0
|
||||||
|
y: 341.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 0.4
|
||||||
|
y: 0.4
|
||||||
|
}
|
||||||
|
type: TYPE_BOX
|
||||||
|
texture: "graphics/slider"
|
||||||
|
id: "sound_bar"
|
||||||
|
inherit_alpha: true
|
||||||
|
size_mode: SIZE_MODE_AUTO
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 311.0
|
||||||
|
y: 208.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 0.483616
|
||||||
|
y: 0.483616
|
||||||
|
z: 0.967232
|
||||||
|
}
|
||||||
|
type: TYPE_BOX
|
||||||
|
texture: "graphics/music"
|
||||||
|
id: "music"
|
||||||
|
inherit_alpha: true
|
||||||
|
size_mode: SIZE_MODE_AUTO
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 717.0
|
||||||
|
y: 206.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 0.386893
|
||||||
|
y: 0.386893
|
||||||
|
z: 0.967232
|
||||||
|
}
|
||||||
|
type: TYPE_BOX
|
||||||
|
texture: "graphics/slider_bar"
|
||||||
|
id: "music_slider"
|
||||||
|
inherit_alpha: true
|
||||||
|
size_mode: SIZE_MODE_AUTO
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 719.0
|
||||||
|
y: 208.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 0.386893
|
||||||
|
y: 0.386893
|
||||||
|
z: 0.967232
|
||||||
|
}
|
||||||
|
type: TYPE_BOX
|
||||||
|
texture: "graphics/slider"
|
||||||
|
id: "music_bar"
|
||||||
|
inherit_alpha: true
|
||||||
|
size_mode: SIZE_MODE_AUTO
|
||||||
|
}
|
||||||
|
material: "/builtins/materials/gui.material"
|
||||||
|
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||||
46
main/settings.gui_script
Normal file
46
main/settings.gui_script
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
function init(self)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function final(self)
|
||||||
|
-- Add finalization code here
|
||||||
|
-- Learn more: https://defold.com/manuals/script/
|
||||||
|
-- Remove this function if not needed
|
||||||
|
end
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
--gui.set_position(gui.get_node("sound_bar"), pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
if message_id == hash("new_volume") then
|
||||||
|
self.volume = message.new_volume
|
||||||
|
local volume_pos = gui.get_position(gui.get_node("sound_bar"))
|
||||||
|
gui.set_position(gui.get_node("sound_bar"), vmath.vector3(self.volume, volume_pos.y, volume_pos.z))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
if action_id == hash("touch") and action.pressed then
|
||||||
|
if gui.pick_node(gui.get_node("sound_bar"), action.x, action.y) then
|
||||||
|
self.dragging = true
|
||||||
|
end
|
||||||
|
elseif action.released then
|
||||||
|
self.dragging = false
|
||||||
|
end
|
||||||
|
if self.dragging then
|
||||||
|
local volume_pos = gui.get_position(gui.get_node("sound_bar"))
|
||||||
|
if action.x >= 547 and action.x <= 887 then
|
||||||
|
gui.set_position(gui.get_node("sound_bar"), vmath.vector3(action.x, volume_pos.y, volume_pos.z))
|
||||||
|
msg.post("main:/controller#main", "new_volume", { new_volume = action.x })
|
||||||
|
end
|
||||||
|
-- print(volume)
|
||||||
|
-- msg.post("main:/controller#main", "set_volume", { volume = volume })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_reload(self)
|
||||||
|
-- Add reload-handling code here
|
||||||
|
-- Learn more: https://defold.com/manuals/hot-reload/
|
||||||
|
-- Remove this function if not needed
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue