Fucking BUG with targetPosition fixed
This commit is contained in:
1 parent
3ef9adadb2
commit
032db15106
5 files changed
+21
-20
No files matched your search
@@ -391,7 +391,7 @@ function newFloatingLayer () {
|
||||
|
||||
/* Calculate repulsion force produced by all other floatingObjects */
|
||||
|
||||
currentRepulsionForce(i)
|
||||
repulsionForceBetweenFloatingObjects(i)
|
||||
|
||||
targetRepulsionForce(i)
|
||||
|
||||
@@ -457,7 +457,7 @@ function newFloatingLayer () {
|
||||
}
|
||||
}
|
||||
|
||||
function currentRepulsionForce (currentFloatingObject) {
|
||||
function repulsionForceBetweenFloatingObjects (currentFloatingObject) {
|
||||
try {
|
||||
/* We generate a repulsion force between floatingObjects, that prevents them to be collisioning so often. */
|
||||
|
||||
@@ -515,7 +515,7 @@ function newFloatingLayer () {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] currentRepulsionForce -> err= ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] repulsionForceBetweenFloatingObjects -> err= ' + err.stack) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,11 +645,7 @@ function newFloatingLayer () {
|
||||
}
|
||||
|
||||
function distance (x1, y1, x2, y2) {
|
||||
try {
|
||||
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2))
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] distance -> err= ' + err.stack) }
|
||||
}
|
||||
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2))
|
||||
}
|
||||
|
||||
function resolveCollision (floatingObject1, floatingObject2) {
|
||||
|
||||
@@ -400,10 +400,13 @@ function newStrategyPart () {
|
||||
thisObject.codeEditor.physics()
|
||||
}
|
||||
|
||||
if (thisObject.payload.chainParent === undefined) { return }
|
||||
|
||||
thisObject.payload.targetPosition.x = thisObject.payload.chainParent.payload.position.x
|
||||
thisObject.payload.targetPosition.y = thisObject.payload.chainParent.payload.position.y
|
||||
if (thisObject.payload.chainParent === undefined) {
|
||||
thisObject.payload.targetPosition.x = canvas.floatingSpace.container.frame.width / 2,
|
||||
thisObject.payload.targetPosition.y = canvas.floatingSpace.container.frame.height / 2
|
||||
} else {
|
||||
thisObject.payload.targetPosition.x = thisObject.payload.chainParent.payload.position.x - canvas.floatingSpace.container.frame.position.x
|
||||
thisObject.payload.targetPosition.y = thisObject.payload.chainParent.payload.position.y - canvas.floatingSpace.container.frame.position.y
|
||||
}
|
||||
}
|
||||
|
||||
function onFocus () {
|
||||
@@ -480,6 +483,7 @@ function newStrategyPart () {
|
||||
y: 0
|
||||
}
|
||||
|
||||
targetPoint = canvas.floatingSpace.container.frame.frameThisPoint(targetPoint)
|
||||
position = thisObject.container.frame.frameThisPoint(position)
|
||||
|
||||
if (thisObject.container.frame.radius > 1) {
|
||||
@@ -630,3 +634,4 @@ function newStrategyPart () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ function newStrategyPartConstructor () {
|
||||
}
|
||||
|
||||
function level_0 () {
|
||||
floatingObject.friction = 0.93
|
||||
floatingObject.friction = FRICTION// 0.93
|
||||
|
||||
floatingObject.initializeMass(500)
|
||||
floatingObject.initializeRadius(45)
|
||||
@@ -105,7 +105,7 @@ function newStrategyPartConstructor () {
|
||||
}
|
||||
|
||||
function level_1 () {
|
||||
floatingObject.friction = 0.94
|
||||
floatingObject.friction = FRICTION // 0.94
|
||||
|
||||
floatingObject.initializeMass(250)
|
||||
floatingObject.initializeRadius(45)
|
||||
|
||||
@@ -29,10 +29,10 @@ function newFloatingSpace () {
|
||||
thisObject.container.isWheelable = true
|
||||
thisObject.container.detectMouseOver = true
|
||||
thisObject.container.frame.radius = 0
|
||||
thisObject.container.frame.width = browserCanvas.width * 1.5
|
||||
thisObject.container.frame.height = browserCanvas.height * 1.5
|
||||
thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2
|
||||
thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2
|
||||
thisObject.container.frame.width = browserCanvas.width * 1
|
||||
thisObject.container.frame.height = browserCanvas.height * 1
|
||||
thisObject.container.frame.position.x = 0 // browserCanvas.width / 2// - thisObject.container.frame.width / 2
|
||||
thisObject.container.frame.position.y = 0 // browserCanvas.height / 2// - thisObject.container.frame.height / 2
|
||||
|
||||
let visible = false
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ function newInvestmentPlan () {
|
||||
let payload = {}
|
||||
if (chainParent === undefined) {
|
||||
payload.targetPosition = {
|
||||
x: canvas.floatingSpace.container.frame.width / 2,
|
||||
y: canvas.floatingSpace.container.frame.height / 2
|
||||
x: canvas.floatingSpace.container.frame.position.x + canvas.floatingSpace.container.frame.width / 2,
|
||||
y: canvas.floatingSpace.container.frame.position.y + canvas.floatingSpace.container.frame.height / 2
|
||||
}
|
||||
} else {
|
||||
payload.targetPosition = {
|
||||
|
||||
Reference in new issue
Block a user