Twin-stick shooter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
748 B

package main
import (
"github.com/hajimehoshi/ebiten/v2"
)
// Tile represents a space with an x,y coordinate within a Level. Any number of
// sprites may be added to a Tile.
type Tile struct {
sprites []*ebiten.Image
floor bool
wall bool
}
// AddSprite adds a sprite to the Tile.
func (t *Tile) AddSprite(s *ebiten.Image) {
t.sprites = append(t.sprites, s)
}
// ClearSprites removes all sprites from the Tile.
func (t *Tile) ClearSprites() {
for i := range t.sprites {
t.sprites[i] = nil
}
t.sprites = t.sprites[:0]
}
// Draw draws the Tile on the screen using the provided options.
func (t *Tile) Draw(screen *ebiten.Image, options *ebiten.DrawImageOptions) {
for _, s := range t.sprites {
screen.DrawImage(s, options)
}
}