Skip to content

Commit

Permalink
reset game, without reset sound due faiface/beep#146
Browse files Browse the repository at this point in the history
  • Loading branch information
polpettone committed Aug 20, 2022
1 parent b3177be commit bc43711
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion game/game.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package game

import "github.com/polpettone/adventure/engine"

type Game interface {
Init()
Init(engine engine.Engine)
Update(key string) error
Run() bool
}
7 changes: 3 additions & 4 deletions game/pinguinBurgGame.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func initItems(count int) map[uuid.UUID]*models.Item {
return itemsMap
}

func (g *PinguinBurfGame) Init() {
func (g *PinguinBurfGame) Init(engine engine.Engine) {

player1 := models.NewPlayer(models.PLAYER, 0, 0, "k", "j", "l", "h", "m")
player2 := models.NewPlayer(models.PLAYER2, 79, 29, "w", "s", "d", "a", "x")
Expand All @@ -62,7 +62,7 @@ func (g *PinguinBurfGame) Init() {
enemyMap := map[uuid.UUID]*models.Enemy{}
enemyMap[enemy.ID] = enemy

itemsMap := initItems(100)
itemsMap := initItems(500)

elements := buildElementsForUpdate(itemsMap, enemyMap, *player1, *player2)

Expand Down Expand Up @@ -92,8 +92,7 @@ func (g *PinguinBurfGame) Init() {
g.Player1 = player1
g.Player2 = player2

g.Engine = &engine.EngineOne{}
g.Engine.Setup()
g.Engine = engine
g.Engine.ClearScreen()

fmt.Println(gameMap.Print())
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"github.com/polpettone/adventure/engine"
"github.com/polpettone/adventure/game"
)

Expand All @@ -10,9 +11,12 @@ func main() {

func startPinguinBurgGame() {

engine := &engine.EngineOne{}
engine.Setup()

for {
game := &game.PinguinBurfGame{}
game.Init()
game.Init(engine)
quit := game.Run()

if quit {
Expand Down

0 comments on commit bc43711

Please sign in to comment.