Skip to content

Updated examples to run on Defold 1.8.0 #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
462 changes: 231 additions & 231 deletions _data/examplesindex.json

Large diffs are not rendered by default.

92 changes: 6 additions & 86 deletions _includes/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,99 +18,19 @@ <h1>WebGL not supported ⚠️</h1>
</div>
<!-- -->
<script id='engine-loader' type='text/javascript' src="/examples/dmloader.js"></script>
<!-- -->
<script id='engine-setup' type='text/javascript'>
var extra_params = {
archive_location_filter: function( path ) {
return ("/examples/archive" + path + "");
},
engine_arguments: [ '--config=examples.start={{ page.collection }}', "--verify-graphics-calls=false",],
custom_heap_size: 67108864,
full_screen_container: "#canvas-container",
disable_context_menu: true,
retry_time:1.0,
retry_count:10,
unsupported_webgl_callback: function() {
var e = document.getElementById("webgl-not-supported");
e.style.display = "block";
}
}

Module['persistentStorage'] = (typeof window !== 'undefined') && !!(window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);

Module['INITIAL_MEMORY'] = extra_params.custom_heap_size;

Module['onRuntimeInitialized'] = function() {
Module.runApp("canvas", extra_params);
};

Module["locateFile"] = function(path, scriptDirectory)
{
// dmengine*.wasm is hardcoded in the built JS loader for WASM,
// we need to replace it here with the correct project name.
if (path == "dmengine.wasm" || path == "dmengine_release.wasm" || path == "dmengine_headless.wasm") {
path = "Defoldexamples.wasm";
}
return scriptDirectory + path;
};



var is_iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
var buttonHeight = 0;
var prevInnerWidth = -1;
var prevInnerHeight = -1;
function resize_game_canvas() {
// Hack for iOS when exit from Fullscreen mode
if (is_iOS) {
window.scrollTo(0, 0);
}

var app_container = document.getElementById('app-container');
var game_canvas = document.getElementById('canvas');
var innerWidth = window.innerWidth;
var innerHeight = window.innerHeight - buttonHeight;
if (prevInnerWidth == innerWidth && prevInnerHeight == innerHeight)
{
return;
}
prevInnerWidth = innerWidth;
prevInnerHeight = innerHeight;
var width = 720;
var height = 720;
var targetRatio = width / height;
var actualRatio = innerWidth / innerHeight;




//No scale
var margin_left = ((innerWidth - width) / 2);
margin_left = margin_left > 0 ? margin_left : 0;
var margin_top = ((innerHeight - height) / 2);
margin_top = margin_top > 0 ? margin_top : 0;
app_container.style.marginLeft = margin_left + "px";
app_container.style.marginTop = margin_top + "px";

app_container.style.width = width + "px";
app_container.style.height = height + buttonHeight + "px";
game_canvas.width = width;
game_canvas.height = height;
}




</script>

<script id='engine-start' type='text/javascript'>
var runningFromFileWarning = document.getElementById("running-from-file-warning");
if (window.location.href.startsWith("file://")) {
runningFromFileWarning.style.display = "block";
}
else {
EngineLoader.stream_wasm = "false" === "true";
EngineLoader.load("canvas", "/examples/Defoldexamples");

CUSTOM_PARAMETERS.archive_location_filter = function(path) { return ("/examples/archive" + path); };
CUSTOM_PARAMETERS.engine_arguments = [ '--config=examples.start={{ page.collection }}', '--verify-graphics-calls=false' ];
CUSTOM_PARAMETERS.resize_window_callback = function() {};
EngineLoader.load("canvas", "/examples/Defoldexamples");

runningFromFileWarning.parentNode.removeChild(runningFromFileWarning);
}
</script>
Binary file modified examples/Defoldexamples.wasm
Binary file not shown.
10,450 changes: 10,344 additions & 106 deletions examples/Defoldexamples_asmjs.js

Large diffs are not rendered by default.

10,118 changes: 10,117 additions & 1 deletion examples/Defoldexamples_wasm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/archive/archive_files.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"content":[{"name":"game.projectc","size":3729,"pieces":[{"name":"game0.projectc","offset":0}]},{"name":"game.arci","size":41648,"pieces":[{"name":"game0.arci","offset":0}]},{"name":"game.arcd","size":4002228,"pieces":[{"name":"game0.arcd","offset":0},{"name":"game1.arcd","offset":2097152}]},{"name":"game.dmanifest","size":45366,"pieces":[{"name":"game0.dmanifest","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game0.public.der","offset":0}]}]}
{"content":[{"name":"game.projectc","size":3899,"pieces":[{"name":"game0.projectc","offset":0}]},{"name":"game.arci","size":41648,"pieces":[{"name":"game0.arci","offset":0}]},{"name":"game.arcd","size":4002432,"pieces":[{"name":"game0.arcd","offset":0},{"name":"game1.arcd","offset":2097152}]},{"name":"game.dmanifest","size":45366,"pieces":[{"name":"game0.dmanifest","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game0.public.der","offset":0}]}],"total_size":4093507}
Binary file modified examples/archive/game0.arcd
Binary file not shown.
Binary file modified examples/archive/game0.arci
Binary file not shown.
Binary file modified examples/archive/game0.dmanifest
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/archive/game0.projectc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ default_texture_min_filter = linear
default_texture_mag_filter = linear
max_draw_calls = 1024
max_characters = 8192
max_font_batches = 128
max_debug_vertices = 10000
texture_profiles = /all.texture_profiles
verify_graphics_calls = 1
Expand Down Expand Up @@ -122,6 +123,7 @@ pre_renderered_icons = 0
bundle_identifier = com.defold.examples
bundle_name =
infoplist = /builtins/manifests/ios/Info.plist
privacymanifest = /builtins/manifests/ios/PrivacyInfo.xcprivacy
default_language = en
localizations = en

Expand All @@ -142,6 +144,7 @@ proguard =
[osx]
app_icon =
infoplist = /builtins/manifests/osx/Info.plist
privacymanifest = /builtins/manifests/osx/PrivacyInfo.xcprivacy
bundle_identifier = com.defold.examples
bundle_name =
bundle_version = 1
Expand Down Expand Up @@ -194,6 +197,7 @@ sleep_between_server_updates = 0
[liveupdate]
settings = /liveupdate.settings
enabled = 1
mount_on_start = 1

[tilemap]
max_count = 16
Expand Down
Binary file modified examples/archive/game0.public.der
Binary file not shown.
Binary file modified examples/archive/game1.arcd
Binary file not shown.
Loading