You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.6 KiB

2 years ago
'use strict';
let debug = false,
font,
localSettings,
loader;
//Only for online games
let socket;
let antiCacheQuery = '?_=' + new Date().getTime();
let doppler;
function preload(){
localSettings = loadJSON('data/settings/settings.json' + antiCacheQuery, json => {
console.log('Local settings loaded: ', json);
}, error => {
console.log('Local settings failed: ', error);
});
font = loadFont('data/styles/fonts/Tajawal/Tajawal-Regular.ttf' + antiCacheQuery, json => {
console.log('Local font loaded: ', json);
}, error => {
console.log('Local font failed: ', error);
});
loadJSON('data/settings/libraries.json', json => {
loadScripts(json);
console.log('BenjoCraeft library scripts loaded: ', json);
});
}
function setup(){
canvasSetup();
interfaceSetup();
doppler = new Doppler();
doppler.updateMode();
}
function draw(){
background(30);
if (doppler){
doppler.update();
doppler.display();
}
if (loader){
loader.update();
loader.display();
}
if (debug) debugInformation();
}
function canvasSetup(){
setFrameRate(60);
let w = $('#canvas-holder').width(),
h = $('#canvas-holder').height();
let canvas = createCanvas(w, h);
canvas.parent('canvas-holder');
textFont(font);
}
function interfaceSetup(){
}
function loadScripts(libs){
for (let script in libs){
if (libs[script]){
let url = '/lib/benjocraeft/' + script + '.js'
$.getScript(url, () => {
console.log('Successfully loaded script: ', url)
});
}
}
}