summaryrefslogtreecommitdiff
path: root/objects.go
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2024-04-22 17:32:17 +0100
committerdavidovski <david@davidovski.xyz>2024-04-22 17:32:17 +0100
commitb0a8bb642f919eaa0c36b9d861c47e0cc4a99440 (patch)
treed9e184cec7db11ad8dc7c93b9e68291bc5beceae /objects.go
parenteeca23dc59e60def65dfefc28b69d6cfc85467ff (diff)
use grass
Diffstat (limited to 'objects.go')
-rw-r--r--objects.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/objects.go b/objects.go
index d1ccfeb..2d14855 100644
--- a/objects.go
+++ b/objects.go
@@ -40,6 +40,7 @@ type GameObject struct {
onCollideDown func(this, other *GameObject) bool
onCollideLeft func(this, other *GameObject) bool
onCollideRight func(this, other *GameObject) bool
+ Draw func (o * GameObject, screen *ebiten.Image, tilemap Tilemap)
movable bool
}
@@ -132,7 +133,7 @@ func (o * GameObject) HasCollision(tilemap Tilemap, others []*GameObject, dir Di
return false
}
-func (o * GameObject) Draw(screen *ebiten.Image, tilemap Tilemap) {
+func DrawObject(o * GameObject, screen *ebiten.Image, tilemap Tilemap) {
op := &ebiten.DrawImageOptions{}
op.ColorScale.ScaleAlpha(o.alpha)
op.GeoM.Translate(float64(o.x), float64(o.y))
@@ -199,6 +200,7 @@ func NewObject(game *Game, x, y float32) *GameObject{
x: x,
y: y,
movable: true,
+ Draw: DrawObject,
}
}
@@ -208,6 +210,7 @@ func NewPlayer(game *Game, x, y float32) *GameObject{
playerImage := ebiten.NewImageFromImage(characterImage)
player.image = playerImage.SubImage(image.Rect(4, 8, 27, 32)).(*ebiten.Image)
+ player.Draw = DrawObject
player.movable = false
return player