From ab7a6984cf4ab61399b3d4766b30bc5cc55cdf1e Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Mon, 12 Jan 2026 16:39:35 +0700 Subject: [PATCH] Bunch of random changes --- Backup/huge-atlas.png | 3 + liveupdate.settings | 0 main/Game.go | 4 + main/knights-blue.tilesource | 2 - main/main.collection | 28 ++ main/overlays.gui | 443 +++++++++++++++++++++++++++++++ main/sprites.atlas | 4 +- main/test-huger-atlas.atlas | 3 + main/test-hugest-atlas.atlas | 3 + project.shared_editor_settings | 0 scripts/TestGuiScript.gui_script | 41 +++ scripts/game.script | 45 +++- scripts/knight.script | 2 +- scripts/utils.lua | 25 ++ 14 files changed, 593 insertions(+), 10 deletions(-) create mode 100644 Backup/huge-atlas.png create mode 100644 liveupdate.settings create mode 100644 main/Game.go create mode 100644 main/overlays.gui create mode 100644 main/test-huger-atlas.atlas create mode 100644 main/test-hugest-atlas.atlas create mode 100644 project.shared_editor_settings create mode 100644 scripts/TestGuiScript.gui_script create mode 100644 scripts/utils.lua diff --git a/Backup/huge-atlas.png b/Backup/huge-atlas.png new file mode 100644 index 0000000..ab233b6 --- /dev/null +++ b/Backup/huge-atlas.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d1ca5f52f28649e14e06d5422214ca930669092e9978ddd5f0a7a2057070d79 +size 141911 diff --git a/liveupdate.settings b/liveupdate.settings new file mode 100644 index 0000000..e69de29 diff --git a/main/Game.go b/main/Game.go new file mode 100644 index 0000000..3f53af5 --- /dev/null +++ b/main/Game.go @@ -0,0 +1,4 @@ +components { + id: "game" + component: "/scripts/game.script" +} diff --git a/main/knights-blue.tilesource b/main/knights-blue.tilesource index 5d5c1f1..16713a1 100644 --- a/main/knights-blue.tilesource +++ b/main/knights-blue.tilesource @@ -1,7 +1,6 @@ image: "/assets/V1/Factions/Knights/Troops/Warrior/Blue/Warrior_Blue.png" tile_width: 192 tile_height: 192 -collision_groups: "default" animations { id: "attack1-down" start_tile: 25 @@ -52,4 +51,3 @@ animations { playback: PLAYBACK_LOOP_FORWARD fps: 12 } -extrude_borders: 2 diff --git a/main/main.collection b/main/main.collection index c92c9ae..441a8c3 100644 --- a/main/main.collection +++ b/main/main.collection @@ -134,3 +134,31 @@ embedded_instances { z: 500.0 } } +embedded_instances { + id: "test-atlas" + data: "embedded_components {\n" + " id: \"sprite\"\n" + " type: \"sprite\"\n" + " data: \"default_animation: \\\"Lancer\\\"\\n" + "material: \\\"/builtins/materials/sprite.material\\\"\\n" + "textures {\\n" + " sampler: \\\"texture_sampler\\\"\\n" + " texture: \\\"/main/test-hugest-atlas.atlas\\\"\\n" + "}\\n" + "\"\n" + " position {\n" + " x: 333.0\n" + " y: 218.0\n" + " z: 1.0\n" + " }\n" + "}\n" + "" +} +embedded_instances { + id: "GUI" + data: "components {\n" + " id: \"overlays\"\n" + " component: \"/main/overlays.gui\"\n" + "}\n" + "" +} diff --git a/main/overlays.gui b/main/overlays.gui new file mode 100644 index 0000000..cd6ded7 --- /dev/null +++ b/main/overlays.gui @@ -0,0 +1,443 @@ +fonts { + name: "default" + font: "/builtins/fonts/default.font" +} +nodes { + position { + x: 532.0 + y: 335.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + scale { + x: 2.0 + y: 2.0 + } + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "1000" + font: "default" + id: "text" + parent: "box" + inherit_alpha: true +} +nodes { + position { + x: 142.0 + y: 149.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box1" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text1" + parent: "box1" + inherit_alpha: true +} +nodes { + position { + x: 142.0 + y: 149.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box2" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 142.0 + y: 149.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box3" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text3" + parent: "box3" + inherit_alpha: true +} +nodes { + position { + x: 142.0 + y: 149.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box4" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text4" + parent: "box4" + inherit_alpha: true +} +nodes { + position { + x: 142.0 + y: 149.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box5" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text5" + parent: "box5" + inherit_alpha: true +} +nodes { + position { + x: 514.0 + y: 140.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box6" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text6" + parent: "box6" + inherit_alpha: true +} +nodes { + position { + x: 154.0 + y: 325.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box7" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text7" + parent: "box7" + inherit_alpha: true +} +nodes { + position { + x: 307.0 + y: 195.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box8" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text8" + parent: "box8" + inherit_alpha: true +} +nodes { + position { + x: 339.0 + y: 45.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box9" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text9" + parent: "box9" + inherit_alpha: true +} +nodes { + position { + x: 664.0 + y: 204.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box10" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text10" + parent: "box10" + inherit_alpha: true +} +nodes { + position { + x: 313.0 + y: 436.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box11" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text11" + parent: "box11" + inherit_alpha: true +} +nodes { + position { + x: 142.0 + y: 149.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box12" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text12" + parent: "box12" + inherit_alpha: true +} +nodes { + position { + x: 142.0 + y: 149.0 + } + size { + x: 200.0 + y: 100.0 + } + type: TYPE_BOX + id: "box13" + inherit_alpha: true + size_mode: SIZE_MODE_AUTO +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text13" + parent: "box13" + inherit_alpha: true +} +nodes { + size { + x: 200.0 + y: 100.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + } + type: TYPE_TEXT + text: "Testing" + font: "default" + id: "text2" + inherit_alpha: true +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/main/sprites.atlas b/main/sprites.atlas index c82f8bb..0a6bf50 100644 --- a/main/sprites.atlas +++ b/main/sprites.atlas @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5be53cc74dee0a49da2782e9d96f68253a13c5f128e6c6f14c0fab42e8f7aa30 -size 74 +oid sha256:3a5eaf6a80752f95dc091333c8bb421b54fd657b98924447836c96714750060a +size 77 diff --git a/main/test-huger-atlas.atlas b/main/test-huger-atlas.atlas new file mode 100644 index 0000000..dd20beb --- /dev/null +++ b/main/test-huger-atlas.atlas @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cafef3814c95ae25ff5c5fe17b87f774c4cfce218c3c0ba49e39b279ca412067 +size 1148 diff --git a/main/test-hugest-atlas.atlas b/main/test-hugest-atlas.atlas new file mode 100644 index 0000000..49bc8ef --- /dev/null +++ b/main/test-hugest-atlas.atlas @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f221ae588b354f8e8c1f8188e2035f94ef7d53e493e7c42c1c2bc906f855929a +size 28484 diff --git a/project.shared_editor_settings b/project.shared_editor_settings new file mode 100644 index 0000000..e69de29 diff --git a/scripts/TestGuiScript.gui_script b/scripts/TestGuiScript.gui_script new file mode 100644 index 0000000..949c82a --- /dev/null +++ b/scripts/TestGuiScript.gui_script @@ -0,0 +1,41 @@ +function init(self) + -- Add initialization code here + -- Learn more: https://defold.com/manuals/script/ + -- Remove this function if not needed +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) + -- 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 diff --git a/scripts/game.script b/scripts/game.script index 1c34245..17c6dd1 100644 --- a/scripts/game.script +++ b/scripts/game.script @@ -1,4 +1,14 @@ local utils = require "scripts.utils" +local mobdebug = require "builtins.scripts.mobdebug" + +local genv = _G or _ENV +local jit = rawget(genv, "jit") +if jit then + print("turning jit off") + jit.off() + jit.opt.start(0) -- Disable all optimizations (set optimization level to 0) + +end function init(self) msg.post(".", "acquire_input_focus") @@ -31,19 +41,44 @@ function on_message(self, message_id, message, sender) -- Remove this function if not needed end +local function another_one(one, two) + local three = one + two + print(three) + return three +end + function on_input(self, action_id, action) if action_id == hash("touch") and action.pressed then + print("JIT status:", jit.status()) + self.next_state = "moving" - local tx, ty, _ = utils.screen_to_world(action.screen_x, action.screen_y, 0, "/CameraParent#camera") + local tx, ty = utils.screen_to_world(action.screen_x, action.screen_y, 0, "/CameraParent#camera") + local three = another_one(5, 10) self.target_pos = vmath.vector3(tx, ty, 0) - elseif action_id == hash("right-click") then + local testing = three + 10 + print(testing) + local another_test = testing + 100 + print(another_test) + self.another_test = another_test + return false + elseif action_id == hash("right-click") and action.pressed then + print(self.another_test + 10) -- msg.post(receiver, message_id, message) end end function on_reload(self) msg.post(".", "acquire_input_focus") - -- Add reload-handling code here - -- Learn more: https://defold.com/manuals/hot-reload/ - -- Remove this function if not needed end + +-- local function list_breakpoints() +-- local result = {} +-- for file, lines in pairs(breakpoints) do +-- for line, _ in pairs(lines) do +-- table.insert(result, {file = file, line = line}) +-- end +-- end +-- return result +-- end + +-- mobdebug.list_breakpoints = list_breakpoints diff --git a/scripts/knight.script b/scripts/knight.script index bd851bf..a49ab42 100644 --- a/scripts/knight.script +++ b/scripts/knight.script @@ -33,7 +33,7 @@ end function on_message(self, message_id, message, sender) if message_id == hash("collision_response") then - print(go.get_id()) + -- print(go.get_id()) end if message_id == hash("trigger_response") then if message.enter then diff --git a/scripts/utils.lua b/scripts/utils.lua new file mode 100644 index 0000000..1affb97 --- /dev/null +++ b/scripts/utils.lua @@ -0,0 +1,25 @@ +local M = {} + +function M.screen_to_world(x, y, z, camera_id) + local projection = camera.get_projection(camera_id) + local view = camera.get_view(camera_id) + local w, h = window.get_size() + + -- https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates + local inv = vmath.inv(projection * view) + x = (2 * x / w) - 1 + y = (2 * y / h) - 1 + z = (2 * z) - 1 + local x1 = x * inv.m00 + y * inv.m01 + z * inv.m02 + inv.m03 + local y1 = x * inv.m10 + y * inv.m11 + z * inv.m12 + inv.m13 + local z1 = x * inv.m20 + y * inv.m21 + z * inv.m22 + inv.m23 + + return x1, y1, z1 +end + +if true then + +end + + +return M \ No newline at end of file