From fb4343af2191674fe46768dcb563c082193c0d8a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 22 Jan 2018 21:07:07 +0900 Subject: [PATCH] examples/blocks: Reduce members from GameScene --- examples/blocks/blocks/gamescene.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/blocks/blocks/gamescene.go b/examples/blocks/blocks/gamescene.go index 5a9f8ed0f..868cb57d4 100644 --- a/examples/blocks/blocks/gamescene.go +++ b/examples/blocks/blocks/gamescene.go @@ -127,7 +127,6 @@ func drawTextBoxContent(r *ebiten.Image, content string, x, y, width int) { type GameScene struct { field *Field - rand *rand.Rand currentPiece *Piece currentPieceX int currentPieceY int @@ -135,16 +134,18 @@ type GameScene struct { currentPieceAngle Angle nextPiece *Piece landingCount int - currentFrame int score int lines int gameover bool } +func init() { + rand.Seed(time.Now().UnixNano()) +} + func NewGameScene() *GameScene { return &GameScene{ field: &Field{}, - rand: rand.New(rand.NewSource(time.Now().UnixNano())), } } @@ -180,7 +181,7 @@ const ( func (s *GameScene) choosePiece() *Piece { num := int(BlockTypeMax) - blockType := BlockType(s.rand.Intn(num) + 1) + blockType := BlockType(rand.Intn(num) + 1) return Pieces[blockType] } @@ -225,8 +226,6 @@ func (s *GameScene) Update(state *GameState) error { return nil } - s.currentFrame++ - const maxLandingCount = ebiten.FPS if s.currentPiece == nil { s.initCurrentPiece(s.choosePiece())