-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine.go
52 lines (40 loc) · 995 Bytes
/
engine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"github.com/BigJk/ramen/console"
)
// Engine acts as a store of game data that can easily be passed to functions that need it
type Engine struct {
player *Entity
gameMap *GameMap
}
func (e *Engine) Render(con *console.Console) {
e.gameMap.Render(con)
}
// HandleEnemyTurns performs enemy entities actions
func (e *Engine) HandleEnemyTurns() {
for _, entity := range e.gameMap.entities.Entities {
if entity == e.player {
continue
}
fmt.Println(fmt.Sprintf("The %s wonders when it will get to take a real turn", entity.name))
}
}
// HandlePlayerTurn performs players action
func (e *Engine) HandlePlayerTurn(action IAction) {
if action == nil {
return
}
action.Perform(e, e.player)
e.gameMap.UpdateFov()
e.HandleEnemyTurns()
}
func NewEngine() *Engine {
engine := &Engine{
player: Player.Spawn(ScreenW/2, ScreenH/2, nil),
}
GenerateDungeon(80, 45, 30, 6, 30, 2, engine)
// Init FOV
engine.gameMap.UpdateFov()
return engine
}