Level pre screens

This commit is contained in:
Heather 2025-08-27 01:05:31 +01:00
parent 20ccd7debc
commit 3b98017aa7
22 changed files with 343 additions and 36 deletions

View file

@ -9,14 +9,6 @@
}
:workflow {
:recent-files [
[
"/main/curses.collection"
:scene
]
[
"/main/mummy.script"
:code
]
[
"/main/entername.collection"
:scene
@ -29,10 +21,6 @@
"/main/level3.collection"
:scene
]
[
"/main/graphics.atlas"
:scene
]
[
"/main/debug.gui"
:scene
@ -53,10 +41,6 @@
"/main/scoreboard.gui_script"
:code
]
[
"/main/startscreen.gui_script"
:code
]
[
"/main/level2.collection"
:scene
@ -65,14 +49,6 @@
"/main/level1.collection"
:scene
]
[
"/main/level2.script"
:code
]
[
"/main/level3.script"
:code
]
[
"/main/settings.gui"
:scene
@ -86,29 +62,81 @@
:code
]
[
"/main/level1.script"
"/main/holdingamulet.script"
:code
]
[
"/main/holdingamulet.script"
"/main/player.script"
:code
]
[
"/main/graphics.atlas"
:scene
]
[
"/main/main.collection"
:scene
]
[
"/main/startscreen.gui_script"
:code
]
[
"/main/button.gui_script"
:code
]
[
"/main/level2.script"
:code
]
[
"/main/level3.script"
:code
]
[
"/main/curse.script"
:code
]
[
"/main/level1.script"
:code
]
[
"/main/entername.script"
:code
]
[
"/main/level1prescreen.collection"
:scene
]
[
"/main/level1prescreen.script"
:code
]
[
"/main/level2prescreen_copy.collection"
:scene
]
[
"/main/level3prescreen.script"
:code
]
[
"/main/level2prescreen.script"
:code
]
[
"/main/startscreen.script"
:code
]
[
"/main/main.script"
:code
]
[
"/main/main.collection"
"/main/level2prescreen.collection"
:scene
]
[
"/main/player.script"
:code
]
]
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

BIN
graphics/level1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
graphics/level2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
graphics/level3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View file

@ -23,7 +23,7 @@ end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
if gui.pick_node(gui.get_node("button_level1"), action.x, action.y) then
msg.post("main:/controller#main", "show level1 screen")
msg.post("main:/controller#main", "show level1prescreen")
elseif gui.pick_node(gui.get_node("button_scoreboard"), action.x, action.y) then
msg.post("main:/controller#main", "show scoreboard screen")
end

View file

@ -103,6 +103,15 @@ images {
images {
image: "/graphics/volume.png"
}
images {
image: "/graphics/level1.png"
}
images {
image: "/graphics/level2.png"
}
images {
image: "/graphics/level3.png"
}
animations {
id: "run_left"
images {

View file

@ -0,0 +1,25 @@
name: "level1prescreen"
scale_along_z: 0
embedded_instances {
id: "background"
data: "components {\n"
" id: \"level1prescreen\"\n"
" component: \"/main/level1prescreen.script\"\n"
"}\n"
"embedded_components {\n"
" id: \"sprite\"\n"
" type: \"sprite\"\n"
" data: \"default_animation: \\\"level1\\\"\\n"
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
"textures {\\n"
" sampler: \\\"texture_sampler\\\"\\n"
" texture: \\\"/main/graphics.atlas\\\"\\n"
"}\\n"
"\"\n"
" scale {\n"
" x: 1.0125\n"
" y: 1.005\n"
" }\n"
"}\n"
""
}

View file

@ -0,0 +1,52 @@
function init(self)
self.timer = 2
go.set_position(vmath.vector3(527.5,348,0), "background")
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)
if self.timer > 0 then
self.timer = self.timer - dt
elseif self.timer < 0 and self.timer > -1 then
msg.post("main:/controller#main", "show level1 screen")
self.timer = -1
end
end
function fixed_update(self, dt)
-- This function is called if 'Fixed Update Frequency' is enabled in the Engine section of game.project
-- Can be coupled with fixed updates of the physics simulation if 'Use Fixed Timestep' is enabled in
-- Physics section of game.project
-- Add update code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Learn more: https://defold.com/manuals/message-passing/
-- Remove this function if not needed
end
function on_input(self, action_id, action)
-- Add input-handling code here. The game object this script is attached to
-- must have acquired input focus:
--
-- msg.post(".", "acquire_input_focus")
--
-- All mapped input bindings will be received. Mouse and touch input will
-- be received regardless of where on the screen it happened.
-- Learn more: https://defold.com/manuals/input/
-- Remove this function if not needed
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

View file

@ -0,0 +1,24 @@
name: "level2prescreen"
scale_along_z: 0
embedded_instances {
id: "background"
data: "components {\n"
" id: \"level2prescreen\"\n"
" component: \"/main/level2prescreen.script\"\n"
"}\n"
"embedded_components {\n"
" id: \"sprite\"\n"
" type: \"sprite\"\n"
" data: \"default_animation: \\\"level2\\\"\\n"
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
"textures {\\n"
" sampler: \\\"texture_sampler\\\"\\n"
" texture: \\\"/main/graphics.atlas\\\"\\n"
"}\\n"
"\"\n"
" position {\n"
" z: 0.7\n"
" }\n"
"}\n"
""
}

View file

@ -0,0 +1,52 @@
function init(self)
self.timer = 2
go.set_position(vmath.vector3(527.5,348,0), "background")
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)
if self.timer > 0 then
self.timer = self.timer - dt
elseif self.timer < 0 and self.timer > -1 then
msg.post("main:/controller#main", "show level2 screen")
self.timer = -1
end
end
function fixed_update(self, dt)
-- This function is called if 'Fixed Update Frequency' is enabled in the Engine section of game.project
-- Can be coupled with fixed updates of the physics simulation if 'Use Fixed Timestep' is enabled in
-- Physics section of game.project
-- Add update code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Learn more: https://defold.com/manuals/message-passing/
-- Remove this function if not needed
end
function on_input(self, action_id, action)
-- Add input-handling code here. The game object this script is attached to
-- must have acquired input focus:
--
-- msg.post(".", "acquire_input_focus")
--
-- All mapped input bindings will be received. Mouse and touch input will
-- be received regardless of where on the screen it happened.
-- Learn more: https://defold.com/manuals/input/
-- Remove this function if not needed
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

View file

@ -0,0 +1,24 @@
name: "level3prescreen"
scale_along_z: 0
embedded_instances {
id: "background"
data: "components {\n"
" id: \"level3prescreen\"\n"
" component: \"/main/level3prescreen.script\"\n"
"}\n"
"embedded_components {\n"
" id: \"sprite\"\n"
" type: \"sprite\"\n"
" data: \"default_animation: \\\"level3\\\"\\n"
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
"textures {\\n"
" sampler: \\\"texture_sampler\\\"\\n"
" texture: \\\"/main/graphics.atlas\\\"\\n"
"}\\n"
"\"\n"
" position {\n"
" z: 0.7\n"
" }\n"
"}\n"
""
}

View file

@ -0,0 +1,52 @@
function init(self)
self.timer = 2
go.set_position(vmath.vector3(527.5,348,0), "background")
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)
if self.timer > 0 then
self.timer = self.timer - dt
elseif self.timer < 0 and self.timer > -1 then
msg.post("main:/controller#main", "show level3 screen")
self.timer = -1
end
end
function fixed_update(self, dt)
-- This function is called if 'Fixed Update Frequency' is enabled in the Engine section of game.project
-- Can be coupled with fixed updates of the physics simulation if 'Use Fixed Timestep' is enabled in
-- Physics section of game.project
-- Add update code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Learn more: https://defold.com/manuals/message-passing/
-- Remove this function if not needed
end
function on_input(self, action_id, action)
-- Add input-handling code here. The game object this script is attached to
-- must have acquired input focus:
--
-- msg.post(".", "acquire_input_focus")
--
-- All mapped input bindings will be received. Mouse and touch input will
-- be received regardless of where on the screen it happened.
-- Learn more: https://defold.com/manuals/input/
-- Remove this function if not needed
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

View file

@ -60,6 +60,24 @@ embedded_instances {
" data: \"collection: \\\"/main/level3.collection\\\"\\n"
"\"\n"
"}\n"
"embedded_components {\n"
" id: \"level1prescreen_proxy\"\n"
" type: \"collectionproxy\"\n"
" data: \"collection: \\\"/main/level1prescreen.collection\\\"\\n"
"\"\n"
"}\n"
"embedded_components {\n"
" id: \"level2prescreen_proxy\"\n"
" type: \"collectionproxy\"\n"
" data: \"collection: \\\"/main/level2prescreen.collection\\\"\\n"
"\"\n"
"}\n"
"embedded_components {\n"
" id: \"level3prescreen_proxy\"\n"
" type: \"collectionproxy\"\n"
" data: \"collection: \\\"/main/level3prescreen.collection\\\"\\n"
"\"\n"
"}\n"
""
}
embedded_instances {

View file

@ -108,35 +108,54 @@ function on_message(self, message_id, message, sender)
elseif message_id == hash("show scoreboard screen") then
msg.post(self.current_collection, "unload")
self.collection_to_load = "#scoreboard_proxy"
elseif message_id == hash("show instructions screen") then
-- instructions screen
msg.post(self.current_collection, "unload")
self.collection_to_load = "#instructions_proxy"
elseif message_id == hash("show settings screen") then
-- settings screen
msg.post(self.current_collection, "unload")
self.collection_to_load = "#settings_proxy"
elseif message_id == hash("escape") then
msg.post(self.current_collection, "unload")
self.collection_to_load = "#startscreen_proxy"
elseif message_id == hash("show level1prescreen") then
msg.post(self.current_collection, "unload")
self.collection_to_load = "#level1prescreen_proxy"
elseif message_id == hash("show level2 screen") then
msg.post(self.current_collection, "unload")
self.collection_to_load = "#level2_proxy"
elseif message_id == hash("show level3 screen") then
msg.post(self.current_collection, "unload")
self.collection_to_load = "#level3_proxy"
elseif message_id == hash("send_table") then
msg.post("scoreboard:/scoreboard#scoreboard", "highscore_table", { high_scores = self.highscore_table})
elseif message_id == hash("save_name") then
self.highscore_table[self.highscore_position][1] = message.name
local my_file_path = sys.get_save_file("cursegame", "high_scores")
sys.save(my_file_path, self.highscore_table)
msg.post(self.current_collection, "unload")
self.collection_to_load = "#scoreboard_proxy"
elseif message_id == hash("LevelCompleted") then
if self.current_collection == "#level1_proxy" then
self.current_level = "level2"
msg.post(self.current_collection, "unload")
self.collection_to_load = "#level2_proxy"
self.collection_to_load = "#level2prescreen_proxy"
elseif self.current_collection == "#level2_proxy" then
self.current_level = "level3"
msg.post(self.current_collection, "unload")
self.collection_to_load = "#level3_proxy"
self.collection_to_load = "#level3prescreen_proxy"
end
elseif message_id == hash("LifeLost") then
self.current_lives = self.current_lives - 1
if self.current_lives <= 0 then
@ -147,9 +166,11 @@ function on_message(self, message_id, message, sender)
msg.post(self.collection_to_load, "load")
self.current_collection = self.collection_to_load
self.collection_to_load = ""
elseif message_id == hash("add 100 points") then
self.current_score = self.current_score + 100
--print(self.current_score)
elseif message_id == hash("play amulet sound") then
sound.play("sound#amulet_sound", {speed = 1, gain = (self.sounds_volume - 547)/(887 - 547)})
elseif message_id == hash("play dying sound") then
@ -160,10 +181,12 @@ function on_message(self, message_id, message, sender)
sound.play("sound#jump_sound", {speed = 1, gain = (self.sounds_volume - 547)/(887 - 547)})
elseif message_id == hash("play background music") then
sound.play("music#background_music", {speed = 1, gain = (self.music_volume - 547)/(887 - 547)})
elseif message_id == hash("sounds_volume") then
self.sounds_volume = message.sounds_volume
-- local scaled_volume = (self.sounds_volume - 547)/(887 - 547)
-- sound.set_group_gain("sounds", scaled_volume)
elseif message_id == hash("music_volume") then
self.music_volume = message.music_volume
-- local scaled_volume = (self.music_volume - 547)/(887 - 547)

View file

@ -26,7 +26,7 @@ end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
if gui.pick_node(gui.get_node("startgame"), action.x, action.y) then
msg.post("main:/controller#main", "show level1 screen")
msg.post("main:/controller#main", "show level1prescreen")
elseif gui.pick_node(gui.get_node("instructions"), action.x, action.y) then
msg.post("main:/controller#main", "show instructions screen")
elseif gui.pick_node(gui.get_node("settings"), action.x, action.y) then