Mine Runner now OPEN SOURCE
SOURCES
This is an example of how can look small game made in defold. I think my defold looks a little bit different than you defold, but maybe you find something usefull in my project:)
Open source version same as release. But i removed all sounds/music and change some textures. Because i use paid assets.
Some facts about the game and its architecture:
1)Small 3D runner game. 2.23mb(gzipped)
1.86mb resources:
-636kb textures
-543kb meshes
-340kb sounds
-184kb lua
-64kb fonts
2. Single branch multiple platform
You can build it for this platforms from master branch. Playmarket, yandex, vk, gamedistribution (declined), crazygames, poki (declined), dev build. I use bob --settings to change dependencies and configs for platforms.
java -jar bob/bob.jar --settings bob/settings/release_game.project_settings --settings bob/settings/crazy_games_game.project_settings --archive --with-symbols --variant release --platform=js-web --bo bob/releases/crazy_games clean resolve build bundle
3)A lot of useful modules:)
-custom scene manager (inspired by early version of monarch)
-localization
-storage (save, load,migrations,encrypt)
-lua tween animations. Support parallel, sequence, and changing script_instance
local action_2 = ACTIONS.Sequence()
action_2:add_action(function()
COMMON.coroutine_wait(0.9)
gui.set_color(self.vh.start_timer_lbl_2, COLOR_EMPTY)
gui.set_scale(self.vh.start_timer_lbl_2, SCALE_NUMBER)
gui.set_enabled(self.vh.start_timer_lbl_2, true)
end)
action_2:add_action(ACTIONS.TweenGui { object = self.vh.start_timer_lbl_2, property = "color", v4 = true,
from = COLOR_EMPTY, to = COLOR_WHITE, time = 0.25,
easing = TWEEN.easing.inQuad })
-and a lot of other modules
4)Lua modules better than scripts:)
In game, I have only 4 .script files. All logic in lua modules.
1.init_controller.script
Initialize all. Load game scene. Update some modules that should be updated every frame
2.game_scene_controller.script
Update game logic
3.shop/controller.script
Need it to update 3D model in shop gui. Yes, I use 3D models in gui;)
4.world_textures.script
Handled all textures for tunnel
go.property("mine_world", resource.texture("/assets/textures/rgb/mip/mine_world.png"))
go.property("dark_world", resource.texture("/assets/textures/rgb/mip/dark_world.png"))
go.property("metal_world", resource.texture("/assets/textures/rgb/mip/metal_world.png"))
go.property("toon_world", resource.texture("/assets/textures/rgb/mip/toon_world.png"))
go.property("grass_world", resource.texture("/assets/textures/rgb/mip/grass_world.png"))
5.N28S(NoMoreGlobalFunctionInScript) inspired by Script wrapper for Defold · GitHub
I made my own implementation. It support multiple n28s scripts per .script file. Also it supports inheritance
6.Debug panel that show only in dev builds.
7.No messages for game logic
I hate messages) They make code async and hard to understand. Also i need to use ctrl+f(find gui in editor) to find where i use this message.
So i use changing script instance where i need it. I can save script instance. Then i can load that script instance when needed. Not recommend if you do not understand what is it and why you need it) Messages is ok when you post something between logic and gui.
8.ECS
9. World and GameWorld
World and GameWorld is lua modules that have all other lua modules that i use in game.
Most of modules have reference to world module. So in module i can get world and from world get all others modules. So why world and not require modules. Because when require, it easy to make cyclic dependencies. But when i use world i can fix this cyclic dependencies, because in world it easy to change order of initialization of other modules. Also i can pass world in constructor or set it as variable of module.
--check in main_menu.gui_script
if (WORLD.sdk.yagames_sdk and COMMON.html5_is_mobile()) then
WORLD.sdk.yagames_sdk:sticky_banner_hide()
end