Skip to content

Commit 970dea2

Browse files
committed
Added checksum ability to build process.
Fixed RequestAnimationFrame.
1 parent 96c7446 commit 970dea2

7 files changed

Lines changed: 77 additions & 9 deletions

File tree

v3/create-checksum.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var fs = require('fs-extra');
2+
var uuid = require('node-uuid');
3+
4+
var v = uuid.v1();
5+
6+
var output = [
7+
'var CHECKSUM = {',
8+
'build: \'' + v + '\'',
9+
'};',
10+
'module.exports = CHECKSUM;'
11+
];
12+
13+
// Should output a json file, but webpack2 json-loader is broken
14+
// at the moment, so we're outputting a js file instead
15+
16+
fs.writeFile('./src/checksum.js', output.join('\n'), function (error) {
17+
18+
if (error)
19+
{
20+
throw error;
21+
}
22+
else
23+
{
24+
console.log('Building #' + v);
25+
}
26+
27+
});

v3/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@
3030
"web audio"
3131
],
3232
"dependencies": {
33+
"json-loader": "^0.5.4",
3334
"webpack": "2.1.0-beta.27"
3435
},
3536
"devDependencies": {
3637
"copy-webpack-plugin": "^4.0.1",
3738
"fs-extra": "^1.0.0",
39+
"json-loader": "^0.5.4",
40+
"node-uuid": "^1.4.7",
3841
"webpack": "2.1.0-beta.27",
3942
"webpack-dev-server": "2.1.0-beta.11",
4043
"webpack-shell-plugin": "^0.4.3"

v3/src/boot/Game.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7+
var CHECKSUM = require('../checksum');
8+
79
var Config = require('./Config');
810
var DebugHeader = require('./DebugHeader');
9-
var RequestAnimationFrame = require('./RequestAnimationFrame');
11+
var RequestAnimationFrame = require('../dom/RequestAnimationFrame');
1012

1113
var Game = function (config)
1214
{
@@ -68,6 +70,20 @@ var Game = function (config)
6870
// this.device.whenReady(this.boot, this);
6971

7072
DebugHeader(this);
73+
74+
console.log(CHECKSUM.build);
75+
76+
};
77+
78+
Game.prototype.constructor = Game;
79+
80+
Game.prototype = {
81+
82+
update: function (timestamp)
83+
{
84+
// console.log(timestamp);
85+
}
86+
7187
};
7288

7389
module.exports = Game;

v3/src/checksum.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var CHECKSUM = {
2+
build: '9d525b60-b2af-11e6-8aab-1f6b9d8fd351'
3+
};
4+
module.exports = CHECKSUM;

v3/src/dom/RequestAnimationFrame.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ function RequestAnimationFrame (game)
2525
*/
2626
this.isRunning = false;
2727

28+
this.tick = 0;
29+
2830
var vendors = [
2931
'ms',
3032
'moz',
@@ -48,19 +50,25 @@ function RequestAnimationFrame (game)
4850
*/
4951
this.timeOutID = null;
5052

53+
var _this = this;
54+
5155
// timestamp = DOMHighResTimeStamp
52-
this.step = function (timestamp)
56+
var step = function (timestamp)
5357
{
54-
this.timeOutID = window.requestAnimationFrame(this.step);
58+
_this.tick = timestamp;
5559

56-
this.game.update(timestamp);
60+
_this.timeOutID = window.requestAnimationFrame(step);
61+
62+
_this.game.update(timestamp);
5763
};
5864

59-
this.stepTimeout = function ()
65+
var stepTimeout = function ()
6066
{
61-
this.game.update(Date.now());
67+
_this.tick = Date.now();
68+
69+
// _this.game.update(_this.tick);
6270

63-
this.timeOutID = window.setTimeout(this.stepTimeout, this.game.time.timeToCall);
71+
// _this.timeOutID = window.setTimeout(stepTimeout, _this.game.time.timeToCall);
6472
};
6573

6674
/**
@@ -75,13 +83,13 @@ function RequestAnimationFrame (game)
7583
{
7684
this.isSetTimeOut = true;
7785

78-
this.timeOutID = window.setTimeout(this.stepTimeout, 0);
86+
this.timeOutID = window.setTimeout(stepTimeout, 0);
7987
}
8088
else
8189
{
8290
this.isSetTimeOut = false;
8391

84-
this.timeOutID = window.requestAnimationFrame(this.step);
92+
this.timeOutID = window.requestAnimationFrame(step);
8593
}
8694
};
8795

v3/webpack.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ module.exports = {
2020
plugins: [
2121

2222
new WebpackShellPlugin({
23+
onBuildStart: 'node create-checksum.js',
2324
onBuildEnd: 'node copy-to-examples.js'
2425
})
2526

2627
]
28+
2729
};

v3/yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,10 @@ jsbn@~0.1.0:
11511151
version "0.1.0"
11521152
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.0.tgz#650987da0dd74f4ebf5a11377a2aa2d273e97dfd"
11531153

1154+
json-loader@^0.5.4:
1155+
version "0.5.4"
1156+
resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de"
1157+
11541158
json-schema@0.2.3:
11551159
version "0.2.3"
11561160
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
@@ -1390,6 +1394,10 @@ node-pre-gyp@^0.6.29:
13901394
tar "~2.2.1"
13911395
tar-pack "~3.3.0"
13921396

1397+
node-uuid@^1.4.7:
1398+
version "1.4.7"
1399+
resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f"
1400+
13931401
nopt@~3.0.6:
13941402
version "3.0.6"
13951403
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"

0 commit comments

Comments
 (0)