Merge pull request #22 from townxelliot/no-mobile-setting-take2-21
Remove platform option and use HUD option instead
This commit is contained in:
+27
-17
@@ -19,25 +19,30 @@ 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;
|
||||
|
||||
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;
|
||||
|
||||
this.controlType = opts.controlType == undefined ? 1 : opts.controlType;
|
||||
|
||||
// 0 == low, 1 == mid, 2 == high, 3 == very high
|
||||
// the old platform+quality combinations map to these new quality values
|
||||
// as follows:
|
||||
// mobile + low quality => 0 (LOW)
|
||||
// mobile + mid quality OR desktop + low quality => 1 (MID)
|
||||
// mobile + high quality => 2 (HIGH)
|
||||
// desktop + mid or high quality => 3 (VERY HIGH)
|
||||
this.quality = opts.quality == undefined ? 3 : opts.quality;
|
||||
|
||||
if(this.half)
|
||||
if(this.quality === 0)
|
||||
{
|
||||
this.width /= 2;
|
||||
this.height /=2;
|
||||
@@ -129,17 +134,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()
|
||||
@@ -272,8 +277,8 @@ bkcore.hexgl.HexGL.prototype.initRenderer = function()
|
||||
clearColor: 0x000000
|
||||
});
|
||||
|
||||
|
||||
if(this.quality > 0 && !this.mobile)
|
||||
// desktop + quality mid or high
|
||||
if(this.quality > 2)
|
||||
{
|
||||
renderer.physicallyBasedShading = true;
|
||||
renderer.gammaInput = true;
|
||||
@@ -344,8 +349,11 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
|
||||
// this.composers.game.addPass( effectFXAA );
|
||||
|
||||
// this.extras.fxaa = effectFXAA;
|
||||
|
||||
// }
|
||||
if(this.quality > 1 && !this.mobile)
|
||||
|
||||
// desktop + quality mid or high
|
||||
if(this.quality > 2)
|
||||
{
|
||||
var effectBloom = new THREE.BloomPass( 0.8, 25, 4 , 256);
|
||||
|
||||
@@ -354,12 +362,13 @@ bkcore.hexgl.HexGL.prototype.initGameComposer = function()
|
||||
this.extras.bloom = effectBloom;
|
||||
}
|
||||
|
||||
if(!this.mobile || this.quality > 0)
|
||||
// desktop + quality low, mid or high
|
||||
// OR
|
||||
// mobile + quality mid or high
|
||||
if(this.quality > 0)
|
||||
this.composers.game.addPass( effectHex );
|
||||
else
|
||||
this.composers.game.addPass( effectScreen );
|
||||
|
||||
|
||||
}
|
||||
|
||||
bkcore.hexgl.HexGL.prototype.createMesh = function(parent, geometry, x, y, z, mat)
|
||||
@@ -370,7 +379,8 @@ 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)
|
||||
// desktop + quality mid or high
|
||||
if(this.quality > 2)
|
||||
{
|
||||
mesh.castShadow = true;
|
||||
mesh.receiveShadow = true;
|
||||
|
||||
@@ -37,11 +37,14 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
analyser: null,
|
||||
pixelRatio: 2048.0 / 6000.0,
|
||||
|
||||
load: function(opts, quality, mobile)
|
||||
load: function(opts, quality)
|
||||
{
|
||||
this.lib = new bkcore.threejs.Loader(opts);
|
||||
|
||||
if((quality < 1 && !mobile) || quality < 2) // LOW
|
||||
// desktop + quality low
|
||||
// OR
|
||||
// mobile + quality low or mid
|
||||
if(quality < 2) // LOW
|
||||
{
|
||||
this.lib.load({
|
||||
textures: {
|
||||
@@ -83,6 +86,9 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
}
|
||||
});
|
||||
}
|
||||
// desktop + quality mid or high
|
||||
// OR
|
||||
// mobile + quality high
|
||||
else // HIGH
|
||||
{console.log('HIGH');
|
||||
this.lib.load({
|
||||
@@ -139,9 +145,12 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
}
|
||||
},
|
||||
|
||||
buildMaterials: function(quality, mobile)
|
||||
buildMaterials: function(quality)
|
||||
{
|
||||
if((quality < 1 && !mobile) || quality < 2) // LOW
|
||||
// desktop + quality low
|
||||
// OR
|
||||
// mobile + quality low or mid
|
||||
if(quality < 2) // LOW
|
||||
{
|
||||
this.materials.track = new THREE.MeshBasicMaterial({
|
||||
map: this.lib.get("textures", "track.cityscape.diffuse"),
|
||||
@@ -187,6 +196,9 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
transparent: false
|
||||
});
|
||||
}
|
||||
// desktop + quality mid or high
|
||||
// OR
|
||||
// mobile + quality high
|
||||
else // HIGH
|
||||
{
|
||||
this.materials.track = bkcore.Utils.createNormalMaterial({
|
||||
@@ -270,7 +282,7 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
}
|
||||
},
|
||||
|
||||
buildScenes: function(ctx, quality, mobile)
|
||||
buildScenes: function(ctx, quality)
|
||||
{
|
||||
// IMPORTANT
|
||||
this.analyser = this.lib.get("analysers", "track.cityscape.collision");
|
||||
@@ -313,7 +325,8 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
sun.position.set( -4000, 1200, 1800 );
|
||||
sun.lookAt(new THREE.Vector3());
|
||||
|
||||
if(quality > 0 && !mobile)
|
||||
// desktop + quality mid or high
|
||||
if(quality > 2)
|
||||
{
|
||||
sun.castShadow = true;
|
||||
sun.shadowCameraNear = 50;
|
||||
@@ -348,6 +361,14 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
|
||||
var boosterLight = new THREE.PointLight(0x00a2ff, 4.0, 60);
|
||||
boosterLight.position.set(0, 0.665, -4);
|
||||
|
||||
// desktop + quality low, mid or high
|
||||
// OR
|
||||
// mobile + quality mid or high
|
||||
// NB booster is now enabled on desktop + low quality,
|
||||
// when it wasn't before; this is because this booster setting
|
||||
// is the only difference between mobile + mid quality
|
||||
// and desktop + low quality, so I merged them for convenience
|
||||
if(quality > 0)
|
||||
ship.add(boosterLight);
|
||||
|
||||
@@ -373,7 +394,9 @@ bkcore.hexgl.tracks.Cityscape = {
|
||||
boosterLight: boosterLight,
|
||||
useParticles: false
|
||||
};
|
||||
if(quality > 0 && !mobile)
|
||||
|
||||
// desktop + quality mid or high
|
||||
if(quality > 2)
|
||||
{
|
||||
fxParams.textureCloud = this.lib.get("textures", "cloud");
|
||||
fxParams.textureSpark = this.lib.get("textures", "spark");
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
<div id="start">Start</div>
|
||||
<div id="s-controlType">Controls: LeapMotion</div>
|
||||
<div id="s-quality">Quality: High</div>
|
||||
<div id="s-platform">Platform: Desktop</div>
|
||||
<div id="s-hud">HUD: On</div>
|
||||
<div id="s-godmode">Godmode: On</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+6
-7
@@ -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
|
||||
@@ -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'
|
||||
@@ -37,10 +35,11 @@ init = (controlType, quality, platform, godmode) ->
|
||||
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: ']
|
||||
['quality', ['LOW', 'MID', 'HIGH', 'VERY HIGH'], 3, 3, 'Quality: ']
|
||||
['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]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var $, a, getWebGL, hasWebGL, init, s, u, _fn, _i, _len;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
return document.getElementById(_);
|
||||
};
|
||||
|
||||
init = function(controlType, quality, platform, godmode) {
|
||||
init = function(controlType, quality, hud, godmode) {
|
||||
var hexGL, progressbar;
|
||||
hexGL = new bkcore.hexgl.HexGL({
|
||||
document: document,
|
||||
@@ -17,9 +17,7 @@
|
||||
gameover: $('step-5'),
|
||||
quality: quality,
|
||||
difficulty: 0,
|
||||
half: platform === 1 && quality < 1,
|
||||
mobile: platform === 1,
|
||||
hud: platform === 0,
|
||||
hud: hud === 1,
|
||||
controlType: controlType,
|
||||
godmode: godmode,
|
||||
track: 'Cityscape'
|
||||
@@ -46,7 +44,7 @@
|
||||
|
||||
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: '], ['godmode', ['OFF', 'ON'], 0, 1, 'Godmode: ']];
|
||||
s = [['controlType', ['KEYBOARD', 'TOUCH', 'LEAP MOTION CONTROLLER', 'GAMEPAD'], 0, 0, 'Controls: '], ['quality', ['LOW', 'MID', 'HIGH', 'VERY HIGH'], 3, 3, 'Quality: '], ['hud', ['OFF', 'ON'], 1, 1, 'HUD: '], ['godmode', ['OFF', 'ON'], 0, 1, 'Godmode: ']];
|
||||
|
||||
_fn = function(a) {
|
||||
var e, f, _ref;
|
||||
|
||||
Reference in New Issue
Block a user