A kind of Augmented Reality programming game that makes you a better programmer.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ttarpit/game/engine.go

40 lines
703 B

package game
import (
"fmt"
"lcthw.dev/go/ttarpit/config"
"lcthw.dev/go/ttarpit/data"
)
type Game struct {
settings config.Config
HP int
Errors int
}
func New(settings config.Config) *Game {
game := new(Game)
game.settings = settings
game.HP = settings.StartingHP
return game
}
func (game *Game) TakeHit(errinfo data.ErrInfo) {
fmt.Println("!!!!!!!!!!!!!!!!!", errinfo)
game.Errors++
game.HP--
fmt.Println("============== PROCESS EXIT")
fmt.Printf("==== HP: %d Errors: %d =====\n",
game.HP, game.Errors)
if game.HP <= 0 {
fmt.Println("!!!!!! YOU DIED !!!!!!!")
game.HP = game.settings.StartingHP
}
fmt.Println("===========================")
}