Ejemplo 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))
	}
}
Ejemplo n.º 2
0
func NewStyle(fontSpec font.Spec) *Style {
	return &Style{
		font:      app.Cache().GetFont(fontSpec),
		edge:      None,
		foreColor: gfx.White,
		backColor: gfx.Black}
}
Ejemplo n.º 3
0
func NewCycle(timePerFrame int64, loops bool, frameSpecs []gfx.ImageSpec) Cycle {
	var frames []gfx.Drawable
	for _, spec := range frameSpecs {
		frames = append(frames, app.Cache().GetDrawable(spec))
	}

	return Cycle{timePerFrame, frames, loops}
}
Ejemplo n.º 4
0
func (m *Mob) Sprite(offset image.Point) gfx.Sprite {
	// XXX: Hacky way to pass adjust parameter to make big mobs get drawn by
	// their frontmost point. Layer is assumed to be a delta, the view system
	// will adjust it into the correct Z level.
	layer := 0
	if m.isBig {
		layer += 2 * util.ViewLayersPerZ
	}
	return gfx.Sprite{
		Layer:    layer,
		Offset:   offset.Add(m.bob()),
		Drawable: app.Cache().GetDrawable(m.icon)}
}