Ejemplo n.º 1
0
// Blast generates an explosion effect in the game world.
func (f *Fx) Blast(loc space.Location, kind BlastKind) {
	switch kind {
	case SmallExplosion:
		frames := anim.NewCycle(.1e9, false, util.SmallIcons(util.Items, 32, 33, 34, 35))
		f.anim.Add(
			anim.Func(func(t int64, offset image.Point) {
				frames.Frame(t).Draw(offset)
			}), space.SimpleFootprint(loc), .4e9)
	case LargeExplosion:
		frames := anim.NewCycle(.10e9, false, util.LargeIcons(util.Items, 5, 6, 7, 8, 9))
		f.anim.Add(
			anim.Func(func(t int64, offset image.Point) {
				frames.Frame(t).Draw(offset)
			}), space.SimpleFootprint(loc), .5e9)
	case Sparks:
		frames := anim.NewCycle(.07e9, false, util.SmallIcons(util.Items, 36, 37, 38))
		f.anim.Add(
			anim.Func(func(t int64, offset image.Point) {
				frames.Frame(t).Draw(offset)
			}), space.SimpleFootprint(loc), .21e9)
	case BloodSquib:
		frames := anim.NewCycle(.07e9, false, util.SmallIcons(util.Items, 39, 40, 41))
		f.anim.Add(
			anim.Func(func(t int64, offset image.Point) {
				frames.Frame(t).Draw(offset)
			}), space.SimpleFootprint(loc), .21e9)
	case Smoke:
		frames := anim.NewCycle(.07e9, false, util.SmallIcons(util.Items, 42, 43, 44))
		f.anim.Add(
			anim.Func(func(t int64, offset image.Point) {
				frames.Frame(t).Draw(offset)
			}), space.SimpleFootprint(loc), .21e9)
	default:
		println("Unknown blast kind ", kind)
		return
	}

}
Ejemplo n.º 2
0
// Beam generates a projectile beam effect in the game world.
func (f *Fx) Beam(origin space.Location, dir image.Point, length int, kind BeamKind) {
	// Make a footprint for the beam shape.
	shape := []image.Point{image.Pt(0, 0)}
	for i := 0; i < length; i++ {
		shape = append(shape, shape[len(shape)-1].Add(dir))
	}
	footprint := space.FootprintFromPoints(f.world.Manifold, origin, shape)

	screenVec := util.ChartToScreen(shape[len(shape)-1])

	// TODO: Different beam types.

	f.anim.Add(
		anim.Func(func(t int64, offset image.Point) {
			gfx.Line(
				sdl.Frame(),
				offset.Add(util.HalfTile),
				offset.Add(util.HalfTile).Add(screenVec),
				gfx.LerpCol(gfx.Gold, gfx.Black, float64(t)/float64(.5e9)))
		}), footprint, .2e9)
}