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
|
|
|
|
2024-07-18 14:59:03 +00:00
|
|
|
func (p *Tile) OnEvent(event land.UserEventType, args ...any) {
|
|
|
|
if event == land.UserEventMouseDown {
|
|
|
|
log.Printf("user clicked tile: %s", args[0].(land.Vector2D).String())
|
|
|
|
}
|
2024-07-18 09:46:36 +00:00
|
|
|
}
|