Exemplo n.º 1
0
func (h *Hud) drawHealth(bounds image.Rectangle) {
	heart := app.Cache().GetDrawable(util.SmallIcon(util.Items, 22))
	halfHeart := app.Cache().GetDrawable(util.SmallIcon(util.Items, 23))
	noHeart := app.Cache().GetDrawable(util.SmallIcon(util.Items, 24))
	shield := app.Cache().GetDrawable(util.SmallIcon(util.Items, 25))
	halfShield := app.Cache().GetDrawable(util.SmallIcon(util.Items, 26))

	pc, _ := h.world.Player.(entity.Stats)
	offset := bounds.Min
	for i := 0; i < pc.MaxHealth(); i += 2 {
		n := pc.Health() - i
		if n > 1 {
			heart.Draw(offset)
		} else if n > 0 {
			halfHeart.Draw(offset)
		} else {
			noHeart.Draw(offset)
		}
		offset = offset.Add(image.Pt(util.TileW, 0))
	}
	for i := 0; i < pc.Shield(); i += 2 {
		n := pc.Shield() - i
		if n > 1 {
			shield.Draw(offset)
		} else {
			halfShield.Draw(offset)
		}
		offset = offset.Add(image.Pt(util.TileW, 0))
	}
}
Exemplo n.º 2
0
func icon(idx int) gfx.ImageSpec { return util.SmallIcon(util.Chars, idx) }
Exemplo n.º 3
0
func genPC(w *world.World) entity.Entity {
	return mob.NewPC(w, mob.Spec{Icon: util.SmallIcon(util.Chars, 16), MaxHealth: 6})
}