This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
pixi_game.js
60 lines (42 loc) · 1.43 KB
/
pixi_game.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
53
54
55
56
57
58
59
60
var app = new PIXI.Application(800, 600, { antialias: true });
document.body.appendChild(app.view);
var spavn = function(){
var g = new PIXI.Graphics();
g.beginFill(0xFF3300 * Math.random());
g.lineStyle(2, 0xFFFFFF * Math.random(), 1);
g.drawRect(Math.random() * 700, Math.random() * 500, 100, 100);
g.cacheAsBitmap = true;
app.stage.addChild(g);
setTimeout(spavn , Math.random()*1000);
setTimeout(function() {
g.destroy();
}, 3000);
}
setTimeout(spavn , Math.random()*1000)
var st = null;
setTimeout(function(){
var pixi_gstats = new GStats.PIXIHooks(app);
st = new GStats.StatsJSAdapter(pixi_gstats);
document.body.appendChild(st.stats.dom || st.stats.domElement);
}, 1000);
// let's create a moving shape
var thing = new PIXI.Graphics();
app.stage.addChild(thing);
thing.x = 800/2;
thing.y = 600/2;
var count = 0;
app.ticker.add(function() {
count += 0.1;
thing.clear();
thing.lineStyle(10, 0xff0000, 1);
thing.beginFill(0xffFF00, 0.5);
thing.moveTo(-120 + Math.sin(count) * 20, -100 + Math.cos(count)* 20);
thing.lineTo( 120 + Math.cos(count) * 20, -100 + Math.sin(count)* 20);
thing.lineTo( 120 + Math.sin(count) * 20, 100 + Math.cos(count)* 20);
thing.lineTo( -120 + Math.cos(count)* 20, 100 + Math.sin(count)* 20);
thing.lineTo( -120 + Math.sin(count) * 20, -100 + Math.cos(count)* 20);
thing.rotation = count * 0.1;
if(st){
st.update();
}
});