From ec04c06ffad66ec95560aba08e70134d3ba2d5e5 Mon Sep 17 00:00:00 2001 From: davidovski Date: Mon, 22 Apr 2024 12:42:38 +0100 Subject: add audio --- objects.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'objects.go') diff --git a/objects.go b/objects.go index 3c44458..d1ccfeb 100644 --- a/objects.go +++ b/objects.go @@ -3,10 +3,8 @@ package main import ( "image" "image/color" - "log" "github.com/hajimehoshi/ebiten/v2" - "github.com/hajimehoshi/ebiten/v2/ebitenutil" "github.com/hajimehoshi/ebiten/v2/vector" ) @@ -130,6 +128,7 @@ func (o * GameObject) HasCollision(tilemap Tilemap, others []*GameObject, dir Di return f(obj, o) } } + return false } @@ -142,8 +141,6 @@ func (o * GameObject) Draw(screen *ebiten.Image, tilemap Tilemap) { if o.highlight { vector.StrokeRect(screen, o.x, o.y, float32(o.image.Bounds().Dx()), float32(o.image.Bounds().Dy()), hightlightBorder, color.RGBA{255, 100, 100, 255}, false) } - - } func (object * GameObject) Collide(other *GameObject) bool { @@ -208,10 +205,7 @@ func NewObject(game *Game, x, y float32) *GameObject{ func NewPlayer(game *Game, x, y float32) *GameObject{ player := NewObject(game, x, y) - playerImage, _, err := ebitenutil.NewImageFromFile("assets/character.png") - if err != nil { - log.Fatal(err) - } + playerImage := ebiten.NewImageFromImage(characterImage) player.image = playerImage.SubImage(image.Rect(4, 8, 27, 32)).(*ebiten.Image) -- cgit v1.2.1