Skip to content

Commit

Permalink
Merge pull request #4 from dusk125/atlas-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
dusk125 authored Aug 17, 2024
2 parents a6e31f9 + 0ded3b1 commit 1c3e930
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/atlas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Atlas Extension

This is a simple example of the texture atlas extension.
Binary file added ext/atlas/hiking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions ext/atlas/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"github.com/gopxl/pixel/v2"
"github.com/gopxl/pixel/v2/backends/opengl"
"github.com/gopxl/pixel/v2/ext/atlas"
"golang.org/x/image/colornames"
)

var (
Atlas atlas.Atlas
group = Atlas.MakeGroup()
hiking = group.AddFile("hiking.png")
gopher = Atlas.AddFile("thegopherproject.png")
)

func run() {
cfg := opengl.WindowConfig{
Title: "Atlas example",
Bounds: pixel.R(0, 0, 1024, 768),
}
win, err := opengl.NewWindow(cfg)
if err != nil {
panic(err)
}
defer win.Destroy()

Atlas.Pack()

for !win.Closed() {
if win.JustPressed(pixel.KeyEscape) {
win.SetClosed(true)
}

win.Clear(colornames.Skyblue)

hiking.Draw(win, pixel.IM.Moved(win.Bounds().Center()))
gopher.Draw(win, pixel.IM.Moved(win.Bounds().Center()))

win.Update()
}
}

func main() {
opengl.Run(run)
}
Binary file added ext/atlas/thegopherproject.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1c3e930

Please sign in to comment.