summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/rooms/mover.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/rooms/mover.js')
-rw-r--r--public/assets/javascripts/rectangles/engine/rooms/mover.js38
1 files changed, 37 insertions, 1 deletions
diff --git a/public/assets/javascripts/rectangles/engine/rooms/mover.js b/public/assets/javascripts/rectangles/engine/rooms/mover.js
index fae2ce6..121ecec 100644
--- a/public/assets/javascripts/rectangles/engine/rooms/mover.js
+++ b/public/assets/javascripts/rectangles/engine/rooms/mover.js
@@ -34,7 +34,43 @@ Rooms.mover = new function(){
}
// check if we've breached one of the walls.. clamp position if so
- var collision = base.room.collidesDisc(pos.x, pos.z, radius)
+ var collision = base.room.collidesDisc(cam, pos, radius)
+
+/*
+ var dz = new vec2( cam.z, pos.z )
+ dz.normalize()
+
+ var dx = new vec2( cam.x, pos.x )
+ dx.normalize()
+
+ Walls.list.forEach(function(wall){
+ switch (wall.side) {
+ case FRONT:
+ break
+ case BACK:
+ break
+ case LEFT:
+ if (cam.x >= wall.edge + radius && wall.edge + radius >= pos.x && (wall.vec.intersects(dz) ) {
+ // intersects the wall.. next check if it intersects any of the surface frames
+ wall.surface.faces.some(function(face, i){
+ // if we can pass through the wall at this point, we do not need to clamp
+ if (face.y.a === 0 && face.x.intersects(dz)) {
+ dz.a = pos.z = face.x.clamp(pos.z)
+ dz.b = cam.z
+ dz.normalize()
+ return true
+ }
+ })
+ }
+ break
+ case RIGHT:
+ if (cam.x <= wall.edge - radius && wall.edge - radius <= pos.x && (wall.vec.contains(cam.z) || wall.vec.contains(pos.z)) ) {
+ // intersects
+ }
+ break
+ }
+ })
+*/
if (collision && ! base.noclip) {
cam.x = (collision & LEFT_RIGHT) ? base.room.rect.x.clampDisc(pos.x, radius) : pos.x