diff options
author | davidovski <david@davidovski.xyz> | 2024-04-22 12:42:38 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2024-04-22 12:42:38 +0100 |
commit | ec04c06ffad66ec95560aba08e70134d3ba2d5e5 (patch) | |
tree | 3ba968099cc113d166a6abbc6e9d40363aae5f14 /objects.go | |
parent | 63253bbeb5c6a6a346443483bddc75276625d48a (diff) |
add audio
Diffstat (limited to 'objects.go')
-rw-r--r-- | objects.go | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -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) |