Skip to content

Commit

Permalink
Localise all references to 'mobile'
Browse files Browse the repository at this point in the history
Remove the mobile property and set it locally in each location
where it is used (preparation for iterating the different
platform+quality combinations which affect the graphics).

Mark each point where a decision is made based on platform+quality
with a plain English version of the combinations which take
effect and when.

Add an explicit hud property which is set from the start screen
and which is independent of the platform.
  • Loading branch information
townxelliot committed May 30, 2014
1 parent fdc7e91 commit 4886f1d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 27 deletions.
43 changes: 31 additions & 12 deletions bkcore/hexgl/HexGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ bkcore.hexgl.HexGL = function(opts)

this.a = window.location.href;

this.mobile = opts.mobile == undefined ? false : opts.mobile;
this.active = true;
this.displayHUD = opts.hud == undefined ? true : opts.hud;
this.width = opts.width == undefined ? window.innerWidth : opts.width;
this.height = opts.height == undefined ? window.innerHeight : opts.height;

this.quality = opts.quality == undefined ? 2 : opts.quality;

// TODO remove mobile variable
var mobile = true;
this.half = mobile && this.quality < 1;

this.difficulty = opts.difficulty == undefined ? 0 : opts.difficulty;
this.player = opts.player == undefined ? "Anonym" : opts.player;

this.half = opts.half == undefined ? false : opts.half;

this.track = bkcore.hexgl.tracks[ opts.track == undefined ? 'Cityscape' : opts.track ];

this.mode = opts.mode == undefined ? 'timeattack' : opts.mode;
Expand Down Expand Up @@ -129,17 +131,17 @@ bkcore.hexgl.HexGL.prototype.update = function()
bkcore.hexgl.HexGL.prototype.init = function()
{
this.initHUD();

this.track.buildMaterials(this.quality);

this.track.buildMaterials(this.quality, this.mobile);

this.track.buildScenes(this, this.quality, this.mobile);
this.track.buildScenes(this, this.quality);

this.initGameComposer();
}

bkcore.hexgl.HexGL.prototype.load = function(opts)
{
this.track.load(opts, this.quality, this.mobile);
this.track.load(opts, this.quality);
}

bkcore.hexgl.HexGL.prototype.initGameplay = function()
Expand Down Expand Up @@ -272,8 +274,11 @@ bkcore.hexgl.HexGL.prototype.initRenderer = function()
clearColor: 0x000000
});


if(this.quality > 0 && !this.mobile)
// TODO remove mobile var
var mobile = true;

