PageRenderTime 7ms CodeModel.GetById 5ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/pocjs/entities/BatBossEntity.js

http://github.com/sbober/pocjs
JavaScript | 35 lines | 28 code | 7 blank | 0 comment | 2 complexity | 0f49cf0dace237c02d818cac83e6cdc1 MD5 | raw file
 1dojo.provide("pocjs.entities.BatBossEntity");
 2
 3dojo.declare("pocjs.entities.BatBossEntity", pocjs.entities.EnemyEntity, {
 4
 5    "-chains-": {constructor: "manual"},
 6    constructor: function(x, z) {
 7        this.inherited(arguments, [x, z, 4 * 8, pocjs.Art.getCol(0xffff00)]);
 8        this.x = x;
 9        this.z = z;
10        this.health = 5;
11        this.r = 0.3;
12        
13        this.flying = true;
14    },
15
16    die: function() {
17        pocjs.Sound.bosskill.play();
18        this.level.addEntity(new pocjs.entities.KeyEntity(this.x, this.z));
19    },
20
21    tick: function() {
22        this.inherited(arguments);
23        if (Math.random() * 20 < 1) {
24            var xx = this.x + (Math.random() - 0.5) * 2;
25            var zz = this.z + (Math.random() - 0.5) * 2;
26            var batEntity = new pocjs.entities.BatEntity(xx, zz);
27            batEntity.level = this.level;
28
29            if (batEntity.isFree(xx, zz)) {
30                this.level.addEntity(batEntity);
31            }
32        }
33    }
34});
35