Skip to content

Commit 5364896

Browse files
committed
✨ (sudoku-game): add layout for sudoku game to show ui
1 parent 943c28a commit 5364896

File tree

13 files changed

+337
-7
lines changed

13 files changed

+337
-7
lines changed

cmd/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"log"
5+
6+
"github.com/hajimehoshi/ebiten/v2"
7+
"github.com/leetcode-golang-classroom/sudoku-game/internal/layout"
8+
)
9+
10+
func main() {
11+
ebiten.SetWindowSize(layout.ScreenWidth, layout.ScreenHeight)
12+
ebiten.SetWindowTitle("Sudoku Board")
13+
gameLayout := layout.NewGameLayout()
14+
if err := ebiten.RunGame(gameLayout); err != nil {
15+
log.Fatal(err)
16+
}
17+
}

go.mod

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ module github.com/leetcode-golang-classroom/sudoku-game
22

33
go 1.24.0
44

5-
require github.com/stretchr/testify v1.11.1
5+
require (
6+
github.com/hajimehoshi/ebiten/v2 v2.8.8
7+
github.com/stretchr/testify v1.11.1
8+
)
69

710
require (
811
github.com/davecgh/go-spew v1.1.1 // indirect
12+
github.com/ebitengine/gomobile v0.0.0-20240911145611-4856209ac325 // indirect
13+
github.com/ebitengine/hideconsole v1.0.0 // indirect
14+
github.com/ebitengine/purego v0.8.0 // indirect
15+
github.com/go-text/typesetting v0.2.0 // indirect
16+
github.com/jezek/xgb v1.1.1 // indirect
917
github.com/pmezard/go-difflib v1.0.0 // indirect
18+
golang.org/x/image v0.20.0 // indirect
19+
golang.org/x/sync v0.8.0 // indirect
20+
golang.org/x/sys v0.25.0 // indirect
21+
golang.org/x/text v0.18.0 // indirect
1022
gopkg.in/yaml.v3 v3.0.1 // indirect
1123
)

go.sum

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/ebitengine/gomobile v0.0.0-20240911145611-4856209ac325 h1:Gk1XUEttOk0/hb6Tq3WkmutWa0ZLhNn/6fc6XZpM7tM=
4+
github.com/ebitengine/gomobile v0.0.0-20240911145611-4856209ac325/go.mod h1:ulhSQcbPioQrallSuIzF8l1NKQoD7xmMZc5NxzibUMY=
5+
github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj1yReDqE=
6+
github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A=
7+
github.com/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE=
8+
github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
9+
github.com/go-text/typesetting v0.2.0 h1:fbzsgbmk04KiWtE+c3ZD4W2nmCRzBqrqQOvYlwAOdho=
10+
github.com/go-text/typesetting v0.2.0/go.mod h1:2+owI/sxa73XA581LAzVuEBZ3WEEV2pXeDswCH/3i1I=
11+
github.com/go-text/typesetting-utils v0.0.0-20240317173224-1986cbe96c66 h1:GUrm65PQPlhFSKjLPGOZNPNxLCybjzjYBzjfoBGaDUY=
12+
github.com/go-text/typesetting-utils v0.0.0-20240317173224-1986cbe96c66/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
13+
github.com/hajimehoshi/bitmapfont/v3 v3.2.0 h1:0DISQM/rseKIJhdF29AkhvdzIULqNIIlXAGWit4ez1Q=
14+
github.com/hajimehoshi/bitmapfont/v3 v3.2.0/go.mod h1:8gLqGatKVu0pwcNCJguW3Igg9WQqVXF0zg/RvrGQWyg=
15+
github.com/hajimehoshi/ebiten/v2 v2.8.8 h1:xyMxOAn52T1tQ+j3vdieZ7auDBOXmvjUprSrxaIbsi8=
16+
github.com/hajimehoshi/ebiten/v2 v2.8.8/go.mod h1:durJ05+OYnio9b8q0sEtOgaNeBEQG7Yr7lRviAciYbs=
17+
github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4=
18+
github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
19+
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
20+
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
321
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
422
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
523
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
624
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
25+
golang.org/x/image v0.20.0 h1:7cVCUjQwfL18gyBJOmYvptfSHS8Fb3YUDtfLIZ7Nbpw=
26+
golang.org/x/image v0.20.0/go.mod h1:0a88To4CYVBAHp5FXJm8o7QbUl37Vd85ply1vyD8auM=
27+
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
28+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
29+
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
30+
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
31+
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
32+
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
33+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
734
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
835
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
936
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/fonts/embed.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2022 The Ebitengine Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package fonts
16+
17+
import (
18+
_ "embed"
19+
)
20+
21+
var (
22+
//go:embed mplus-1p-regular.ttf
23+
MPlus1pRegular_ttf []byte
24+
25+
//go:embed pressstart2p.ttf
26+
PressStart2P_ttf []byte
27+
28+
//go:embed noto-emoji-regular.ttf
29+
NotoEmojiRegular_ttf []byte
30+
)

internal/fonts/license.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# License
2+
3+
## mplus-1p-regular.ttf
4+
5+
```
6+
M+ FONTS Copyright (C) 2002-2015 M+ FONTS PROJECT
7+
8+
-
9+
10+
LICENSE_E
11+
12+
13+
14+
15+
These fonts are free software.
16+
Unlimited permission is granted to use, copy, and distribute them, with
17+
or without modification, either commercially or noncommercially.
18+
THESE FONTS ARE PROVIDED "AS IS" WITHOUT WARRANTY.
19+
20+
21+
http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/
22+
```
23+
24+
## PressStart2P-vaV7.ttf
25+
26+
```
27+
Copyright (c) 2011, Cody "CodeMan38" Boisclair (cody@zone38.net),
28+
with Reserved Font Name "Press Start".
29+
30+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
31+
```
1.58 MB
Binary file not shown.
858 KB
Binary file not shown.

internal/fonts/pressstart2p.ttf

80.5 KB
Binary file not shown.

internal/game/cell.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ package game
44
type CellType int
55

66
const (
7-
Empty CellType = iota // 空格
8-
Preset // 題目預設的數字
9-
Input // 玩家輸入的數字
7+
Empty CellType = iota // 空格
8+
Preset // 題目預設的數字
9+
Input // 玩家輸入的數字
10+
InputConflict // 輸入數值有 conflict
1011
)
1112

1213
// Cell 代表數獨的一個格子

internal/game/sudoku.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ func NewBoard() *Board {
2323

2424
// Game - 遊戲結構
2525
type Game struct {
26-
board *Board
26+
Board *Board
2727
}
2828

2929
// NewGame - 建構遊戲結構
3030
func NewGame() *Game {
3131
return &Game{
32-
board: NewBoard(),
32+
Board: NewBoard(),
3333
}
3434
}

0 commit comments

Comments
 (0)