aboutsummaryrefslogtreecommitdiff
path: root/tris/move.go
blob: 0e081ef87ae4d044d0b7d7258a96f1a1f32635e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
}