summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/models
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-02 16:18:12 -0400
committerJules Laplace <jules@okfoc.us>2014-10-02 16:18:12 -0400
commitf7c36f7a3394caa90937c5687f3ac7aeeed82e82 (patch)
treed155f036dff980abc5af7161517842a51887e1ac /public/assets/javascripts/rectangles/models
parent55639122a00e77aaca1c6ac2faa5bc9f61ce7124 (diff)
add media closer to where you clicked
Diffstat (limited to 'public/assets/javascripts/rectangles/models')
-rw-r--r--public/assets/javascripts/rectangles/models/vec2.js10
-rw-r--r--public/assets/javascripts/rectangles/models/wall.js9
2 files changed, 17 insertions, 2 deletions
diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js
index a5a832e..49613c3 100644
--- a/public/assets/javascripts/rectangles/models/vec2.js
+++ b/public/assets/javascripts/rectangles/models/vec2.js
@@ -63,6 +63,16 @@
this.b /= n
return this
}
+ vec2.prototype.addVec = function(v){
+ this.a += v.a
+ this.b += v.b
+ return this
+ }
+ vec2.prototype.subVec = function(v){
+ this.a -= v.a
+ this.b -= v.b
+ return this
+ }
vec2.prototype.zero = function(){
this.a = this.b = 0
}
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js
index ce958db..fdc8d8c 100644
--- a/public/assets/javascripts/rectangles/models/wall.js
+++ b/public/assets/javascripts/rectangles/models/wall.js
@@ -53,7 +53,6 @@
/*
mousemove: function(e){
var offset = offsetFromPoint(e, mx.el)
- var shouldFlip = base.side & (RIGHT | FRONT)
if (offset) {
var pos = base.mxOffsetToPosition( offset, index )
@@ -72,9 +71,15 @@
if (Scenery.nextText) {
}
else if (Scenery.nextMedia) {
+ var offset = offsetFromPoint(e, mx.el)
+ if (! offset) { return }
+
+ var pos = base.mxOffsetToPosition( offset, index )
+
var scenery = Scenery.addNextToWall({
wall: base,
- index: index
+ index: index,
+ position: pos,
})
// scenery was not placed