blob: ecc334dedf22e88a4c68d8c0296f8c5db81ebec7 (
plain)
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
|
window.Wall = (function(){
var Wall = function(opt){
this.id = opt.id
this.room = opt.room
this.rect = opt.rect || new Rect (0,0,0,0)
this.rect.sides = opt.side
this.side = opt.side
this.mx = []
this.els = []
if (opt.el) {
this.mx.push(opt.el)
}
}
Wall.prototype.toString = function(){
return this.rect.toString()
}
Wall.prototype.reset = function(){
}
Wall.prototype.destroy = function(){
this.mx.forEach(function(mx){
mx.destroy && mx.destroy()
})
this.room = this.rect = this.mx = this.els = null
}
Wall.prototype.bind = function(){
var base = this
base.$walls = $( this.mx.map(function(mx){ return mx.el }) )
base.$walls.bind({
mouseover: function(){
},
mousemove: function(e){
},
mousedown: function(){
base.randomize_colors()
}
})
}
Wall.prototype.bounds_for = function(img) {
var coord = this.side & FRONT_BACK ? this.rect.x : this.rect.y
return new Rect( new vec2( coord.a + img.width/2, coord.b - img.width/2 ),
new vec2( img.height/2, clipper.rooms[this.room].height - img.height/2 ) )
}
var bzz = 0
Wall.prototype.randomize_colors = function(){
this.$walls.css("background-color", window.colors[bzz=(bzz+1)%window.colors.length])
}
return Wall
})()
|