aboutsummaryrefslogtreecommitdiff
path: root/tris/move.go
diff options
context:
space:
mode:
authorJoop Kiefte <ikojba@gmail.com>2020-09-12 08:25:24 +0200
committerJoop Kiefte <ikojba@gmail.com>2020-09-12 08:25:24 +0200
commitac3196415d5d87a745d339f1548573b0b5745c41 (patch)
treeb296d16875d98b965b7520797294358156ee3b08 /tris/move.go
parentbc89ff176ddf7cf9627df15e8624d94a040a1d0b (diff)
Creating move routine to implement kicks in
Diffstat (limited to 'tris/move.go')
-rw-r--r--tris/move.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/tris/move.go b/tris/move.go
new file mode 100644
index 0000000..0e081ef
--- /dev/null
+++ b/tris/move.go
@@ -0,0 +1,18 @@
+package tris
+
+func (p Placement) Move(f Field, rot Rotation, x, y int) (np Placement, floor, topout bool) {
+ np = p
+ np.Rot = rot
+ np.X = x
+ np.Y = y
+ if !np.Collide(f) { // free air
+ return np, false, false
+ }
+ np = p // last resort reset p
+ fp := np
+ fp.Y++
+ if fp.Collide(f) && np.Y < 0 {
+ return np, true, true
+ }
+ return np, fp.Collide(f), false
+}