PageRenderTime 20ms CodeModel.GetById 17ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/pocjs/gui/RubbleSprite.js

http://github.com/sbober/pocjs
JavaScript | 33 lines | 28 code | 5 blank | 0 comment | 2 complexity | 42931f11bee42bd89ec494630133a0b1 MD5 | raw file
 1dojo.provide("pocjs.gui.RubbleSprite");
 2
 3dojo.declare("pocjs.gui.RubbleSprite", pocjs.gui.Sprite, {
 4    xa: null, ya: null, za: null,
 5
 6
 7    "-chains-": {constructor: "manual"},
 8    constructor: function() {
 9        this.inherited(arguments, [ Math.random() - 0.5,
10                    Math.random() * 0.8,
11                    Math.random() - 0.5,
12                    2, 0x555555
13        ]);
14        this.xa = Math.random() - 0.5;
15        this.ya = Math.random();
16        this.za = Math.random() - 0.5;
17    },
18
19    tick: function() {
20        this.x += this.xa * 0.03;
21        this.y += this.ya * 0.03;
22        this.z += this.za * 0.03;
23        this.ya -= 0.1;
24        if (this.y < 0) {
25            this.y = 0;
26            this.xa *= 0.8;
27            this.za *= 0.8;
28            if (Math.random() < 0.04)
29                this.removed = true;
30        }
31    }
32});
33