Raycaster example now works

This commit is contained in:
Sasha Koshka 2023-03-16 00:30:59 -04:00
parent 40aa1a788b
commit 0ebf0bc814
2 changed files with 8 additions and 4 deletions

View File

@ -31,7 +31,11 @@ func NewGame (world World, textures Textures) (game *Game) {
return
}
func (game *Game) DrawTo (canvas canvas.Canvas, bounds image.Rectangle) {
func (game *Game) DrawTo (
canvas canvas.Canvas,
bounds image.Rectangle,
onDamage func (image.Rectangle),
) {
if canvas == nil {
select {
case game.stopChan <- true:
@ -41,7 +45,7 @@ func (game *Game) DrawTo (canvas canvas.Canvas, bounds image.Rectangle) {
game.running = true
go game.run()
}
game.Raycaster.DrawTo(canvas, bounds)
game.Raycaster.DrawTo(canvas, bounds, onDamage)
}
func (game *Game) Stamina () float64 {

View File

@ -49,9 +49,9 @@ func NewRaycaster (world World, textures Textures) (element *Raycaster) {
textures: textures,
renderDistance: 8,
}
element.Core, element.core = core.NewCore(element.drawAll)
element.Core, element.core = core.NewCore(element, element.drawAll)
element.FocusableCore,
element.focusableControl = core.NewFocusableCore(element.Draw)
element.focusableControl = core.NewFocusableCore(element.core, element.Draw)
element.core.SetMinimumSize(64, 64)
return
}