summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/rectangles')
-rw-r--r--assets/javascripts/rectangles/_env.js3
-rw-r--r--assets/javascripts/rectangles/map/_map.js1
-rw-r--r--assets/javascripts/rectangles/map/draw.js23
-rw-r--r--assets/javascripts/rectangles/map/ui.js9
4 files changed, 33 insertions, 3 deletions
diff --git a/assets/javascripts/rectangles/_env.js b/assets/javascripts/rectangles/_env.js
index 463fb3e..145806e 100644
--- a/assets/javascripts/rectangles/_env.js
+++ b/assets/javascripts/rectangles/_env.js
@@ -8,6 +8,9 @@ environment.init = function(){
"rotationX": PI/2,
"rotationY": PI
})
+
+ map.center.a = scene.camera.x
+ map.center.b = scene.camera.z
clipper.rooms.push( new room ({
rect: new rect(-100,-100, 100,100),
diff --git a/assets/javascripts/rectangles/map/_map.js b/assets/javascripts/rectangles/map/_map.js
index b0d0b60..846c73c 100644
--- a/assets/javascripts/rectangles/map/_map.js
+++ b/assets/javascripts/rectangles/map/_map.js
@@ -27,6 +27,7 @@ var map = new function(){
map.draw.regions(clipper.regions)
map.draw.mouse(map.ui.mouse.cursor)
+ scene && map.draw.camera(scene.camera)
ctx.restore()
}
diff --git a/assets/javascripts/rectangles/map/draw.js b/assets/javascripts/rectangles/map/draw.js
index 1dcd1ae..1fca4b9 100644
--- a/assets/javascripts/rectangles/map/draw.js
+++ b/assets/javascripts/rectangles/map/draw.js
@@ -44,6 +44,29 @@ map.draw = new function(){
}
}
}
+
+ base.camera = function(cam){
+ ctx.lineWidth = 0.5
+
+ ctx.save()
+
+ ctx.translate(cam.x, cam.z)
+ ctx.rotate(cam.rotationY)
+
+ var radius = 3 / map.zoom
+
+ ctx.fillStyle = '#888';
+
+ ctx.beginPath();
+ ctx.moveTo(0,0)
+ ctx.lineTo(-radius,-radius/2)
+ ctx.lineTo(0,radius*3)
+ ctx.lineTo(radius,-radius/2)
+ ctx.moveTo(0,0)
+ ctx.fill()
+
+ ctx.restore()
+ }
//
diff --git a/assets/javascripts/rectangles/map/ui.js b/assets/javascripts/rectangles/map/ui.js
index 6560695..f08cae0 100644
--- a/assets/javascripts/rectangles/map/ui.js
+++ b/assets/javascripts/rectangles/map/ui.js
@@ -25,10 +25,13 @@ map.ui = new function(){
function down (e, cursor){
cursor.x.div(map.zoom).add( map.center.a + map.bounds.a/2 )
cursor.y.div(map.zoom).add( -map.center.b - map.bounds.b/2 )
-
+console.log(cursor+"")
if (e.ctrlKey || e.which === 3) {
- map.center.a = cursor.x.b = cursor.x.a + map.bounds.a/2
- map.center.b = cursor.y.b = cursor.y.a + map.bounds.b
+ map.center.a = cursor.x.a + map.bounds.a * map.zoom
+ map.center.b = -cursor.y.a + map.bounds.b * map.zoom
+ console.log(map.center+"")
+ cursor.x.b = cursor.x.a
+ cursor.y.b = cursor.y.a
base.mouse.down = false
e.preventDefault()
e.stopPropagation()