ecs attempt
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/fov"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/fov/precomputed_shade"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/gamestate"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/mob"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
"time"
|
||||
)
|
||||
@ -14,12 +15,12 @@ var NotInViewError = errors.New("not in ViewPort")
|
||||
|
||||
type ViewPort struct {
|
||||
*types.Rect
|
||||
cameraCoords types.Coords
|
||||
layer *Layer
|
||||
Fov fov.Fov
|
||||
PlayerCoords types.Coords
|
||||
PlayerTorchRadius int
|
||||
animateTiles *time.Ticker
|
||||
cameraCoords types.Coords
|
||||
layer *Layer
|
||||
Fov fov.Fov
|
||||
Player mob.Player
|
||||
TorchRadius int
|
||||
animateTiles *time.Ticker
|
||||
}
|
||||
|
||||
func NewViewPort(x, y, w, h int, layer *Layer) *ViewPort {
|
||||
@ -32,7 +33,7 @@ func NewViewPort(x, y, w, h int, layer *Layer) *ViewPort {
|
||||
Fov: computedFov,
|
||||
}
|
||||
|
||||
vp.PlayerTorchRadius = 11
|
||||
vp.TorchRadius = 12
|
||||
vp.animateTiles = time.NewTicker(time.Second / 12)
|
||||
|
||||
return &vp
|
||||
@ -45,7 +46,7 @@ func (vp *ViewPort) Close() {
|
||||
|
||||
func (vp *ViewPort) Move(state *gamestate.GameState) {
|
||||
|
||||
c := &state.Player.Coords
|
||||
c := &state.Level.Player.HasComponent(types.Coords{}).Coords
|
||||
|
||||
x := c.X - vp.Rect.W/2
|
||||
y := c.Y - vp.Rect.H/2
|
||||
@ -103,7 +104,7 @@ func (vp *ViewPort) Render(state *gamestate.GameState) {
|
||||
vp.layer.ClearRect(vp.Rect)
|
||||
fovRecompute = true
|
||||
redraw = true
|
||||
vp.Fov.ComputeFov(state.Level, state.Player.Coords, vp.PlayerTorchRadius)
|
||||
vp.Fov.ComputeFov(state.Level, state.Level.Player.Coords, vp.TorchRadius)
|
||||
}
|
||||
|
||||
//if redraw {
|
||||
@ -121,7 +122,7 @@ func (vp *ViewPort) Render(state *gamestate.GameState) {
|
||||
}
|
||||
}
|
||||
//mobs
|
||||
pc, err := vp.ToVPCoords(state.Player.Coords)
|
||||
pc, err := vp.ToVPCoords(state.Level.Player.Coords)
|
||||
_ = pc
|
||||
if err != nil {
|
||||
fmt.Println("error on getting player position")
|
||||
|
Reference in New Issue
Block a user