2024-07-18 09:21:25 +00:00
|
|
|
package tiles
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.solsynth.dev/highland/codingland/pkg/internal/land"
|
|
|
|
"github.com/veandco/go-sdl2/sdl"
|
2024-07-18 09:46:36 +00:00
|
|
|
"log"
|
2024-07-18 09:21:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Tile struct {
|
|
|
|
land.BaseObject
|
|
|
|
|
|
|
|
Position land.Vector2D
|
|
|
|
Size land.Vector2D
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Tile) Draw(pen *sdl.Renderer) {
|
|
|
|
pen.SetDrawColor(255, 255, 255, 255)
|
|
|
|
pen.FillRect(&sdl.Rect{
|
|
|
|
X: int32(p.Position.X),
|
|
|
|
Y: int32(p.Position.Y),
|
|
|
|
W: int32(p.Size.X),
|
|
|
|
H: int32(p.Size.Y),
|
|
|
|
})
|
|
|
|
|
|
|
|
for _, child := range p.Children {
|
|
|
|
if drawableChild, ok := child.(land.DrawableObject); ok {
|
|
|
|
drawableChild.Draw(pen)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Tile) GetPosition() land.Vector2D {
|
|
|
|
return p.Position
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Tile) GetSize() land.Vector2D {
|
|
|
|
return p.Size
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Tile) OnCollide(other land.CollidableObject) {
|
|
|
|
}
|
2024-07-18 09:46:36 +00:00
|
|
|
|
|
|
|
func (p *Tile) OnClick(mousePos land.Vector2D) {
|
|
|
|
log.Printf("user clicked tile: %s", mousePos.String())
|
|
|
|
}
|