rotating pieces that mostly work
This commit is contained in:
@@ -77,6 +77,9 @@
|
|||||||
|
|
||||||
// TODO provide a saner/configurable set of bindings to trigger these ui action functions
|
// TODO provide a saner/configurable set of bindings to trigger these ui action functions
|
||||||
{
|
{
|
||||||
|
(when FlxG.keys.justPressed.Q
|
||||||
|
(when draggingSprite
|
||||||
|
(draggingSprite.rotate 90)))
|
||||||
(when (and FlxG.keys.justPressed.SPACE !entryNameText)
|
(when (and FlxG.keys.justPressed.SPACE !entryNameText)
|
||||||
(defAndCall method toggleBackgroundColor
|
(defAndCall method toggleBackgroundColor
|
||||||
(set save.data.backgroundIndex #{(save.data.backgroundIndex + 1) % backgroundOptions.length;}#)
|
(set save.data.backgroundIndex #{(save.data.backgroundIndex + 1) % backgroundOptions.length;}#)
|
||||||
@@ -402,10 +405,12 @@
|
|||||||
minY (/ (apply min pointsY) ros)
|
minY (/ (apply min pointsY) ros)
|
||||||
maxX (/ (apply max pointsX) ros)
|
maxX (/ (apply max pointsX) ros)
|
||||||
maxY (/ (apply max pointsY) ros)
|
maxY (/ (apply max pointsY) ros)
|
||||||
rect (.fromTwoPoints (new FlxRect) (new FlxPoint minX minY) (new FlxPoint maxX maxY))]
|
rect (.fromTwoPoints (new FlxRect) (new FlxPoint minX minY) (new FlxPoint maxX maxY))
|
||||||
(+= rect.x s.x)
|
originOffset (new FlxPoint (- s.origin.x minX) (- s.origin.y minY))
|
||||||
(+= rect.y s.y)
|
rotated (rect.getRotatedBounds s.angle originOffset)]
|
||||||
rect)))
|
(+= rotated.x s.x)
|
||||||
|
(+= rotated.y s.y)
|
||||||
|
rotated)))
|
||||||
|
|
||||||
(method :FlxRect matchZoneLeft [:KissExtendedSprite s]
|
(method :FlxRect matchZoneLeft [:KissExtendedSprite s]
|
||||||
(matchZone s WEST))
|
(matchZone s WEST))
|
||||||
@@ -456,7 +461,7 @@
|
|||||||
`(whenLet [,to (dictGet ,mp id)
|
`(whenLet [,to (dictGet ,mp id)
|
||||||
mz1 (,mz1 s)
|
mz1 (,mz1 s)
|
||||||
mz2 (,mz2 ,to)]
|
mz2 (,mz2 ,to)]
|
||||||
(unless .isEmpty (mz1.intersection mz2)
|
(unless (or !(= s.angle .angle ,to) .isEmpty (mz1.intersection mz2))
|
||||||
(connectPiece id s ,to mz1 mz2)))))
|
(connectPiece id s ,to mz1 mz2)))))
|
||||||
|
|
||||||
(method :Bool checkMatches [id]
|
(method :Bool checkMatches [id]
|
||||||
|
@@ -25,6 +25,24 @@ class KissExtendedSprite extends flixel.addons.display.FlxExtendedSprite {
|
|||||||
mouseStartPos = FlxG.mouse.getWorldPosition();
|
mouseStartPos = FlxG.mouse.getWorldPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sleazy method just for Habit Puzzles
|
||||||
|
public function rotate(deg:Float) {
|
||||||
|
if (deg < 0) {
|
||||||
|
deg += 360 * Math.ceil(Math.abs(deg / 360));
|
||||||
|
}
|
||||||
|
angle = angle + deg % 360;
|
||||||
|
for (c in connectedSprites) {
|
||||||
|
if (c != this) {
|
||||||
|
c.angle = c.angle + deg % 360;
|
||||||
|
|
||||||
|
var thisCenter = new FlxPoint(x + origin.x, y + origin.y);
|
||||||
|
var cCenter = new FlxPoint(c.x + c.origin.x, c.y + c.origin.y);
|
||||||
|
var offset = cCenter.subtractPoint(thisCenter);
|
||||||
|
c.origin.subtractPoint(offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override function updateDrag() {
|
override function updateDrag() {
|
||||||
var mouseTotalMovement = FlxG.mouse.getWorldPosition().subtractPoint(mouseStartPos);
|
var mouseTotalMovement = FlxG.mouse.getWorldPosition().subtractPoint(mouseStartPos);
|
||||||
var nextPos = dragStartPos.copyTo().addPoint(mouseTotalMovement);
|
var nextPos = dragStartPos.copyTo().addPoint(mouseTotalMovement);
|
||||||
|
Reference in New Issue
Block a user