Skip to content

Instantly share code, notes, and snippets.

View aglitchman's full-sized avatar
☄️
Defolding

Artsiom Trubchyk aglitchman

☄️
Defolding
View GitHub Profile
@aglitchman
aglitchman / test_emcc1_llvm31.js
Created July 17, 2012 00:59
JS output by emscripten, LLVM 3.1 + LLVM 3.2
// Note: Some Emscripten settings will significantly limit the speed of the generated code.
// Note: Some Emscripten settings may limit the speed of the generated code.
// TODO: " u s e s t r i c t ";
try {
this['Module'] = Module;
} catch(e) {
this['Module'] = Module = {};
}
@aglitchman
aglitchman / defold_ie11_support.html
Last active April 16, 2020 10:17
Defold recently dropped support of Internet Explorer 11 for HTML5 builds. If you want to run your game on IE11 then add this code to your engine_template.html right after the <body> tag. Tested on Defold 1.2.167. Changelog: 2020-04-16 - Added "resume" implementation for AudioContext for Edge ≤18, Chrome <41, Firefox <40 browsers.
<script id="old-browser-support">
if (!(navigator.getGamepads || navigator.webkitGetGamepads)) {
navigator.getGamepads = function() { return []; };
}
if (!(window.AudioContext || window.webkitAudioContext)) {
window.AudioContext = function() {
this.sampleRate = 44100;
this.destination = 0;
this.currentTime = 0;
this.state = "running";
@aglitchman
aglitchman / compile_shader.editor_script
Last active November 30, 2021 15:02
Editor script for Defold IDE. The script adds the menu items "Compile Fragment Shader" and "Compile Vertex Shader" for .fp/.vp files.
-- Download and install Arm Mobile Studio from
-- https://developer.arm.com/tools-and-software/graphics-and-gaming/arm-mobile-studio/components/mali-offline-compiler
local M = {}
local function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending
end
function M.get_commands()
@aglitchman
aglitchman / convert_sound.editor_script
Last active April 13, 2023 13:04
Convert to Ogg Vorbis - editor script for Defold
-- 1. Put this script into your project's dir as `convert_sound.editor_script` (the extension is important!)
-- 2. Click "Project / Reload Editor Scripts"
-- 3. Download the latest ffmpeg from https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z or
-- from https://ffmpeg.org/download.html for other platforms
-- 4. Put ffmpeg executable into FFMPEG_LOCATION or modify the FFMPEG_LOCATION path
-- 5. Tune output audio file quality:
-- Range is -1.0 to 10.0, where 10.0 is highest quality.
-- Default is 3 with a target of 112kbps, and it's enough for the most games.
-- The formula 16×(q+4) is used below 4, 32×q is used below 8, and 64×(q-4) otherwise.
-- Examples: 112=16×(3+4), 160=32×5, 200=32×6.25, 384=64×(10-4).
@aglitchman
aglitchman / device.lua
Last active March 5, 2024 11:39
Detect operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile). Lua module for the Defold game engine.
-- Based on the device.js module: https://github.com/matthewhudson/current-device
-- MIT License
--
-- Usage:
-- local device = require("device")
-- if device.type == "mobile" then
-- -- do something!
-- end
--
-- Or:
@aglitchman
aglitchman / build_with_liveupdate.sh
Created November 15, 2022 12:59
Example script of how to build Defold game for HTML5 with Live Update resources and move them to the destination directory
#!/bin/bash
# ⚠⚠⚠ Run the script from the root directory of your project!
# Requires: curl, jq, wget, awk, java >=11
# macOS: brew install jq awk wget openjdk@11
# Ubuntu/Debian/WSL: sudo apt install --no-install-recommends jq wget openjdk-11-jre-headless
# Stop on errors
set -e
@aglitchman
aglitchman / ff_unique_symbols.js
Last active May 18, 2023 22:42
NodeJS script to generate FF script to keep in the font required characters only
/*
USAGE:
1. RUN:
node ff_unique_symbols.js
2. Copy the result, i.e. the FF script.
3. Open a font in FontForge
4. File -> Execute Script
5. In the popup select FF, paste the script.