different

This commit is contained in:
Josh Deprez 2021-08-05 14:36:07 +10:00 committed by Josh Deprez
parent 8bddc09a11
commit 8d9806f93f
2 changed files with 70 additions and 64 deletions

65
game/anims.go Normal file
View file

@ -0,0 +1,65 @@
package game
import "drjosh.dev/gurgle/engine"
func init() {
engine.AnimDefs = map[string]*engine.AnimDef{
"green_tiles": {
Frames: []engine.AnimFrame{
{Frame: 0, Duration: 16},
{Frame: 1, Duration: 16},
{Frame: 2, Duration: 16},
},
},
"red_tiles": {
Frames: []engine.AnimFrame{
{Frame: 3, Duration: 12},
{Frame: 4, Duration: 12},
{Frame: 5, Duration: 12},
{Frame: 6, Duration: 12},
},
},
"aw_idle_right": {
Frames: []engine.AnimFrame{
{Frame: 0, Duration: 60},
},
},
"aw_idle_left": {
Frames: []engine.AnimFrame{
{Frame: 1, Duration: 60},
},
},
"aw_walk_right": {
Frames: []engine.AnimFrame{
{Frame: 2, Duration: 6},
{Frame: 3, Duration: 6},
{Frame: 4, Duration: 6},
{Frame: 5, Duration: 6},
},
},
"aw_walk_left": {
Frames: []engine.AnimFrame{
{Frame: 6, Duration: 6},
{Frame: 7, Duration: 6},
{Frame: 8, Duration: 6},
{Frame: 9, Duration: 3},
},
},
"aw_run_right": {
Frames: []engine.AnimFrame{
{Frame: 10, Duration: 3},
{Frame: 11, Duration: 3},
{Frame: 12, Duration: 3},
{Frame: 13, Duration: 3},
},
},
"aw_run_left": {
Frames: []engine.AnimFrame{
{Frame: 14, Duration: 3},
{Frame: 15, Duration: 3},
{Frame: 16, Duration: 3},
{Frame: 17, Duration: 3},
},
},
}
}

69
main.go
View file

@ -12,75 +12,16 @@ import (
"github.com/hajimehoshi/ebiten/v2"
)
const screenWidth, screenHeight = 320, 240
//go:embed assets
var assets embed.FS
func main() {
ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowResizable(true)
ebiten.SetWindowSize(640, 480)
ebiten.SetWindowTitle("TODO")
engine.AssetFS = assets
engine.AnimDefs = map[string]*engine.AnimDef{
"green_tiles": {
Frames: []engine.AnimFrame{
{Frame: 0, Duration: 16},
{Frame: 1, Duration: 16},
{Frame: 2, Duration: 16},
},
},
"red_tiles": {
Frames: []engine.AnimFrame{
{Frame: 3, Duration: 12},
{Frame: 4, Duration: 12},
{Frame: 5, Duration: 12},
{Frame: 6, Duration: 12},
},
},
"aw_idle_right": {
Frames: []engine.AnimFrame{
{Frame: 0, Duration: 60},
},
},
"aw_idle_left": {
Frames: []engine.AnimFrame{
{Frame: 1, Duration: 60},
},
},
"aw_walk_right": {
Frames: []engine.AnimFrame{
{Frame: 2, Duration: 6},
{Frame: 3, Duration: 6},
{Frame: 4, Duration: 6},
{Frame: 5, Duration: 6},
},
},
"aw_walk_left": {
Frames: []engine.AnimFrame{
{Frame: 6, Duration: 6},
{Frame: 7, Duration: 6},
{Frame: 8, Duration: 6},
{Frame: 9, Duration: 3},
},
},
"aw_run_right": {
Frames: []engine.AnimFrame{
{Frame: 10, Duration: 3},
{Frame: 11, Duration: 3},
{Frame: 12, Duration: 3},
{Frame: 13, Duration: 3},
},
},
"aw_run_left": {
Frames: []engine.AnimFrame{
{Frame: 14, Duration: 3},
{Frame: 15, Duration: 3},
{Frame: 16, Duration: 3},
{Frame: 17, Duration: 3},
},
},
}
// engine.AnimDefs set in game/anims.go
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)},
@ -141,8 +82,8 @@ func main() {
}
game := &engine.Game{
ScreenHeight: screenHeight,
ScreenWidth: screenWidth,
ScreenHeight: 240,
ScreenWidth: 320,
Scene: &engine.Scene{
ID: "root",
Components: []interface{}{