aboutsummaryrefslogtreecommitdiff
path: root/tris/move.go
diff options
context:
space:
mode:
Diffstat (limited to 'tris/move.go')
-rw-r--r--tris/move.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/tris/move.go b/tris/move.go
index 0e081ef..29140b8 100644
--- a/tris/move.go
+++ b/tris/move.go
@@ -1,5 +1,11 @@
package tris
+func (p Placement) Floor(f Field) bool {
+ fp := p
+ fp.Y++
+ return fp.Collide(f)
+}
+
func (p Placement) Move(f Field, rot Rotation, x, y int) (np Placement, floor, topout bool) {
np = p
np.Rot = rot
@@ -9,10 +15,8 @@ func (p Placement) Move(f Field, rot Rotation, x, y int) (np Placement, floor, t
return np, false, false
}
np = p // last resort reset p
- fp := np
- fp.Y++
- if fp.Collide(f) && np.Y < 0 {
+ if np.Floor(f) && np.Y < 0 {
return np, true, true
}
- return np, fp.Collide(f), false
+ return np, np.Floor(f), false
}