summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/engine/mover.js
blob: ebe44475a65d3a0e3cb3d7ab8c73b590513d5f41 (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
var mover = new function(){

	var base = this
	var last_room = null

	base.init = function(){
		last_room = clipper.rooms[0]
		base.bind()
	}
	
	base.bind = function(){
		app.on("move", base.update)
	}
	
	base.update = function(pos){
		if (last_room && last_room.rect.contains(pos.x, pos.z)) return;
		
		var intersects = []
		clipper.rooms.forEach(function(r){
			if (r.rect.contains(pos.x, pos.z)) {
				intersects.push(r)
			}
		})
		
		if (intersects.length) {
			$(".face.active").removeClass("active")
			last_room = intersects[0]
		} 
	}

}