Exemple #1
0
func LoadSpriteSpec(c gospec.Context) {
	c.Specify("Sample sprite loads correctly", func() {
		s, err := sprite.LoadSprite("test_sprite")
		c.Expect(err, Equals, nil)
		for i := 0; i < 2000; i++ {
			s.Think(50)
		}
		s.Command("defend")
		s.Command("undamaged")
		s.Command("defend")
		s.Command("undamaged")
		for i := 0; i < 3000; i++ {
			s.Think(50)
		}
		s.Command("turn_right")
		s.Command("turn_right")
		s.Command("turn_right")
		s.Command("turn_right")
		s.Command("turn_right")
		s.Command("turn_right")
		s.Command("turn_left")
		s.Command("turn_left")
		s.Command("turn_right")
		s.Command("turn_right")
		s.Command("turn_right")
		s.Command("turn_left")
		s.Command("turn_left")
		// s.Think(5000)
		for i := 0; i < 300; i++ {
			s.Think(50)
		}
		c.Expect(s.Facing(), Equals, 1)
	})
}
Exemple #2
0
func CommandNSpec(c gospec.Context) {
	c.Specify("Sample sprite loads correctly", func() {
		s, err := sprite.LoadSprite("test_sprite")
		c.Expect(err, Equals, nil)
		for i := 0; i < 2000; i++ {
			s.Think(50)
		}
		s.CommandN([]string{
			"turn_right",
			"turn_right",
			"turn_right",
			"turn_right",
			"turn_right",
			"turn_right",
			"turn_left",
			"turn_left",
			"turn_right",
			"turn_right",
			"turn_right",
			"turn_left",
			"turn_left"})
		s.Think(5000)
		c.Expect(s.Facing(), Equals, 1)
		for i := 0; i < 3000; i++ {
			s.Think(50)
		}
	})
}
Exemple #3
0
func SyncSpec(c gospec.Context) {
	c.Specify("Sample sprite loads correctly", func() {
		s1, err := sprite.LoadSprite("test_sprite")
		c.Expect(err, Equals, nil)
		s2, err := sprite.LoadSprite("test_sprite")
		c.Expect(err, Equals, nil)
		sprite.CommandSync([]*sprite.Sprite{s1, s2}, [][]string{[]string{"melee"}, []string{"defend", "damaged"}}, "hit")
		hit := false
		for i := 0; i < 20; i++ {
			s1.Think(50)
			s2.Think(50)
			if s1.Anim() == "melee_01" && s2.Anim() == "damaged_01" {
				hit = true
			}
		}
		c.Expect(hit, Equals, true)
	})
}
Exemple #4
0
func (b *boxdata) load(dir string) {
	go func() {
		anim, err := sprite.LoadSprite(dir)
		if err != nil {
			error_msg.SetText(err.Error())
		} else {
			b.sb.s = anim
			SetStoreVal(b.name, b.dir)
		}
	}()

	// This is outside of the goroutine because otherwise it might never become
	// visible since we never sync up with it.
	b.dir = dir
}
Exemple #5
0
func (sc *spriteContainer) Load(path string) {
	sc.sp, sc.err = sprite.LoadSprite(path)
	if sc.err != nil {
		base.Error().Printf("Unable to load sprite: %s:%v", path, sc.err)
	}
}