Skip to content

Commit 74768b6

Browse files
author
Allen Ray
committed
update pixel
1 parent cb527ea commit 74768b6

File tree

53 files changed

+342
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+342
-347
lines changed

community/amidakuji/game.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import (
1515
"time"
1616
"unsafe"
1717

18+
glfw "github.com/go-gl/glfw/v3.2/glfw"
1819
gg "github.com/gopxl/pixel-examples/community/amidakuji/glossary"
1920
"github.com/gopxl/pixel-examples/community/amidakuji/glossary/jukebox"
20-
glfw "github.com/go-gl/glfw/v3.2/glfw"
2121

2222
"github.com/gopxl/pixel/v2"
23-
"github.com/gopxl/pixel/v2/pixelgl"
24-
"github.com/gopxl/pixel/v2/text"
23+
"github.com/gopxl/pixel/v2/backends/opengl"
24+
"github.com/gopxl/pixel/v2/ext/text"
2525
"github.com/sqweek/dialog"
2626
"golang.org/x/image/colornames"
2727
)
@@ -49,7 +49,7 @@ type Updater interface {
4949
// Also it manages and draws everything about...
5050
type game struct {
5151
// something system, somthing runtime
52-
window *pixelgl.Window // lazy init
52+
window *opengl.Window // lazy init
5353
bg pixel.RGBA
5454
camera *gg.Camera // lazy init
5555
fpsw *gg.FPSWatch
@@ -429,7 +429,7 @@ func (g *game) Resume() {
429429

430430
func (g *game) SetFullScreenMode(on bool) {
431431
if on {
432-
monitor := pixelgl.PrimaryMonitor()
432+
monitor := opengl.PrimaryMonitor()
433433
width, height := monitor.Size()
434434
// log.Println(monitor.VideoModes()) //
435435
g.window.SetMonitor(monitor)
@@ -447,7 +447,7 @@ func (g *game) SetFullScreenMode(on bool) {
447447
// Read only methods
448448

449449
// WindowDeep is a hacky way to access a window in deep.
450-
// It returns (window *glfw.Window) which is an unexported member inside a (*pixelgl.Window).
450+
// It returns (window *glfw.Window) which is an unexported member inside a (*opengl.Window).
451451
// Read only argument game ignores the pass lock by value warning.
452452
func (g game) WindowDeep() (baseWindow *glfw.Window) {
453453
return *(**glfw.Window)(unsafe.Pointer(reflect.Indirect(reflect.ValueOf(g.window)).FieldByName("window").UnsafeAddr()))
@@ -470,15 +470,15 @@ func (g game) BridgesCount() (sum int) {
470470

471471
// Run the game window and its event loop on main thread.
472472
func (g *game) Run() {
473-
pixelgl.Run(func() {
473+
opengl.Run(func() {
474474
g.RunLazyInit()
475475
g.RunEventLoop()
476476
})
477477
}
478478

479479
func (g *game) RunLazyInit() {
480480
// This window will show up as soon as it is created.
481-
win, err := pixelgl.NewWindow(pixelgl.WindowConfig{
481+
win, err := opengl.NewWindow(opengl.WindowConfig{
482482
Title: title + " (" + version + ")",
483483
Icon: nil,
484484
Bounds: pixel.R(0, 0, g.winWidth, g.winHeight),
@@ -492,8 +492,8 @@ func (g *game) RunLazyInit() {
492492
}
493493
win.SetSmooth(true)
494494

495-
MoveWindowToCenterOfPrimaryMonitor := func(win *pixelgl.Window) {
496-
vmodes := pixelgl.PrimaryMonitor().VideoModes()
495+
MoveWindowToCenterOfPrimaryMonitor := func(win *opengl.Window) {
496+
vmodes := opengl.PrimaryMonitor().VideoModes()
497497
vmodesLast := vmodes[len(vmodes)-1]
498498
biggestResolution := pixel.R(0, 0, float64(vmodesLast.Width), float64(vmodesLast.Height))
499499
win.SetPos(biggestResolution.Center().Sub(win.Bounds().Center()))
@@ -558,15 +558,15 @@ func (g *game) HandlingEvents(dt float64) {
558558
// Notice that all function calls as go routine are non-blocking, but the others will block the main thread.
559559

560560
// system
561-
if g.window.JustReleased(pixelgl.KeyEscape) {
561+
if g.window.JustReleased(opengl.KeyEscape) {
562562
g.window.SetClosed(true)
563563
}
564-
if g.window.JustReleased(pixelgl.KeySpace) {
564+
if g.window.JustReleased(opengl.KeySpace) {
565565
g.Pause()
566566
dialog.Message("%s", "Pause").Title("PPAP").Info()
567567
g.Resume()
568568
}
569-
if g.window.JustReleased(pixelgl.KeyTab) {
569+
if g.window.JustReleased(opengl.KeyTab) {
570570
if g.window.Monitor() == nil {
571571
g.SetFullScreenMode(true)
572572
} else {
@@ -575,12 +575,12 @@ func (g *game) HandlingEvents(dt float64) {
575575
}
576576

577577
// scalpel mode
578-
if g.window.JustReleased(pixelgl.MouseButtonRight) {
578+
if g.window.JustReleased(opengl.MouseButtonRight) {
579579
go func() {
580580
g.isScalpelMode = !g.isScalpelMode
581581
}()
582582
}
583-
if g.window.JustReleased(pixelgl.MouseButtonLeft) {
583+
if g.window.JustReleased(opengl.MouseButtonLeft) {
584584
// ---------------------------------------------------
585585
if !jukebox.IsPlaying() {
586586
jukebox.Play()
@@ -613,18 +613,18 @@ func (g *game) HandlingEvents(dt float64) {
613613
}
614614

615615
// game ctrl
616-
if g.window.JustReleased(pixelgl.Key1) { // shuffle
616+
if g.window.JustReleased(opengl.Key1) { // shuffle
617617
go func() {
618618
g.Shuffle(10, 750)
619619
}()
620620
}
621-
if g.window.JustReleased(pixelgl.Key2) { // find path slow
621+
if g.window.JustReleased(opengl.Key2) { // find path slow
622622
go func() {
623623
g.ResetPaths()
624624
g.AnimatePaths(g.AnimatePath)
625625
}()
626626
}
627-
if g.window.JustReleased(pixelgl.Key3) { // find path fast
627+
if g.window.JustReleased(opengl.Key3) { // find path fast
628628
go func() {
629629
g.ResetPaths()
630630
g.AnimatePaths(func(participant int) {
@@ -634,27 +634,27 @@ func (g *game) HandlingEvents(dt float64) {
634634
}
635635

636636
// camera
637-
if g.window.JustReleased(pixelgl.KeyEnter) {
637+
if g.window.JustReleased(opengl.KeyEnter) {
638638
go func() {
639639
g.camera.Rotate(-90)
640640
}()
641641
}
642-
if g.window.Pressed(pixelgl.KeyRight) {
642+
if g.window.Pressed(opengl.KeyRight) {
643643
go func(dt float64) { // This camera will go diagonal while the case is in middle of rotating the camera.
644644
g.camera.Move(pixel.V(1000*dt, 0).Rotated(-g.camera.Angle()))
645645
}(dt)
646646
}
647-
if g.window.Pressed(pixelgl.KeyLeft) {
647+
if g.window.Pressed(opengl.KeyLeft) {
648648
go func(dt float64) {
649649
g.camera.Move(pixel.V(-1000*dt, 0).Rotated(-g.camera.Angle()))
650650
}(dt)
651651
}
652-
if g.window.Pressed(pixelgl.KeyUp) {
652+
if g.window.Pressed(opengl.KeyUp) {
653653
go func(dt float64) {
654654
g.camera.Move(pixel.V(0, 1000*dt).Rotated(-g.camera.Angle()))
655655
}(dt)
656656
}
657-
if g.window.Pressed(pixelgl.KeyDown) {
657+
if g.window.Pressed(opengl.KeyDown) {
658658
go func(dt float64) {
659659
g.camera.Move(pixel.V(0, -1000*dt).Rotated(-g.camera.Angle()))
660660
}(dt)

community/amidakuji/glossary/cam.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"math"
55

66
"github.com/gopxl/pixel/v2"
7-
"github.com/gopxl/pixel/v2/imdraw"
7+
"github.com/gopxl/pixel/v2/ext/imdraw"
88
"golang.org/x/image/colornames"
99
)
1010

community/amidakuji/glossary/explosive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"sync"
77

88
"github.com/gopxl/pixel/v2"
9-
"github.com/gopxl/pixel/v2/imdraw"
9+
"github.com/gopxl/pixel/v2/ext/imdraw"
1010
)
1111

1212
// -------------------------------------------------------------------------

community/amidakuji/glossary/fpschk.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"time"
88

99
"github.com/gopxl/pixel/v2"
10-
"github.com/gopxl/pixel/v2/imdraw"
11-
"github.com/gopxl/pixel/v2/text"
10+
"github.com/gopxl/pixel/v2/ext/imdraw"
11+
"github.com/gopxl/pixel/v2/ext/text"
1212
"golang.org/x/image/colornames"
1313
)
1414

community/amidakuji/glossary/starfield.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"sync"
77

88
"github.com/gopxl/pixel/v2"
9-
"github.com/gopxl/pixel/v2/imdraw"
9+
"github.com/gopxl/pixel/v2/ext/imdraw"
1010
)
1111

1212
// -------------------------------------------------------------------------

community/amidakuji/glossary/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
_ "image/gif"
1414
_ "image/png"
1515

16-
"github.com/gopxl/pixel/v2"
17-
"github.com/gopxl/pixel/v2/text"
1816
"github.com/golang/freetype/truetype"
17+
"github.com/gopxl/pixel/v2"
18+
"github.com/gopxl/pixel/v2/ext/text"
1919
"golang.org/x/image/font"
2020
"golang.org/x/image/font/basicfont"
2121
)

community/amidakuji/ladder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
gg "github.com/gopxl/pixel-examples/community/amidakuji/glossary"
88

99
"github.com/gopxl/pixel/v2"
10-
"github.com/gopxl/pixel/v2/imdraw"
10+
"github.com/gopxl/pixel/v2/ext/imdraw"
1111
"golang.org/x/image/colornames"
1212
)
1313

community/amidakuji/nametag.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
gg "github.com/gopxl/pixel-examples/community/amidakuji/glossary"
88

99
"github.com/gopxl/pixel/v2"
10-
"github.com/gopxl/pixel/v2/imdraw"
11-
"github.com/gopxl/pixel/v2/text"
10+
"github.com/gopxl/pixel/v2/ext/imdraw"
11+
"github.com/gopxl/pixel/v2/ext/text"
1212
"golang.org/x/image/colornames"
1313
)
1414

community/amidakuji/path.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
gg "github.com/gopxl/pixel-examples/community/amidakuji/glossary"
88

99
"github.com/gopxl/pixel/v2"
10-
"github.com/gopxl/pixel/v2/imdraw"
10+
"github.com/gopxl/pixel/v2/ext/imdraw"
1111
)
1212

1313
// Path is for animating a path to the prize in a ladder.

community/amidakuji/scalpel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
gg "github.com/gopxl/pixel-examples/community/amidakuji/glossary"
88

99
"github.com/gopxl/pixel/v2"
10-
"github.com/gopxl/pixel/v2/imdraw"
10+
"github.com/gopxl/pixel/v2/ext/imdraw"
1111
"golang.org/x/image/colornames"
1212
)
1313

0 commit comments

Comments
 (0)