2021-07-23 13:12:54 +10:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-07-25 14:15:39 +10:00
|
|
|
"embed"
|
|
|
|
_ "image/png"
|
2021-07-23 13:12:54 +10:00
|
|
|
"log"
|
|
|
|
|
|
|
|
"drjosh.dev/gurgle/engine"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
const screenWidth, screenHeight = 320, 240
|
|
|
|
|
2021-07-26 21:19:12 +10:00
|
|
|
//go:embed assets
|
2021-07-25 14:15:39 +10:00
|
|
|
var assets embed.FS
|
|
|
|
|
2021-07-23 13:12:54 +10:00
|
|
|
func main() {
|
|
|
|
ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
|
2021-07-25 14:15:39 +10:00
|
|
|
ebiten.SetWindowTitle("TODO")
|
|
|
|
|
2021-07-31 16:38:54 +10:00
|
|
|
engine.AssetFS = assets
|
2021-07-25 15:03:10 +10:00
|
|
|
|
2021-07-29 15:11:56 +10:00
|
|
|
staticTiles := [][]engine.StaticTile{
|
2021-07-29 15:09:00 +10:00
|
|
|
{0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},
|
|
|
|
{2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3},
|
|
|
|
}
|
|
|
|
|
|
|
|
tiles := make([][]engine.Tile, len(staticTiles))
|
2021-07-30 16:46:15 +10:00
|
|
|
for j, row := range staticTiles {
|
|
|
|
tiles[j] = make([]engine.Tile, len(row))
|
|
|
|
for i, t := range row {
|
|
|
|
tiles[j][i] = t
|
2021-07-29 15:09:00 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-31 16:46:12 +10:00
|
|
|
tiles[4][5] = &engine.AnimatedTile{
|
2021-07-31 17:15:32 +10:00
|
|
|
Anim: engine.Anim{
|
|
|
|
Def: &engine.AnimDef{
|
|
|
|
Frames: []engine.AnimFrame{
|
|
|
|
{Frame: 0, DurationTicks: 16},
|
|
|
|
{Frame: 1, DurationTicks: 16},
|
|
|
|
{Frame: 2, DurationTicks: 16},
|
|
|
|
},
|
|
|
|
Loop: true,
|
|
|
|
},
|
2021-07-30 16:11:01 +10:00
|
|
|
},
|
|
|
|
}
|
2021-07-31 16:46:12 +10:00
|
|
|
tiles[6][7] = &engine.AnimatedTile{
|
2021-07-31 17:15:32 +10:00
|
|
|
Anim: engine.Anim{
|
|
|
|
Def: &engine.AnimDef{
|
|
|
|
Frames: []engine.AnimFrame{
|
|
|
|
{Frame: 3, DurationTicks: 12},
|
|
|
|
{Frame: 4, DurationTicks: 12},
|
|
|
|
{Frame: 5, DurationTicks: 12},
|
|
|
|
{Frame: 6, DurationTicks: 12},
|
|
|
|
},
|
|
|
|
Loop: true,
|
|
|
|
},
|
2021-07-29 15:29:26 +10:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-07-25 15:03:10 +10:00
|
|
|
game := &engine.Game{
|
2021-07-23 13:12:54 +10:00
|
|
|
ScreenHeight: screenHeight,
|
|
|
|
ScreenWidth: screenWidth,
|
2021-07-30 14:25:32 +10:00
|
|
|
Scene: &engine.Scene{
|
2021-07-30 16:11:01 +10:00
|
|
|
Components: []interface{}{
|
2021-07-31 16:46:12 +10:00
|
|
|
&engine.Tilemap{
|
|
|
|
Map: tiles,
|
|
|
|
Src: engine.ImageRef{Path: "assets/boxes.png"},
|
|
|
|
TileSize: 16,
|
|
|
|
},
|
2021-07-30 16:11:01 +10:00
|
|
|
engine.PerfDisplay{},
|
|
|
|
},
|
2021-07-23 13:12:54 +10:00
|
|
|
},
|
2021-07-25 15:03:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := ebiten.RunGame(game); err != nil {
|
2021-07-23 14:59:49 +10:00
|
|
|
log.Fatalf("Game error: %v", err)
|
2021-07-23 13:12:54 +10:00
|
|
|
}
|
|
|
|
}
|