为了更好地理解javascript(我只是在学习),我开始查看各种在线游戏的代码。在这个游戏(HexGl)中,有一个startDelay,countDownDelay,opts。和hud。我似乎无法弄清楚他们的意思。我非常感谢有关这些变量以及它们如何使游戏受益的任何反馈!
游戏代码: https://github.com/BKcore/HexGL
这是一个来自Gameplay.js的片段:
bkcore.hexgl.Gameplay = function(opts)
{
var self = this;
this.startDelay = opts.hud == null ? 0 : 1000;
this.countDownDelay = opts.hud == null ? 1000 : 1500;
this.active = false;
this.timer = new bkcore.Timer();
this.modes = {
'timeattack':null,
'survival':null,
'replay':null
};
this.mode = opts.mode == undefined || !(opts.mode in this.modes) ? "timeattack" : opts.mode;
this.step = 0;
this.hud = opts.hud;
this.shipControls = opts.shipControls;
this.cameraControls = opts.cameraControls;
this.track = opts.track;
this.analyser = opts.analyser;
this.pixelRatio = opts.pixelRatio;
this.previousCheckPoint = -1;
this.results = {
FINISH: 1,
DESTROYED: 2,
WRONGWAY: 3,
REPLAY: 4,
NONE: -1
};
this.result = this.results.NONE;
this.lap = 1;
this.lapTimes = [];
this.lapTimeElapsed = 0;
this.maxLaps = 3;
this.score = null;
this.finishTime = null;
this.onFinish = opts.onFinish == undefined ? function() {console.log("FINISH");} : opts.onFinish;
this.raceData = null;
this.modes.timeattack = function()