mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 04:22:05 +01:00
go fmt
This commit is contained in:
parent
7cea6f4bc8
commit
2b4dc28d91
@ -68,18 +68,15 @@ func (s *GameScene) Update(state *GameState) {
|
|||||||
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
|
||||||
}
|
}
|
||||||
if l := state.Input.StateForKey(ui.KeyLeft);
|
if l := state.Input.StateForKey(ui.KeyLeft); l == 1 || (10 <= l && l%2 == 0) {
|
||||||
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
|
||||||
}
|
}
|
||||||
if r := state.Input.StateForKey(ui.KeyRight);
|
if r := state.Input.StateForKey(ui.KeyRight); r == 1 || (10 <= r && r%2 == 0) {
|
||||||
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
|
||||||
}
|
}
|
||||||
if d := state.Input.StateForKey(ui.KeyDown);
|
if d := state.Input.StateForKey(ui.KeyDown); (d-1)%2 == 0 {
|
||||||
(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
|
||||||
}
|
}
|
||||||
|
@ -170,12 +170,12 @@ func (p *Piece) isBlocked(i, j int, angle Angle) bool {
|
|||||||
case Angle0:
|
case Angle0:
|
||||||
case Angle90:
|
case Angle90:
|
||||||
i2 = j
|
i2 = j
|
||||||
j2 = size-1-i
|
j2 = size - 1 - i
|
||||||
case Angle180:
|
case Angle180:
|
||||||
i2 = size-1-i
|
i2 = size - 1 - i
|
||||||
j2 = size-1-j
|
j2 = size - 1 - j
|
||||||
case Angle270:
|
case Angle270:
|
||||||
i2 = size-1-j
|
i2 = size - 1 - j
|
||||||
j2 = i
|
j2 = i
|
||||||
}
|
}
|
||||||
return p.blocks[i2][j2]
|
return p.blocks[i2][j2]
|
||||||
@ -218,8 +218,8 @@ func (p *Piece) Draw(context graphics.Context, fieldX, fieldY int, pieceX, piece
|
|||||||
}
|
}
|
||||||
|
|
||||||
geoMat := matrix.IdentityGeometry()
|
geoMat := matrix.IdentityGeometry()
|
||||||
x := fieldX + pieceX * blockWidth
|
x := fieldX + pieceX*blockWidth
|
||||||
y := fieldY + pieceY * blockHeight
|
y := fieldY + pieceY*blockHeight
|
||||||
geoMat.Translate(float64(x), float64(y))
|
geoMat.Translate(float64(x), float64(y))
|
||||||
|
|
||||||
drawBlocks(context, blocks, geoMat)
|
drawBlocks(context, blocks, geoMat)
|
||||||
|
@ -31,8 +31,8 @@ func (s *TitleScene) Draw(context graphics.Context) {
|
|||||||
drawLogo(context, "BLOCKS")
|
drawLogo(context, "BLOCKS")
|
||||||
|
|
||||||
message := "PRESS SPACE TO START"
|
message := "PRESS SPACE TO START"
|
||||||
x := (ScreenWidth-textWidth(message)) / 2
|
x := (ScreenWidth - textWidth(message)) / 2
|
||||||
y := ScreenHeight-48
|
y := ScreenHeight - 48
|
||||||
drawTextWithShadow(context, message, x, y, 1, color.RGBA{0x80, 0, 0, 0xff})
|
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
|
dx := (-c / 4) % textureWidth
|
||||||
dy := (c/4) % textureHeight
|
dy := (c / 4) % textureHeight
|
||||||
geo := matrix.IdentityGeometry()
|
geo := matrix.IdentityGeometry()
|
||||||
geo.Translate(float64(dx), float64(dy))
|
geo.Translate(float64(dx), float64(dy))
|
||||||
clr := matrix.IdentityColor()
|
clr := matrix.IdentityColor()
|
||||||
|
Loading…
Reference in New Issue
Block a user