func (e *Entity) die() { e.Mob = nil e.sprite.SetColor(sf.ColorRed()) //Becomes a corpse e.name = e.name + "'s corpse" e.Item = new(Item) }
func NewSimpleFunctionalPathShape(start float32, end float32, function func(float64) float64) (*PathShape, error) { return NewFunctionalPathShape64(start, end, 1, function, sf.ColorRed()) }
func (g *Game) run() { for g.window.IsOpen() { wait := true pollLoop: for event := g.window.PollEvent(); event != nil; event = g.window.PollEvent() { switch et := event.(type) { case sf.EventClosed: g.window.Close() case sf.EventTextEntered: wait = g.handleInput(et.Char) break pollLoop } } g.window.Clear(sf.ColorBlack()) // Draw status stuff. g.window.SetView(g.statusView) g.hpText.SetString("HP: " + strconv.Itoa(g.player.curhp) + "/" + strconv.Itoa(g.player.maxhp)) g.hpText.Draw(g.window, sf.DefaultRenderStates()) g.drawLog() if g.state != INVENTORY { g.window.SetView(g.gameView) g.Draw(g.area) //Draw items for _, i := range g.items { g.Draw(i) } //Process mobs Ai, check for deaths and draw them. for i, m := range g.mobs { if m.Mob == nil { mPos := m.Position() for i := 0; i < 3; i++ { // Spill blood. r := rand.Perm(3) g.area.tiles[(mPos.X+r[0]-1)+(mPos.Y+r[2]-1)*g.area.width].SetColor(sf.ColorRed()) } g.items = append(g.items, m) g.mobs = removeFromList(g.mobs, i) } if !wait && m != g.player && m.Mob != nil { g.processAI(m) } g.Draw(m) } //Check if player died. if g.player.Mob == nil { fmt.Print("Game Over, you died.\n") g.window.Close() return } if g.state == LOOK { g.Draw(g.cursor) g.lookText.Draw(g.window, sf.DefaultRenderStates()) } g.window.Display() } } }