Implement tilemap
This commit is contained in:
parent
680b2d5269
commit
293b013db4
2 changed files with 39 additions and 1 deletions
BIN
assets/boxes.png
Normal file
BIN
assets/boxes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
40
main.go
40
main.go
|
@ -1,6 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"embed"
|
||||||
|
"image"
|
||||||
|
_ "image/png"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"drjosh.dev/gurgle/engine"
|
"drjosh.dev/gurgle/engine"
|
||||||
|
@ -9,13 +12,48 @@ import (
|
||||||
|
|
||||||
const screenWidth, screenHeight = 320, 240
|
const screenWidth, screenHeight = 320, 240
|
||||||
|
|
||||||
|
//go:embed assets/*
|
||||||
|
var assets embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
|
ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
|
||||||
ebiten.SetWindowTitle("ebiten")
|
ebiten.SetWindowTitle("TODO")
|
||||||
|
|
||||||
|
boxesFile, err := assets.Open("assets/boxes.png")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Couldn't open asset: %v", err)
|
||||||
|
}
|
||||||
|
boxesPNG, _, err := image.Decode(boxesFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Couldn't decode asset: %v", err)
|
||||||
|
}
|
||||||
|
tiles := &engine.Tilemap{
|
||||||
|
Map: [][]int{
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
||||||
|
},
|
||||||
|
Src: ebiten.NewImageFromImage(boxesPNG),
|
||||||
|
TileSize: 16,
|
||||||
|
}
|
||||||
|
|
||||||
if err := ebiten.RunGame(&engine.Game{
|
if err := ebiten.RunGame(&engine.Game{
|
||||||
ScreenHeight: screenHeight,
|
ScreenHeight: screenHeight,
|
||||||
ScreenWidth: screenWidth,
|
ScreenWidth: screenWidth,
|
||||||
Components: []interface{}{
|
Components: []interface{}{
|
||||||
|
tiles,
|
||||||
engine.TPSDisplay{},
|
engine.TPSDisplay{},
|
||||||
},
|
},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue