diff --git a/gopher-anim.CI8 b/gopher-anim.CI8 new file mode 100644 index 0000000..53704fa Binary files /dev/null and b/gopher-anim.CI8 differ diff --git a/gopher-anim.png b/gopher-anim.png new file mode 100644 index 0000000..183fba9 Binary files /dev/null and b/gopher-anim.png differ diff --git a/main.go b/main.go index 7b67dff..c47fa3a 100644 --- a/main.go +++ b/main.go @@ -1,18 +1,28 @@ package main import ( + "embed" "fmt" "image" "image/color" + "github.com/clktmr/n64/drivers/cartfs" "github.com/clktmr/n64/drivers/controller" "github.com/clktmr/n64/drivers/display" "github.com/clktmr/n64/drivers/draw" "github.com/clktmr/n64/fonts/gomono12" _ "github.com/clktmr/n64/machine" + "github.com/clktmr/n64/rcp/serial/joybus" + "github.com/clktmr/n64/rcp/texture" "github.com/clktmr/n64/rcp/video" ) +var ( + //go:embed gopher-anim.CI8 + _tutorialFiles embed.FS + tutorialFiles cartfs.FS = cartfs.Embed(_tutorialFiles) +) + var face = gomono12.NewFace() var background = &image.Uniform{color.RGBA{0x7f, 0x7f, 0xaf, 0x0}} @@ -32,6 +42,17 @@ func main() { } }() + gopherFile, err := tutorialFiles.Open("gopher-anim.CI8") + if err != nil { + panic(err) + } + gopherTexture, err := texture.Load(gopherFile) + if err != nil { + panic(err) + } + gopherRect := image.Rect(0, 0, 128, 128) + blows := 0 + for { fb := display.Swap() // Blocks until next VBlank input := <-controllers @@ -43,8 +64,23 @@ func main() { text := fmt.Appendln(nil, "N⁶⁴ - Get N or Get Out ♫") text = fmt.Appendln(text, input[0].Down()) + text = fmt.Appendf(text, "blows: %v/8\n", blows) pt = draw.DrawText(fb, textarea, face, pt, image.Black, nil, text) + gopherFrame := image.Point{} + if blows < 8 { + if input[0].Pressed()&joybus.ButtonA != 0 { + blows++ + } + if input[0].Down()&joybus.ButtonA != 0 { + gopherFrame.X += 128 // blowing gopher + } + } else { + gopherFrame.X += 256 // happy gopher + } + + draw.Over.Draw(fb, gopherRect.Add(pt), gopherTexture, gopherFrame) + draw.Flush() // Blocks until everything is drawn } }