✨ Slide and collide!
This commit is contained in:
40
pkg/internal/tiles/tile.go
Normal file
40
pkg/internal/tiles/tile.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package tiles
|
||||
|
||||
import (
|
||||
"git.solsynth.dev/highland/codingland/pkg/internal/land"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
||||
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) {
|
||||
}
|
Reference in New Issue
Block a user