Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.idea
22 changes: 11 additions & 11 deletions bkcore/Audio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var bkcore = bkcore || {};
const bkcore = bkcore || {};

bkcore.Audio = {};
bkcore.Audio.sounds = {};
Expand All @@ -19,18 +19,18 @@ bkcore.Audio.init = function(){
bkcore.Audio.init();

bkcore.Audio.addSound = function(src, id, loop, callback, usePanner){
var ctx = bkcore.Audio._ctx;
const ctx = bkcore.Audio._ctx;
var audio = new Audio();

if(ctx){
var audio = { src: null, gainNode: null, bufferNode: null, loop: loop };
var xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';

xhr.onload = function(){
ctx.decodeAudioData(xhr.response, function(b){
// Create Gain Node
var gainNode = ctx.createGain();
const gainNode = ctx.createGain();

if(usePanner === true){
gainNode.connect(bkcore.Audio._panner);
Expand Down Expand Up @@ -72,10 +72,10 @@ bkcore.Audio.addSound = function(src, id, loop, callback, usePanner){
};

bkcore.Audio.play = function(id){
var ctx = bkcore.Audio._ctx;
const ctx = bkcore.Audio._ctx;

if(ctx){
var sound = ctx.createBufferSource();
const sound = ctx.createBufferSource();
sound.connect(bkcore.Audio.sounds[id].gainNode);

sound.buffer = bkcore.Audio.sounds[id].src;
Expand All @@ -97,7 +97,7 @@ bkcore.Audio.play = function(id){
};

bkcore.Audio.stop = function(id){
var ctx = bkcore.Audio._ctx;
const ctx = bkcore.Audio._ctx;

if(ctx){
if(bkcore.Audio.sounds[id].bufferNode !== null){
Expand All @@ -112,7 +112,7 @@ bkcore.Audio.stop = function(id){
};

bkcore.Audio.volume = function(id, volume){
var ctx = bkcore.Audio._ctx;
const ctx = bkcore.Audio._ctx;

if(ctx){
bkcore.Audio.sounds[id].gainNode.gain.value = volume;
Expand All @@ -124,8 +124,8 @@ bkcore.Audio.volume = function(id, volume){

bkcore.Audio.setListenerPos = function(vec){
if(bkcore.Audio._ctx){
var panner = bkcore.Audio._panner;
var vec2 = vec.normalize();
const panner = bkcore.Audio._panner;
const vec2 = vec.normalize();
panner.setPosition(
vec2.x * bkcore.Audio.posMultipler,
vec2.y * bkcore.Audio.posMultipler,
Expand All @@ -136,7 +136,7 @@ bkcore.Audio.setListenerPos = function(vec){

bkcore.Audio.setListenerVelocity = function(vec){
if(bkcore.Audio._ctx){
var panner = bkcore.Audio._panner;
const panner = bkcore.Audio._panner;
panner.setVelocity(vec.x, vec.y, vec.z);
}
};
2 changes: 1 addition & 1 deletion bkcore/hexgl/CameraChase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
*/

var bkcore = bkcore || {};
const bkcore = bkcore || {};
bkcore.hexgl = bkcore.hexgl || {};

bkcore.hexgl.CameraChase = function(opts)
Expand Down
16 changes: 8 additions & 8 deletions bkcore/hexgl/Gameplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
*/

var bkcore = bkcore || {};
const bkcore = bkcore || {};
bkcore.hexgl = bkcore.hexgl || {};

bkcore.hexgl.Gameplay = function(opts)
{
var self = this;
const self = this;

this.startDelay = opts.hud == null ? 0 : 1000;
this.countDownDelay = opts.hud == null ? 1000 : 1500;
Expand Down Expand Up @@ -58,12 +58,12 @@ bkcore.hexgl.Gameplay = function(opts)
self.raceData.tick(this.timer.time.elapsed);

self.hud != null && self.hud.updateTime(self.timer.getElapsedTime());
var cp = self.checkPoint();
const cp = self.checkPoint();

if(cp == self.track.checkpoints.start && self.previousCheckPoint == self.track.checkpoints.last)
{
self.previousCheckPoint = cp;
var t = self.timer.time.elapsed;
const t = self.timer.time.elapsed;
self.lapTimes.push(t - self.lapTimeElapsed);
self.lapTimeElapsed = t;

Expand Down Expand Up @@ -131,7 +131,7 @@ bkcore.hexgl.Gameplay.prototype.start = function(opts)
if(this.hud != null) this.hud.messageOnly = true;

try {
var d = localStorage['race-'+this.track.name+'-replay'];
const d = localStorage['race-'+this.track.name+'-replay'];
if(d == undefined)
{
console.error('No replay data for '+'race-'+this.track.name+'-replay'+'.');
Expand Down Expand Up @@ -219,10 +219,10 @@ bkcore.hexgl.Gameplay.prototype.update = function()

bkcore.hexgl.Gameplay.prototype.checkPoint = function()
{
var x = Math.round(this.analyser.pixels.width/2 + this.shipControls.dummy.position.x * this.pixelRatio);
var z = Math.round(this.analyser.pixels.height/2 + this.shipControls.dummy.position.z * this.pixelRatio);
const x = Math.round(this.analyser.pixels.width/2 + this.shipControls.dummy.position.x * this.pixelRatio);
const z = Math.round(this.analyser.pixels.height/2 + this.shipControls.dummy.position.z * this.pixelRatio);

var color = this.analyser.getPixel(x, z);
const color = this.analyser.getPixel(x, z);

if(color.r == 255 && color.g == 255 && color.b < 250)
return color.b;
Expand Down
42 changes: 21 additions & 21 deletions bkcore/hexgl/HUD.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/.
*/

var bkcore = bkcore || {};
const bkcore = bkcore || {};
bkcore.hexgl = bkcore.hexgl || {};

bkcore.hexgl.HUD = function(opts)
{
var self = this;
const self = this;

this.visible = true;
this.messageOnly = false;
Expand Down Expand Up @@ -121,34 +121,34 @@ bkcore.hexgl.HUD.prototype.resetTime = function()

bkcore.hexgl.HUD.prototype.update = function(speed, speedRatio, shield, shieldRatio)
{
var SCREEN_WIDTH = this.width;
var SCREEN_HEIGHT = this.height;
const SCREEN_WIDTH = this.width;
const SCREEN_HEIGHT = this.height;

var SCREEN_HW = SCREEN_WIDTH / 2;
var SCREEN_HH = SCREEN_HEIGHT / 2;
const SCREEN_HW = SCREEN_WIDTH / 2;
const SCREEN_HH = SCREEN_HEIGHT / 2;

if(!this.visible)
{
this.ctx.clearRect(0 , 0 , SCREEN_WIDTH , SCREEN_HEIGHT);
return;
}

var w = this.bg.width;
var h = this.bg.height;
var r = h/w;
var nw = SCREEN_WIDTH;
var nh = nw*r;
var oh = SCREEN_HEIGHT - nh;
var o = 0;
const w = this.bg.width;
const h = this.bg.height;
const r = h/w;
const nw = SCREEN_WIDTH;
const nh = nw*r;
const oh = SCREEN_HEIGHT - nh;
const o = 0;
//speedbar
var ba = nh;
var bl = SCREEN_WIDTH/this.speedBarRatio;
var bw = bl * speedRatio;
const ba = nh;
const bl = SCREEN_WIDTH/this.speedBarRatio;
const bw = bl * speedRatio;
//shieldbar
var sw = SCREEN_WIDTH/this.shieldBarWRatio;
var sho = SCREEN_WIDTH/this.shieldBarHRatio;
var sh = sho*shieldRatio;
var sy = (SCREEN_WIDTH/this.shieldBarYRatio)+sho-sh;
const sw = SCREEN_WIDTH/this.shieldBarWRatio;
const sho = SCREEN_WIDTH/this.shieldBarHRatio;
const sh = sho*shieldRatio;
const sy = (SCREEN_WIDTH/this.shieldBarYRatio)+sho-sh;


if(this.step == 0)
Expand Down Expand Up @@ -213,7 +213,7 @@ bkcore.hexgl.HUD.prototype.update = function(speed, speedRatio, shield, shieldRa
}

// MESSAGE
var my = SCREEN_HH-SCREEN_WIDTH/this.messageYRatio;
const my = SCREEN_HH-SCREEN_WIDTH/this.messageYRatio;

if(this.messageTiming > this.messageDuration+2000)
{
Expand Down
66 changes: 33 additions & 33 deletions bkcore/hexgl/HexGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
'use strict';
'v1.0.1';

var bkcore = bkcore || {};
const bkcore = bkcore || {};
bkcore.hexgl = bkcore.hexgl || {};

bkcore.hexgl.HexGL = function(opts)
{
var self = this;
const self = this;

this.document = opts.document || document;

Expand Down Expand Up @@ -94,7 +94,7 @@ bkcore.hexgl.HexGL.prototype.start = function()

this.manager.setCurrent("game");

var self = this;
const self = this;

function raf()
{
Expand Down Expand Up @@ -155,7 +155,7 @@ bkcore.hexgl.HexGL.prototype.load = function(opts)

bkcore.hexgl.HexGL.prototype.initGameplay = function()
{
var self = this;
const self = this;

this.gameplay = new bkcore.hexgl.Gameplay({
mode: this.mode,
Expand All @@ -182,8 +182,8 @@ bkcore.hexgl.HexGL.prototype.displayScore = function(f, l)
{
this.active = false;

var tf = bkcore.Timer.msToTimeString(f);
var tl = [
const tf = bkcore.Timer.msToTimeString(f);
const tl = [
bkcore.Timer.msToTimeString(l[0]),
bkcore.Timer.msToTimeString(l[1]),
bkcore.Timer.msToTimeString(l[2])
Expand All @@ -197,21 +197,21 @@ bkcore.hexgl.HexGL.prototype.displayScore = function(f, l)
return;
}

var t = this.track;
var dc = this.document.getElementById("finish");
var ds = this.document.getElementById("finish-state");
var dh = this.document.getElementById("finish-hallmsg");
var dr = this.document.getElementById("finish-msg");
var dt = this.document.getElementById("finish-result");
var dl1 = this.document.getElementById("finish-lap1");
var dl2 = this.document.getElementById("finish-lap2");
var dl3 = this.document.getElementById("finish-lap3");
var dd = this.document.getElementById("finish-diff")
var st = this.document.getElementById("finish-twitter");
var sf = this.document.getElementById("finish-fb");
var sl = this.document.getElementById("lowfps-msg");
var d = this.difficulty == 0 ? 'casual' : 'hard';
var ts = this.hud.timeSeparators;
const t = this.track;
const dc = this.document.getElementById("finish");
const ds = this.document.getElementById("finish-state");
const dh = this.document.getElementById("finish-hallmsg");
const dr = this.document.getElementById("finish-msg");
const dt = this.document.getElementById("finish-result");
const dl1 = this.document.getElementById("finish-lap1");
const dl2 = this.document.getElementById("finish-lap2");
const dl3 = this.document.getElementById("finish-lap3");
const dd = this.document.getElementById("finish-diff");
const st = this.document.getElementById("finish-twitter");
const sf = this.document.getElementById("finish-fb");
const sl = this.document.getElementById("lowfps-msg");
const d = this.difficulty == 0 ? 'casual' : 'hard';
const ts = this.hud.timeSeparators;

if(this.gameplay.result == this.gameplay.results.FINISH)
{
Expand All @@ -233,7 +233,7 @@ bkcore.hexgl.HexGL.prototype.displayScore = function(f, l)
}
}
// ladder record
var p = bkcore.hexgl.Ladder.global[t][d][bkcore.hexgl.Ladder.global[t][d].length-2];
const p = bkcore.hexgl.Ladder.global[t][d][bkcore.hexgl.Ladder.global[t][d].length-2];
if(p != undefined && p['score'] > f)
{
dh != undefined && (dh.innerHTML = "You made it to the HOF!");
Expand Down Expand Up @@ -282,7 +282,7 @@ bkcore.hexgl.HexGL.prototype.displayScore = function(f, l)

bkcore.hexgl.HexGL.prototype.initRenderer = function()
{
var renderer = new THREE.WebGLRenderer({
const renderer = new THREE.WebGLRenderer({
antialias: false,
clearColor: 0x000000
});
Expand Down Expand Up @@ -324,22 +324,22 @@ bkcore.hexgl.HexGL.prototype.initHUD = function()

bkcore.hexgl.HexGL.prototype.initGameComposer = function()
{
var renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
var renderTarget = new THREE.WebGLRenderTarget( this.width, this.height, renderTargetParameters );
const renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
const renderTarget = new THREE.WebGLRenderTarget( this.width, this.height, renderTargetParameters );

// GAME COMPOSER
var renderSky = new THREE.RenderPass( this.manager.get("sky").scene, this.manager.get("sky").camera );
const renderSky = new THREE.RenderPass( this.manager.get("sky").scene, this.manager.get("sky").camera );

var renderModel = new THREE.RenderPass( this.manager.get("game").scene, this.manager.get("game").camera );
const renderModel = new THREE.RenderPass( this.manager.get("game").scene, this.manager.get("game").camera );
renderModel.clear = false;

this.composers.game = new THREE.EffectComposer( this.renderer, renderTarget );

var effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
const effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
effectScreen.renderToScreen = true;
var effectVignette = new THREE.ShaderPass( THREE.ShaderExtras[ "vignette" ] );
const effectVignette = new THREE.ShaderPass( THREE.ShaderExtras[ "vignette" ] );

var effectHex = new THREE.ShaderPass( bkcore.threejs.Shaders[ "hexvignette" ] );
const effectHex = new THREE.ShaderPass( bkcore.threejs.Shaders[ "hexvignette" ] );
effectHex.uniforms[ 'size' ].value = 512.0 * (this.width/1633);
effectHex.uniforms[ 'rx' ].value = this.width;
effectHex.uniforms[ 'ry' ].value = this.height;
Expand All @@ -365,7 +365,7 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
// desktop + quality mid or high
if(this.quality > 2)
{
var effectBloom = new THREE.BloomPass( 0.8, 25, 4 , 256);
const effectBloom = new THREE.BloomPass( 0.8, 25, 4 , 256);

this.composers.game.addPass( effectBloom );

Expand All @@ -385,7 +385,7 @@ bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, ma
{
geometry.computeTangents();

var mesh = new THREE.Mesh( geometry, mat );
const mesh = new THREE.Mesh( geometry, mat );
mesh.position.set( x, y, z );
parent.add(mesh);

Expand All @@ -401,7 +401,7 @@ bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, ma

bkcore.hexgl.HexGL.prototype.tweakShipControls = function()
{
var c = this.components.shipControls;
const c = this.components.shipControls;
if(this.difficulty == 1)
{
c.airResist = 0.035;
Expand Down
Loading