aboutsummaryrefslogtreecommitdiff
path: root/tris/move.go
diff options
context:
space:
mode:
authorJoop Kiefte <ikojba@gmail.com>2020-09-12 16:37:57 +0200
committerJoop Kiefte <ikojba@gmail.com>2020-09-12 16:37:57 +0200
commit38293b6d5df68eff2794576bb64f82c2715429b6 (patch)
treec6d839a2a055be9b4045fa8acc3d426ae74580fa /tris/move.go
parentbd80439d9620f02b124b274cd79b8c8d30b69016 (diff)
Add more comments
Diffstat (limited to 'tris/move.go')
-rw-r--r--tris/move.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/tris/move.go b/tris/move.go
index 127ce06..c5ba1ef 100644
--- a/tris/move.go
+++ b/tris/move.go
@@ -3,6 +3,7 @@ package tris
// As at the bottom of https://tetris.fandom.com/wiki/SRS but Y inverse because we start Y at the top
type Kicks map[Rotation][]Point
+// Kics for all pieces except I and O pieces
var K3CW = Kicks{
0: {{X:0, Y:0}, {X:-1, Y:0}, {X:-1, Y: -1}, {X:0, Y:2}, {X:-1, Y:2}},
1: {{X:0, Y:0}, {X:1, Y:0}, {X:1, Y: 1}, {X:0, Y:-2}, {X:1, Y:-2}},
@@ -10,6 +11,7 @@ var K3CW = Kicks{
3: {{X:0, Y:0}, {X:-1, Y:0}, {X:-1, Y: 1}, {X:0, Y:-2}, {X:-1, Y:-2}},
}
+// Long Bar (I piece) Kicks
var LCW = Kicks{
0: {{X:0, Y:0}, {X:-2, Y:0}, {X:1, Y: 0}, {X:-2, Y:1}, {X:1, Y:-2}},
1: {{X:0, Y:0}, {X:-1, Y:0}, {X:2, Y: 0}, {X:-1, Y:-2}, {X:2, Y:1}},
@@ -17,6 +19,7 @@ var LCW = Kicks{
3: {{X:0, Y:0}, {X:1, Y:0}, {X:-2, Y: 0}, {X:1, Y:2}, {X:-2, Y:-1}},
}
+// Try all possible kicks
func (ks Kicks) Try(rot Rotation, reverse bool, p Placement, f Field) (np Placement) {
orot := (rot + 3)%4
if reverse { // for going backwards, you start from one more
@@ -38,6 +41,7 @@ func (ks Kicks) Try(rot Rotation, reverse bool, p Placement, f Field) (np Placem
return p
}
+// Floor checks if the piece touches something underneath it
func (p Placement) Floor(f Field) bool {
fp := p
fp.Y++