This commit is contained in:
Hajime Hoshi 2014-01-07 23:29:12 +09:00
parent 7cea6f4bc8
commit 2b4dc28d91
3 changed files with 13 additions and 16 deletions

View File

@ -68,18 +68,15 @@ func (s *GameScene) Update(state *GameState) {
s.currentPieceAngle = s.field.RotatePieceRight(piece, x, y, angle)
moved = angle != s.currentPieceAngle
}
if l := state.Input.StateForKey(ui.KeyLeft);
l == 1 || (10 <= l && l % 2 == 0) {
if l := state.Input.StateForKey(ui.KeyLeft); l == 1 || (10 <= l && l%2 == 0) {
s.currentPieceX = s.field.MovePieceToLeft(piece, x, y, angle)
moved = x != s.currentPieceX
}
if r := state.Input.StateForKey(ui.KeyRight);
r == 1 || (10 <= r && r % 2 == 0) {
if r := state.Input.StateForKey(ui.KeyRight); r == 1 || (10 <= r && r%2 == 0) {
s.currentPieceX = s.field.MovePieceToRight(piece, x, y, angle)
moved = y != s.currentPieceX
}
if d := state.Input.StateForKey(ui.KeyDown);
(d - 1) % 2 == 0 {
if d := state.Input.StateForKey(ui.KeyDown); (d-1)%2 == 0 {
s.currentPieceY = s.field.DropPiece(piece, x, y, angle)
moved = y != s.currentPieceY
}

View File

@ -170,12 +170,12 @@ func (p *Piece) isBlocked(i, j int, angle Angle) bool {
case Angle0:
case Angle90:
i2 = j
j2 = size-1-i
j2 = size - 1 - i
case Angle180:
i2 = size-1-i
j2 = size-1-j
i2 = size - 1 - i
j2 = size - 1 - j
case Angle270:
i2 = size-1-j
i2 = size - 1 - j
j2 = i
}
return p.blocks[i2][j2]
@ -218,8 +218,8 @@ func (p *Piece) Draw(context graphics.Context, fieldX, fieldY int, pieceX, piece
}
geoMat := matrix.IdentityGeometry()
x := fieldX + pieceX * blockWidth
y := fieldY + pieceY * blockHeight
x := fieldX + pieceX*blockWidth
y := fieldY + pieceY*blockHeight
geoMat.Translate(float64(x), float64(y))
drawBlocks(context, blocks, geoMat)

View File

@ -31,8 +31,8 @@ func (s *TitleScene) Draw(context graphics.Context) {
drawLogo(context, "BLOCKS")
message := "PRESS SPACE TO START"
x := (ScreenWidth-textWidth(message)) / 2
y := ScreenHeight-48
x := (ScreenWidth - textWidth(message)) / 2
y := ScreenHeight - 48
drawTextWithShadow(context, message, x, y, 1, color.RGBA{0x80, 0, 0, 0xff})
}
@ -52,8 +52,8 @@ func drawTitleBackground(context graphics.Context, c int) {
}
}
dx := (-c/4) % textureWidth
dy := (c/4) % textureHeight
dx := (-c / 4) % textureWidth
dy := (c / 4) % textureHeight
geo := matrix.IdentityGeometry()
geo.Translate(float64(dx), float64(dy))
clr := matrix.IdentityColor()