diff --git a/examples/animation/main.go b/examples/animation/main.go index ce62bb62b..cac59bf09 100644 --- a/examples/animation/main.go +++ b/examples/animation/main.go @@ -35,7 +35,7 @@ const ( frameOY = 32 frameWidth = 32 frameHeight = 32 - frameNum = 8 + frameCount = 8 ) var ( @@ -55,7 +55,7 @@ func (g *Game) Draw(screen *ebiten.Image) { op := &ebiten.DrawImageOptions{} op.GeoM.Translate(-float64(frameWidth)/2, -float64(frameHeight)/2) op.GeoM.Translate(screenWidth/2, screenHeight/2) - i := (g.count / 5) % frameNum + i := (g.count / 5) % frameCount sx, sy := frameOX+i*frameWidth, frameOY screen.DrawImage(runnerImage.SubImage(image.Rect(sx, sy, sx+frameWidth, sy+frameHeight)).(*ebiten.Image), op) } diff --git a/examples/blocks/blocks/field.go b/examples/blocks/blocks/field.go index bd7ea6412..489c23a46 100644 --- a/examples/blocks/blocks/field.go +++ b/examples/blocks/blocks/field.go @@ -22,7 +22,7 @@ const maxFlushCount = 20 // Field represents a game field with block states. type Field struct { - blocks [fieldBlockNumX][fieldBlockNumY]BlockType + blocks [fieldBlockCountX][fieldBlockCountY]BlockType flushCount int onEndFlushAnimating func(int) } @@ -30,13 +30,13 @@ type Field struct { // IsBlocked returns a boolean value indicating whether // there is a block at position (x, y) on the field. func (f *Field) IsBlocked(x, y int) bool { - if x < 0 || fieldBlockNumX <= x { + if x < 0 || fieldBlockCountX <= x { return true } if y < 0 { return false } - if fieldBlockNumY <= y { + if fieldBlockCountY <= y { return true } return f.blocks[x][y] != BlockTypeNone @@ -116,7 +116,7 @@ func (f *Field) SetEndFlushAnimating(fn func(lines int)) { // flushable returns a boolean value indicating whether // there is a flushable line in the field. func (f *Field) flushable() bool { - for j := fieldBlockNumY - 1; 0 <= j; j-- { + for j := fieldBlockCountY - 1; 0 <= j; j-- { if f.flushableLine(j) { return true } @@ -127,7 +127,7 @@ func (f *Field) flushable() bool { // flushableLine returns a boolean value indicating whether // the line j is flushabled or not. func (f *Field) flushableLine(j int) bool { - for i := 0; i < fieldBlockNumX; i++ { + for i := 0; i < fieldBlockCountX; i++ { if f.blocks[i][j] == BlockTypeNone { return false } @@ -140,13 +140,13 @@ func (f *Field) setBlock(x, y int, blockType BlockType) { } func (f *Field) endFlushAnimating() int { - flushedLineNum := 0 - for j := fieldBlockNumY - 1; 0 <= j; j-- { - if f.flushLine(j + flushedLineNum) { - flushedLineNum++ + flushedLineCount := 0 + for j := fieldBlockCountY - 1; 0 <= j; j-- { + if f.flushLine(j + flushedLineCount) { + flushedLineCount++ } } - return flushedLineNum + return flushedLineCount } // flushLine flushes the line j if possible, and if the line is flushed, @@ -155,17 +155,17 @@ func (f *Field) endFlushAnimating() int { // flushLine returns a boolean value indicating whether // the line is actually flushed. func (f *Field) flushLine(j int) bool { - for i := 0; i < fieldBlockNumX; i++ { + for i := 0; i < fieldBlockCountX; i++ { if f.blocks[i][j] == BlockTypeNone { return false } } for j2 := j; 1 <= j2; j2-- { - for i := 0; i < fieldBlockNumX; i++ { + for i := 0; i < fieldBlockCountX; i++ { f.blocks[i][j2] = f.blocks[i][j2-1] } } - for i := 0; i < fieldBlockNumX; i++ { + for i := 0; i < fieldBlockCountX; i++ { f.blocks[i][0] = BlockTypeNone } return true @@ -204,13 +204,13 @@ func flushingColor(rate float64) ebiten.ColorM { func (f *Field) Draw(r *ebiten.Image, x, y int) { fc := flushingColor(float64(f.flushCount) / maxFlushCount) - for j := 0; j < fieldBlockNumY; j++ { + for j := 0; j < fieldBlockCountY; j++ { if f.flushableLine(j) { - for i := 0; i < fieldBlockNumX; i++ { + for i := 0; i < fieldBlockCountX; i++ { drawBlock(r, f.blocks[i][j], i*blockWidth+x, j*blockHeight+y, fc) } } else { - for i := 0; i < fieldBlockNumX; i++ { + for i := 0; i < fieldBlockCountX; i++ { drawBlock(r, f.blocks[i][j], i*blockWidth+x, j*blockHeight+y, ebiten.ColorM{}) } } diff --git a/examples/blocks/blocks/gamescene.go b/examples/blocks/blocks/gamescene.go index 9bed83014..30a69005f 100644 --- a/examples/blocks/blocks/gamescene.go +++ b/examples/blocks/blocks/gamescene.go @@ -187,8 +187,8 @@ func (s *GameScene) drawBackground(r *ebiten.Image) { } const ( - fieldWidth = blockWidth * fieldBlockNumX - fieldHeight = blockHeight * fieldBlockNumY + fieldWidth = blockWidth * fieldBlockCountX + fieldHeight = blockHeight * fieldBlockCountY ) func (s *GameScene) choosePiece() *Piece { diff --git a/examples/blocks/blocks/piece.go b/examples/blocks/blocks/piece.go index 1019746c2..ac926a6c8 100644 --- a/examples/blocks/blocks/piece.go +++ b/examples/blocks/blocks/piece.go @@ -159,10 +159,10 @@ func init() { } const ( - blockWidth = 10 - blockHeight = 10 - fieldBlockNumX = 10 - fieldBlockNumY = 20 + blockWidth = 10 + blockHeight = 10 + fieldBlockCountX = 10 + fieldBlockCountY = 20 ) func drawBlock(r *ebiten.Image, block BlockType, x, y int, clr ebiten.ColorM) { @@ -180,7 +180,7 @@ func drawBlock(r *ebiten.Image, block BlockType, x, y int, clr ebiten.ColorM) { func (p *Piece) InitialPosition() (int, int) { size := len(p.blocks) - x := (fieldBlockNumX - size) / 2 + x := (fieldBlockCountX - size) / 2 y := 0 Loop: for j := 0; j < size; j++ { diff --git a/examples/camera/main.go b/examples/camera/main.go index 291d2e29a..e20c6ce3a 100644 --- a/examples/camera/main.go +++ b/examples/camera/main.go @@ -38,8 +38,8 @@ const ( ) const ( - tileSize = 16 - tileXNum = 25 + tileSize = 16 + tileXCount = 25 ) const ( @@ -175,8 +175,8 @@ func (g *Game) Draw(screen *ebiten.Image) { op := &ebiten.DrawImageOptions{} op.GeoM.Translate(float64((i%worldSizeX)*tileSize), float64((i/worldSizeX)*tileSize)) - sx := (t % tileXNum) * tileSize - sy := (t / tileXNum) * tileSize + sx := (t % tileXCount) * tileSize + sy := (t / tileXCount) * tileSize g.world.DrawImage(tilesImage.SubImage(image.Rect(sx, sy, sx+tileSize, sy+tileSize)).(*ebiten.Image), op) } } diff --git a/examples/snake/main.go b/examples/snake/main.go index fcd65a632..468939105 100644 --- a/examples/snake/main.go +++ b/examples/snake/main.go @@ -30,11 +30,11 @@ import ( ) const ( - screenWidth = 640 - screenHeight = 480 - gridSize = 10 - xNumInScreen = screenWidth / gridSize - yNumInScreen = screenHeight / gridSize + screenWidth = 640 + screenHeight = 480 + gridSize = 10 + xGridCountInScreen = screenWidth / gridSize + yGridCountInScreen = screenHeight / gridSize ) const ( @@ -83,8 +83,8 @@ func (g *Game) collidesWithSelf() bool { func (g *Game) collidesWithWall() bool { return g.snakeBody[0].X < 0 || g.snakeBody[0].Y < 0 || - g.snakeBody[0].X >= xNumInScreen || - g.snakeBody[0].Y >= yNumInScreen + g.snakeBody[0].X >= xGridCountInScreen || + g.snakeBody[0].Y >= yGridCountInScreen } func (g *Game) needsToMoveSnake() bool { @@ -96,8 +96,8 @@ func (g *Game) reset() { g.apple.Y = 3 * gridSize g.moveTime = 4 g.snakeBody = g.snakeBody[:1] - g.snakeBody[0].X = xNumInScreen / 2 - g.snakeBody[0].Y = yNumInScreen / 2 + g.snakeBody[0].X = xGridCountInScreen / 2 + g.snakeBody[0].Y = yGridCountInScreen / 2 g.score = 0 g.level = 1 g.moveDirection = dirNone @@ -130,8 +130,8 @@ func (g *Game) Update() error { } if g.collidesWithApple() { - g.apple.X = rand.Intn(xNumInScreen - 1) - g.apple.Y = rand.Intn(yNumInScreen - 1) + g.apple.X = rand.Intn(xGridCountInScreen - 1) + g.apple.Y = rand.Intn(yGridCountInScreen - 1) g.snakeBody = append(g.snakeBody, Position{ X: g.snakeBody[len(g.snakeBody)-1].X, Y: g.snakeBody[len(g.snakeBody)-1].Y, @@ -195,8 +195,8 @@ func newGame() *Game { moveTime: 4, snakeBody: make([]Position, 1), } - g.snakeBody[0].X = xNumInScreen / 2 - g.snakeBody[0].Y = yNumInScreen / 2 + g.snakeBody[0].X = xGridCountInScreen / 2 + g.snakeBody[0].Y = yGridCountInScreen / 2 return g } diff --git a/examples/stars/main.go b/examples/stars/main.go index 90ffee460..ce7397b48 100644 --- a/examples/stars/main.go +++ b/examples/stars/main.go @@ -31,7 +31,7 @@ const ( screenWidth = 640 screenHeight = 480 scale = 64 - starsNum = 1024 + starsCount = 1024 ) type Star struct { @@ -69,12 +69,12 @@ func (s *Star) Draw(screen *ebiten.Image) { } type Game struct { - stars [starsNum]Star + stars [starsCount]Star } func NewGame() *Game { g := &Game{} - for i := 0; i < starsNum; i++ { + for i := 0; i < starsCount; i++ { g.stars[i].Init() } return g @@ -82,14 +82,14 @@ func NewGame() *Game { func (g *Game) Update() error { x, y := ebiten.CursorPosition() - for i := 0; i < starsNum; i++ { + for i := 0; i < starsCount; i++ { g.stars[i].Update(float64(x*scale), float64(y*scale)) } return nil } func (g *Game) Draw(screen *ebiten.Image) { - for i := 0; i < starsNum; i++ { + for i := 0; i < starsCount; i++ { g.stars[i].Draw(screen) } } diff --git a/examples/tiles/main.go b/examples/tiles/main.go index ca2b2a187..c26405aff 100644 --- a/examples/tiles/main.go +++ b/examples/tiles/main.go @@ -64,20 +64,20 @@ func (g *Game) Update() error { func (g *Game) Draw(screen *ebiten.Image) { w, _ := tilesImage.Size() - tileXNum := w / tileSize + tileXCount := w / tileSize // Draw each tile with each DrawImage call. // As the source images of all DrawImage calls are always same, // this rendering is done very efficiently. // For more detail, see https://pkg.go.dev/github.com/hajimehoshi/ebiten/v2#Image.DrawImage - const xNum = screenWidth / tileSize + const xCount = screenWidth / tileSize for _, l := range g.layers { for i, t := range l { op := &ebiten.DrawImageOptions{} - op.GeoM.Translate(float64((i%xNum)*tileSize), float64((i/xNum)*tileSize)) + op.GeoM.Translate(float64((i%xCount)*tileSize), float64((i/xCount)*tileSize)) - sx := (t % tileXNum) * tileSize - sy := (t / tileXNum) * tileSize + sx := (t % tileXCount) * tileSize + sy := (t / tileXCount) * tileSize screen.DrawImage(tilesImage.SubImage(image.Rect(sx, sy, sx+tileSize, sy+tileSize)).(*ebiten.Image), op) } }