-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (42 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* # JingCraft - Index
*
* Entry point for JingCraft
*
* Pixedy
*
* Copyright (c) 2014 Jing Chan <jingchan@gmail.com>
*
* Private Use Only - Unauthorized use prohibited
*
* -----------------------------------------------------------------------------
*/
var WebGL = require('node-webgl');
var Game = require('./lib');
// Make sure correct environment
var nodejs = (typeof window === 'undefined');
if(!nodejs) {
throw Error("node_app.js should be run in node, not the browser.")
}
document = WebGL.document();
alert=console.log;
document.setTitle("Pixedy");
var canvas = document.createElement("canvas", 800, 600);
var glSettings = {
alpha: true,
depth: false,
stencil: false,
antialias: false,
premultipliedAlpha: false,
preserveDrawingBuffer: true
};
// Get WebGL Context and construct Pixedy object
var context = canvas.getContext('webgl', glSettings) || canvas.getContext('experimental-webgl', glSettings);
var game = Game();
var step = function(time){
//game loop
game.step(time);
document.requestAnimationFrame(step,1000/60);
}
document.requestAnimationFrame(step,1000/60);
// module.exports = client;