// desktop + quality mid or high
if(this.quality > 0 && !mobile)
{
renderer.physicallyBasedShading = true;
renderer.gammaInput = true;
Expand Down Expand Up @@ -344,8 +349,14 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
// this.composers.game.addPass( effectFXAA );

// this.extras.fxaa = effectFXAA;

// }
if(this.quality > 1 && !this.mobile)

// TODO remove mobile var
var mobile = true;

// desktop + quality mid or high
if(this.quality > 1 && !mobile)
{
var effectBloom = new THREE.BloomPass( 0.8, 25, 4 , 256);

Expand All @@ -354,7 +365,11 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
this.extras.bloom = effectBloom;
}

if(!this.mobile || this.quality > 0)
// TODO remove mobile var
// desktop + quality low, mid or high
// OR
// mobile + quality mid or high
if(!mobile || this.quality > 0)
this.composers.game.addPass( effectHex );
else
this.composers.game.addPass( effectScreen );
Expand All @@ -370,7 +385,11 @@ bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, ma
mesh.position.set( x, y, z );
parent.add(mesh);

if(this.quality > 0 && !this.mobile)
// TODO remove mobile var
var mobile = true;

// desktop + quality mid or high
if(this.quality > 0 && !mobile)
{
mesh.castShadow = true;
mesh.receiveShadow = true;
Expand Down
32 changes: 29 additions & 3 deletions bkcore/hexgl/tracks/Cityscape.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ bkcore.hexgl.tracks.Cityscape = {
analyser: null,
pixelRatio: 2048.0 / 6000.0,

load: function(opts, quality, mobile)
load: function(opts, quality)
{
// TODO remove mobile var
var mobile = true;

this.lib = new bkcore.threejs.Loader(opts);

// desktop + quality low
// OR
// mobile + quality low or mid
if((quality < 1 && !mobile) || quality < 2) // LOW
{
this.lib.load({
Expand Down Expand Up @@ -83,6 +89,9 @@ bkcore.hexgl.tracks.Cityscape = {
}
});
}
// desktop + quality mid or high
// OR
// mobile + quality high
else // HIGH
{console.log('HIGH');
this.lib.load({
Expand Down Expand Up @@ -139,8 +148,14 @@ bkcore.hexgl.tracks.Cityscape = {
}
},

buildMaterials: function(quality, mobile)
buildMaterials: function(quality)
{
// TODO remove mobile var
var mobile = true;

// desktop + quality low
// OR
// mobile + quality low or mid
if((quality < 1 && !mobile) || quality < 2) // LOW
{
this.materials.track = new THREE.MeshBasicMaterial({
Expand Down Expand Up @@ -187,6 +202,9 @@ bkcore.hexgl.tracks.Cityscape = {
transparent: false
});
}
// desktop + quality mid or high
// OR
// mobile + quality high
else // HIGH
{
this.materials.track = bkcore.Utils.createNormalMaterial({
Expand Down Expand Up @@ -270,8 +288,11 @@ bkcore.hexgl.tracks.Cityscape = {
}
},

buildScenes: function(ctx, quality, mobile)
buildScenes: function(ctx, quality)
{
// TODO remove mobile var
var mobile = true;

// IMPORTANT
this.analyser = this.lib.get("analysers", "track.cityscape.collision");

Expand Down Expand Up @@ -313,6 +334,7 @@ bkcore.hexgl.tracks.Cityscape = {
sun.position.set( -4000, 1200, 1800 );
sun.lookAt(new THREE.Vector3());

// desktop + quality mid or high
if(quality > 0 && !mobile)
{
sun.castShadow = true;
Expand Down Expand Up @@ -348,6 +370,8 @@ bkcore.hexgl.tracks.Cityscape = {

var boosterLight = new THREE.PointLight(0x00a2ff, 4.0, 60);
boosterLight.position.set(0, 0.665, -4);

// desktop or mobile + quality mid or high
if(quality > 0)
ship.add(boosterLight);

Expand All @@ -373,6 +397,8 @@ bkcore.hexgl.tracks.Cityscape = {
boosterLight: boosterLight,
useParticles: false
};

// desktop + quality mid or high
if(quality > 0 && !mobile)
{
fxParams.textureCloud = this.lib.get("textures", "cloud");
Expand Down
11 changes: 5 additions & 6 deletions launch.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ = (_) -> document.getElementById _

init = (controlType, quality, platform, godmode) ->
init = (controlType, quality, hud, godmode) ->
hexGL = new bkcore.hexgl.HexGL(
document: document
width: window.innerWidth
Expand All @@ -9,10 +9,8 @@ init = (controlType, quality, platform, godmode) ->
overlay: $ 'overlay'
gameover: $ 'step-5'
quality: quality
difficulty: 0,
half: (platform is 1 and quality < 1)
mobile: platform is 1
hud: platform is 0
difficulty: 0
hud: hud is 1
controlType: controlType
godmode: godmode
track: 'Cityscape'
Expand All @@ -38,9 +36,10 @@ u = bkcore.Utils.getURLParameter
s = [
['controlType', ['KEYBOARD', 'TOUCH', 'LEAP MOTION CONTROLLER', 'GAMEPAD'], 0, 0, 'Controls: ']
['quality', ['LOW', 'MID', 'HIGH'], 2, 2, 'Quality: ']
['platform', ['DESKTOP', 'MOBILE'], 0, 0, 'Platform: ']
['hud', ['OFF', 'ON'], 1, 1, 'HUD: ']
['godmode', ['OFF', 'ON'], 0, 1, 'Godmode: ']
]

for a in s
do(a)->
a[3] = u(a[0]) ? a[2]
Expand Down
10 changes: 4 additions & 6 deletions launch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4886f1d

Please sign in to comment.