blocks: Bug fix: only one operation for a piece is permitted

This commit is contained in:
Hajime Hoshi 2016-02-16 03:59:49 +09:00
parent 805b637a18
commit 10d191b8b1

View File

@ -280,20 +280,16 @@ func (s *GameScene) Update(state *GameState) error {
if state.Input.IsRotateRightTrigger() { if state.Input.IsRotateRightTrigger() {
s.currentPieceAngle = s.field.RotatePieceRight(piece, x, y, angle) s.currentPieceAngle = s.field.RotatePieceRight(piece, x, y, angle)
moved = angle != s.currentPieceAngle moved = angle != s.currentPieceAngle
} } else if state.Input.IsRotateLeftTrigger() {
if state.Input.IsRotateLeftTrigger() {
s.currentPieceAngle = s.field.RotatePieceLeft(piece, x, y, angle) s.currentPieceAngle = s.field.RotatePieceLeft(piece, x, y, angle)
moved = angle != s.currentPieceAngle moved = angle != s.currentPieceAngle
} } else if l := state.Input.StateForLeft(); l == 1 || (10 <= l && l%2 == 0) {
if l := state.Input.StateForLeft(); l == 1 || (10 <= l && l%2 == 0) {
s.currentPieceX = s.field.MovePieceToLeft(piece, x, y, angle) s.currentPieceX = s.field.MovePieceToLeft(piece, x, y, angle)
moved = x != s.currentPieceX moved = x != s.currentPieceX
} } else if r := state.Input.StateForRight(); r == 1 || (10 <= r && r%2 == 0) {
if r := state.Input.StateForRight(); r == 1 || (10 <= r && r%2 == 0) {
s.currentPieceX = s.field.MovePieceToRight(piece, x, y, angle) s.currentPieceX = s.field.MovePieceToRight(piece, x, y, angle)
moved = y != s.currentPieceX moved = y != s.currentPieceX
} } else if d := state.Input.StateForDown(); (d-1)%2 == 0 {
if d := state.Input.StateForDown(); (d-1)%2 == 0 {
s.currentPieceY = s.field.DropPiece(piece, x, y, angle) s.currentPieceY = s.field.DropPiece(piece, x, y, angle)
moved = y != s.currentPieceY moved = y != s.currentPieceY
if moved { if moved {