fixed lit thresholds
This commit is contained in:
@ -21,8 +21,6 @@ import (
|
||||
// - Only lighting walls with light from the player (cheap trick, dutch)
|
||||
// - Match light value for walls with the highest light value in adjacent floor cell visible to player (seems costly)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Why am I here? Well, I just don't know what to call it - I'm sure it's an established method, and I'm aware there are
|
||||
probably optimisations to be had. I thought if I roughed out the algorithm here, the r/roguelikedev community would
|
||||
@ -258,7 +256,7 @@ func (ps *precomputedShade) ComputeFov(level *gamemap.Level, initCoords types.Co
|
||||
for _, cell := range ps.CellList {
|
||||
//fmt.Printf("\n coords: %v, distance: %f, lit: %d", cell.Coords, cell.distance, cell.lit)
|
||||
cs, err := ps.toLevelCoords(level, initCoords, cell.Coords)
|
||||
if cell.lit > 0 {
|
||||
if cell.lit > 2 {
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@ -275,7 +273,7 @@ func (ps *precomputedShade) ComputeFov(level *gamemap.Level, initCoords types.Co
|
||||
if //int(maybeNb.distance) == int(cell.distance-1) &&
|
||||
maybeNb.IsAdjacentTo(&cell.Coords) &&
|
||||
//(maybeNb.X == cell.X || maybeNb.Y == cell.Y) &&
|
||||
maybeNb.lit > 0 { //magic constant!
|
||||
maybeNb.lit > 5 { //magic constant!
|
||||
level.GetTile(cs).Visible = true
|
||||
level.GetTile(cs).Explored = true
|
||||
}
|
||||
|
@ -25,6 +25,22 @@ func (l *Level) GetTile (coords types.Coords) *Tile {
|
||||
return l.Tiles[coords.Y*l.W+coords.X]
|
||||
}
|
||||
|
||||
func (l *Level) GetTileNbs (coords types.Coords) []*Tile {
|
||||
result := make([]*Tile,0)
|
||||
for i := coords.X-1; i < coords.X+1; i++ {
|
||||
for j := coords.Y-1; j < coords.Y+1; j++ {
|
||||
nbc := types.Coords{i,j}
|
||||
if l.InBounds(nbc){
|
||||
if nbc == coords {
|
||||
continue
|
||||
}
|
||||
result = append(result, l.GetTileByXY(i,j))
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (l *Level) GetTileByXY (x,y int) *Tile {
|
||||
return l.Tiles[y*l.W+x]
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/ecs/systems"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/gamestate"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/mob/movement"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
@ -11,14 +13,22 @@ type GameScreen struct {
|
||||
mw *mainwindow.MainWindow
|
||||
state *gamestate.GameState
|
||||
vp *mainwindow.ViewPort
|
||||
controller *ecs.Controller
|
||||
}
|
||||
|
||||
func NewGameScreen(mw *mainwindow.MainWindow, state *gamestate.GameState, viewPort *mainwindow.ViewPort) *GameScreen {
|
||||
return &GameScreen{mw: mw, state: state, vp: viewPort}
|
||||
func NewGameScreen(mw *mainwindow.MainWindow, state *gamestate.GameState, viewPort *mainwindow.ViewPort, controller *ecs.Controller) *GameScreen {
|
||||
return &GameScreen{mw: mw, state: state, vp: viewPort, controller: controller}
|
||||
}
|
||||
|
||||
func (ts *GameScreen) UseEcs() bool { return true }
|
||||
func (ts *GameScreen) Enter() {}
|
||||
func (ts *GameScreen) Enter() {
|
||||
renderMobs := systems.MobRenderSystem{EntityController: ts.controller}
|
||||
ts.controller.AddSystem(renderMobs, 1)
|
||||
}
|
||||
func (ts *GameScreen) Exit() {
|
||||
//remove what we dont need
|
||||
}
|
||||
|
||||
func (ts *GameScreen) HandleInput(input string) {
|
||||
//ts.state.Do(func(){
|
||||
switch input {
|
||||
@ -26,25 +36,25 @@ func (ts *GameScreen) HandleInput(input string) {
|
||||
ts.walk(ts.state, 0, -1)
|
||||
break
|
||||
case "Down", "j", "2":
|
||||
ts.walk(ts.state,0, 1)
|
||||
ts.walk(ts.state, 0, 1)
|
||||
break
|
||||
case "Left", "h", "4":
|
||||
ts.walk(ts.state,-1, 0)
|
||||
ts.walk(ts.state, -1, 0)
|
||||
break
|
||||
case "Right", "l", "6":
|
||||
ts.walk(ts.state,1, 0)
|
||||
ts.walk(ts.state, 1, 0)
|
||||
break
|
||||
case "y", "7":
|
||||
ts.walk(ts.state,-1, -1)
|
||||
ts.walk(ts.state, -1, -1)
|
||||
break
|
||||
case "u", "9":
|
||||
ts.walk(ts.state,1, -1)
|
||||
ts.walk(ts.state, 1, -1)
|
||||
break
|
||||
case "b", "1":
|
||||
ts.walk(ts.state,-1, 1)
|
||||
ts.walk(ts.state, -1, 1)
|
||||
break
|
||||
case "n", "3":
|
||||
ts.walk(ts.state,1, 1)
|
||||
ts.walk(ts.state, 1, 1)
|
||||
break
|
||||
default:
|
||||
ts.mw.GetLayer("base").ClearArea(0, 3, 40, 1)
|
||||
@ -54,12 +64,11 @@ func (ts *GameScreen) HandleInput(input string) {
|
||||
}
|
||||
//})
|
||||
}
|
||||
func (ts *GameScreen) Exit() {}
|
||||
|
||||
func (ts *GameScreen) Render() {
|
||||
ts.vp.Render(ts.state)
|
||||
}
|
||||
|
||||
|
||||
func (ts *GameScreen) walk(state *gamestate.GameState, dx, dy int) {
|
||||
controller := state.Controller
|
||||
coords := controller.GetComponent(state.Player, types.Coords{}.TypeOf()).(types.Coords)
|
||||
@ -72,4 +81,4 @@ func (ts *GameScreen) walk(state *gamestate.GameState, dx, dy int) {
|
||||
|
||||
state.Redraw <- struct{}{}
|
||||
state.FovRecompute <- struct{}{}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user