diff options
author | davidovski <david@davidovski.xyz> | 2024-04-22 17:54:21 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2024-04-22 17:54:21 +0100 |
commit | e4c0edeacb2c5829f864e116b68f6cad175141b3 (patch) | |
tree | 88ebcb9dd06affb1e525f807e3a40b864dd0865b /objects.go | |
parent | d57ab031de3987ead9c06c48c8a5ad18a9de860c (diff) |
paper-style art
Diffstat (limited to 'objects.go')
-rw-r--r-- | objects.go | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -133,11 +133,23 @@ func (o * GameObject) HasCollision(tilemap Tilemap, others []*GameObject, dir Di return false } -func DrawObject(o * GameObject, screen *ebiten.Image, tilemap Tilemap) { +func ShadowDraw(screen *ebiten.Image, image *ebiten.Image, x, y float32, alpha float32) { op := &ebiten.DrawImageOptions{} - op.ColorScale.ScaleAlpha(o.alpha) - op.GeoM.Translate(float64(o.x), float64(o.y)) - screen.DrawImage(o.image, op) + if alpha > 0{ + op = &ebiten.DrawImageOptions{} + op.ColorScale.ScaleAlpha(alpha) + op.ColorScale.Scale(0, 0, 0, 1); + op.GeoM.Translate(float64(x+shadowOffset), float64(y + shadowOffset)) + screen.DrawImage(image, op) + } + op = &ebiten.DrawImageOptions{} + op.ColorScale.ScaleAlpha(alpha) + op.GeoM.Translate(float64(x), float64(y)) + screen.DrawImage(image, op) +} + +func DrawObject(o * GameObject, screen *ebiten.Image, tilemap Tilemap) { + ShadowDraw(screen, o.image, o.x, o.y, o.alpha) 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) |