summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/map
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/map')
-rw-r--r--public/assets/javascripts/rectangles/engine/map/_map.js3
-rw-r--r--public/assets/javascripts/rectangles/engine/map/draw.js19
2 files changed, 13 insertions, 9 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/_map.js b/public/assets/javascripts/rectangles/engine/map/_map.js
index e27346d..6492db6 100644
--- a/public/assets/javascripts/rectangles/engine/map/_map.js
+++ b/public/assets/javascripts/rectangles/engine/map/_map.js
@@ -50,6 +50,7 @@ var Map = function(opt){
switch (opt.type) {
case "ortho":
base.draw = new Map.Draw (base, { ortho: true })
+ base.draw.grid_size = MAP_GRID_SIZE
base.ui = new Map.UI.Ortho (base)
base.sides = base.sides_for_center
$(window).resize(base.resize)
@@ -57,6 +58,7 @@ var Map = function(opt){
case "editor":
base.draw = new Map.Draw (base)
+ base.draw.grid_size = MAP_GRID_SIZE
base.ui = new Map.UI.Editor (base)
base.sides = base.sides_for_center
$(window).resize(base.resize)
@@ -64,6 +66,7 @@ var Map = function(opt){
case "minimap":
base.draw = new Map.Draw (base, { center: scene.camera, minimap: true })
+ base.draw.grid_size = MAP_GRID_SIZE * 10
base.ui = new Map.UI.Minimap (base)
base.sides = base.sides_for_camera
break
diff --git a/public/assets/javascripts/rectangles/engine/map/draw.js b/public/assets/javascripts/rectangles/engine/map/draw.js
index fd05f86..4f4759f 100644
--- a/public/assets/javascripts/rectangles/engine/map/draw.js
+++ b/public/assets/javascripts/rectangles/engine/map/draw.js
@@ -179,8 +179,8 @@ Map.Draw = function(map, opt){
ctx.lineWidth = 1/map.zoom
var sides = map.sides()
- var quant = sides.clone().quantize(MAP_GRID_SIZE)
- for (var x = quant.x.a - MAP_GRID_SIZE; x <= quant.x.b; x += MAP_GRID_SIZE) {
+ var quant = sides.clone().quantize(draw.grid_size)
+ for (var x = quant.x.a - draw.grid_size; x <= quant.x.b; x += draw.grid_size) {
if (Math.round(x) % 360 == 0) {
ctx.strokeStyle = "rgba(0,0,0,0.3)"
ctx.lineWidth = 1/map.zoom
@@ -191,17 +191,18 @@ Map.Draw = function(map, opt){
}
line(x, sides.y.a, x, sides.y.b)
}
- for (var y = quant.y.a - MAP_GRID_SIZE; y <= quant.y.b; y += MAP_GRID_SIZE) {
- if (Math.round(y) % 360 == 0) {
+
+ for (var y = quant.y.a - draw.grid_size; y <= quant.y.b; y += draw.grid_size) {
+ if (Math.round(y) % 360 == 0) {
ctx.strokeStyle = "rgba(0,0,0,0.3)"
ctx.lineWidth = 1/map.zoom
- }
- else {
+ }
+ else {
ctx.strokeStyle = "rgba(0,0,0,0.05)"
ctx.lineWidth = 1/map.zoom
- }
- line(sides.x.a, y, sides.x.b, y)
- }
+ }
+ line(sides.x.a, y, sides.x.b, y)
+ }
}
//