2021-07-23 13:12:54 +10:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-07-25 14:15:39 +10:00
|
|
|
"embed"
|
2021-08-03 18:26:14 +10:00
|
|
|
"image"
|
2021-08-05 10:26:45 +10:00
|
|
|
"image/color"
|
2021-07-25 14:15:39 +10:00
|
|
|
_ "image/png"
|
2021-07-23 13:12:54 +10:00
|
|
|
"log"
|
|
|
|
|
|
|
|
"drjosh.dev/gurgle/engine"
|
2021-08-05 12:26:41 +10:00
|
|
|
"drjosh.dev/gurgle/game"
|
2021-07-23 13:12:54 +10:00
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
)
|
|
|
|
|
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() {
|
2021-08-05 14:36:07 +10:00
|
|
|
ebiten.SetWindowResizable(true)
|
|
|
|
ebiten.SetWindowSize(640, 480)
|
2021-07-25 14:15:39 +10:00
|
|
|
ebiten.SetWindowTitle("TODO")
|
|
|
|
|
2021-07-31 16:38:54 +10:00
|
|
|
engine.AssetFS = assets
|
2021-08-05 14:36:07 +10:00
|
|
|
// engine.AnimDefs set in game/anims.go
|
2021-07-25 15:03:10 +10:00
|
|
|
|
2021-08-03 16:17:59 +10:00
|
|
|
tiles := [][]engine.Tile{
|
|
|
|
{engine.StaticTile(9), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, engine.StaticTile(9)},
|
|
|
|
{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "red_tiles"}}, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
|
|
|
{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "red_tiles"}}, nil, nil, nil},
|
|
|
|
{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
|
|
|
{nil, nil, &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "green_tiles"}}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
|
|
|
{nil, nil, nil, nil, nil, &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "red_tiles"}}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
|
|
|
{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "green_tiles"}}, nil, nil, nil, nil, nil, nil},
|
|
|
|
{nil, nil, nil, nil, &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "green_tiles"}}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
|
|
|
{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "green_tiles"}}, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
2021-08-05 15:16:56 +10:00
|
|
|
{nil, &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "red_tiles"}}, nil, nil, nil, nil, nil, nil, engine.StaticTile(9), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
|
|
|
{nil, nil, nil, nil, nil, engine.StaticTile(9), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, engine.StaticTile(9), nil, nil, nil},
|
|
|
|
{nil, nil, nil, nil, engine.StaticTile(9), engine.StaticTile(9), engine.StaticTile(9), nil, nil, nil, engine.StaticTile(9), nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
2021-08-03 16:43:38 +10:00
|
|
|
{engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "red_tiles"}}, engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8), engine.StaticTile(8)},
|
|
|
|
{engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "red_tiles"}}, engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), &engine.AnimatedTile{AnimRef: engine.AnimRef{Key: "green_tiles"}}, engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7)},
|
|
|
|
{engine.StaticTile(9), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(7), engine.StaticTile(9)},
|
2021-08-02 15:56:25 +10:00
|
|
|
}
|
2021-07-29 15:29:26 +10:00
|
|
|
|
2021-08-03 20:06:17 +10:00
|
|
|
level1 := &engine.Scene{
|
|
|
|
ID: "level_1",
|
|
|
|
Components: []interface{}{
|
2021-08-05 15:14:56 +10:00
|
|
|
&engine.Fill{
|
|
|
|
Color: color.Gray{100},
|
|
|
|
ZPos: 0,
|
2021-08-05 10:26:45 +10:00
|
|
|
},
|
2021-08-03 20:06:17 +10:00
|
|
|
&engine.Tilemap{
|
|
|
|
ID: "terrain",
|
|
|
|
Map: tiles,
|
|
|
|
Src: engine.ImageRef{Path: "assets/boxes.png"},
|
|
|
|
TileSize: 16,
|
2021-08-05 15:14:56 +10:00
|
|
|
ZPos: 1,
|
2021-08-03 20:06:17 +10:00
|
|
|
},
|
|
|
|
&engine.SolidRect{
|
|
|
|
ID: "ceiling",
|
|
|
|
Rect: image.Rect(0, -1, 320, 0),
|
|
|
|
},
|
|
|
|
&engine.SolidRect{
|
|
|
|
ID: "left_wall",
|
|
|
|
Rect: image.Rect(-1, 0, 0, 240),
|
|
|
|
},
|
|
|
|
&engine.SolidRect{
|
|
|
|
ID: "right_wall",
|
|
|
|
Rect: image.Rect(320, 0, 321, 240),
|
|
|
|
},
|
2021-08-05 12:26:41 +10:00
|
|
|
&game.Awakeman{
|
|
|
|
Sprite: engine.Sprite{
|
|
|
|
ID: "awakeman",
|
|
|
|
Actor: engine.Actor{
|
|
|
|
CollisionDomain: "level_1",
|
|
|
|
Pos: image.Pt(100, 100),
|
|
|
|
Size: image.Pt(10, 16),
|
|
|
|
},
|
|
|
|
Src: engine.ImageRef{Path: "assets/aw.png"},
|
2021-08-05 15:14:56 +10:00
|
|
|
ZPos: 2,
|
2021-08-04 15:07:57 +10:00
|
|
|
},
|
2021-08-03 20:06:17 +10:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-07-25 15:03:10 +10:00
|
|
|
game := &engine.Game{
|
2021-08-05 14:36:07 +10:00
|
|
|
ScreenHeight: 240,
|
|
|
|
ScreenWidth: 320,
|
2021-07-30 14:25:32 +10:00
|
|
|
Scene: &engine.Scene{
|
2021-08-02 12:16:10 +10:00
|
|
|
ID: "root",
|
2021-07-30 16:11:01 +10:00
|
|
|
Components: []interface{}{
|
2021-08-01 16:41:10 +10:00
|
|
|
&engine.GobDumper{
|
2021-08-01 20:38:27 +10:00
|
|
|
KeyCombo: []ebiten.Key{ebiten.KeyControl, ebiten.KeyD},
|
2021-08-01 16:41:10 +10:00
|
|
|
},
|
2021-08-03 20:06:17 +10:00
|
|
|
level1,
|
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
|
|
|
}
|
2021-08-05 12:26:41 +10:00
|
|
|
game.PrepareToRun()
|
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
|
|
|
}
|
|
|
|
}
|