Starting to add in assets.
This commit is contained in:
@@ -64,6 +64,8 @@ type Game struct {
|
||||
//similar fields that we see in the client list, but for us
|
||||
eliminated bool
|
||||
hit bool
|
||||
|
||||
dino *elements.Dino
|
||||
}
|
||||
|
||||
func NewGame() *Game {
|
||||
@@ -74,6 +76,7 @@ func NewGame() *Game {
|
||||
elimblocky: elements.NewBlock(),
|
||||
cycle: 0,
|
||||
name: namelist[rand.Intn(len(namelist))],
|
||||
dino: elements.NewDino(gamedata.DinoTypeGreen),
|
||||
}
|
||||
|
||||
g.blocky.SetColor(color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff})
|
||||
@@ -93,6 +96,7 @@ func NewGame() *Game {
|
||||
func (g *Game) Update() error {
|
||||
|
||||
g.blocky.Update()
|
||||
g.dino.Update()
|
||||
//g.hitblocky.Update()
|
||||
|
||||
g.HandleInput()
|
||||
@@ -158,6 +162,12 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
text.Draw(screen, client.Name, f2, top)
|
||||
}
|
||||
|
||||
g.dino.Draw()
|
||||
dop := &ebiten.DrawImageOptions{}
|
||||
dop.GeoM.Translate(-float64(g.dino.Sprite.Bounds().Dx())/2, -float64(g.dino.Sprite.Bounds().Dy())/2)
|
||||
dop.GeoM.Translate(g.blocky.GetPosition().X, g.blocky.GetPosition().Y)
|
||||
screen.DrawImage(g.dino.Sprite, dop)
|
||||
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenwidth, screenheight int) {
|
||||
@@ -260,6 +270,7 @@ func (g *Game) HandleInput() {
|
||||
|
||||
dx := 0
|
||||
dy := 0
|
||||
|
||||
if ebiten.IsKeyPressed(ebiten.KeyW) {
|
||||
dy = -movementLimit
|
||||
}
|
||||
@@ -268,9 +279,17 @@ func (g *Game) HandleInput() {
|
||||
}
|
||||
if ebiten.IsKeyPressed(ebiten.KeyA) {
|
||||
dx = -movementLimit
|
||||
g.dino.SetLeft(true)
|
||||
}
|
||||
if ebiten.IsKeyPressed(ebiten.KeyD) {
|
||||
dx = +movementLimit
|
||||
g.dino.SetLeft(false)
|
||||
}
|
||||
|
||||
if math.Abs(float64(dx)) > 0 || math.Abs(float64(dy)) > 0 {
|
||||
g.dino.SetAction(gamedata.DinoActionWalk)
|
||||
} else {
|
||||
g.dino.SetAction(gamedata.DinoActionIdle)
|
||||
}
|
||||
|
||||
cpos := g.blocky.GetPosition()
|
||||
@@ -280,6 +299,7 @@ func (g *Game) HandleInput() {
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeySpace) {
|
||||
g.SendSlap()
|
||||
g.dino.SetAction(gamedata.DinoActionSlap)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user