2023-02-17 07:04:29 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/surdeus/gox/src/gx"
|
2023-02-17 23:51:40 +03:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/examples/resources/images"
|
|
|
|
"bytes"
|
|
|
|
"log"
|
2023-02-17 07:04:29 +03:00
|
|
|
)
|
|
|
|
|
2023-02-17 16:40:46 +03:00
|
|
|
type Player struct {
|
2023-02-17 23:51:40 +03:00
|
|
|
*gx.Sprite
|
2023-02-17 16:56:15 +03:00
|
|
|
}
|
|
|
|
|
2023-02-17 23:51:40 +03:00
|
|
|
var (
|
|
|
|
playerImg *gx.Image
|
|
|
|
)
|
|
|
|
|
2023-02-17 16:56:15 +03:00
|
|
|
func NewPlayer() *Player {
|
|
|
|
return &Player{
|
2023-02-17 23:51:40 +03:00
|
|
|
Sprite: &gx.Sprite{
|
|
|
|
Object: &gx.Object{
|
|
|
|
T: gx.Transform {
|
|
|
|
P: gx.Vector{1, 1},
|
|
|
|
S: gx.Vector{1, 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Image: playerImg,
|
|
|
|
},
|
2023-02-17 16:56:15 +03:00
|
|
|
}
|
2023-02-17 16:40:46 +03:00
|
|
|
}
|
|
|
|
|
2023-02-17 23:51:40 +03:00
|
|
|
func (p *Player) Update(e *gx.Engine) {
|
|
|
|
p.Sprite.Object.T.P.Y += 0.1
|
|
|
|
}
|
|
|
|
|
2023-02-17 07:04:29 +03:00
|
|
|
func main() {
|
|
|
|
e := gx.New(&gx.WindowConfig{
|
|
|
|
Title: "Test title",
|
|
|
|
Width: 480,
|
|
|
|
Height: 320,
|
|
|
|
})
|
|
|
|
|
2023-02-17 23:51:40 +03:00
|
|
|
var err error
|
|
|
|
playerImg, err = gx.LoadImage(bytes.NewReader(images.Runner_png))
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-17 16:56:15 +03:00
|
|
|
e.Add(0, NewPlayer())
|
2023-02-17 07:04:29 +03:00
|
|
|
e.Run()
|
|
|
|
}
|