2021-10-05 03:47:29 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"image"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type gamePlayer struct {
|
|
|
|
x, y float64
|
|
|
|
|
|
|
|
angle float64
|
|
|
|
|
|
|
|
weapon *playerWeapon
|
2021-10-06 04:05:02 +00:00
|
|
|
|
2021-10-07 00:29:28 +00:00
|
|
|
score int
|
|
|
|
|
2021-10-06 04:05:02 +00:00
|
|
|
health int
|
2021-10-12 03:22:13 +00:00
|
|
|
|
|
|
|
repelUntil time.Time
|
2021-10-05 03:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewPlayer() (*gamePlayer, error) {
|
|
|
|
f, err := assetsFS.Open("assets/weapons/uzi.png")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
img, _, err := image.Decode(f)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
uziSprite := ebiten.NewImageFromImage(img)
|
|
|
|
|
|
|
|
p := &gamePlayer{
|
|
|
|
weapon: &playerWeapon{
|
|
|
|
sprite: uziSprite,
|
|
|
|
cooldown: 100 * time.Millisecond,
|
|
|
|
},
|
2021-10-07 01:02:17 +00:00
|
|
|
health: 3,
|
2021-10-05 03:47:29 +00:00
|
|
|
}
|
|
|
|
return p, nil
|
|
|
|
}
|