Example #1
0
func load() {
	// Initialize the engine with a working resolution of 1920x1080
	eng = gogam.NewEngine(1920, 1080)

	// Initialize a cat sprite at position (20,20)
	cat = gogam.NewSprite(20, 20)

	// Grab the cat texture
	t := gogam.NewTexture("cat.png", eng)

	// Get the cat's frame from the texture
	stillAf1 := gogam.NewAnimationFrame(t, image.Rect(0, 0, 139, 119), 1000)

	// Create an animation from the frame
	a := gogam.NewAnimation([]*gogam.AnimationFrame{stillAf1})

	// Add animation as a possible animation for the cat called "still"
	cat.AddAnimation("still", a)

	// Set the "still" animation as currently active animation
	cat.SetAnimation("still")

	// Tell the engine to draw the cat
	eng.Draw(cat)
}
Example #2
0
func load() {
	eng = gogam.NewEngine(1080, 1920)

	duck = gogam.NewSprite(20, 20)
	t := gogam.NewTexture("duck.png", eng)
	stillAf2 := gogam.NewAnimationFrame(t, image.Rect(256, 0, 512, 288), int(time.Millisecond*300))
	stillAf3 := gogam.NewAnimationFrame(t, image.Rect(512, 0, 768, 288), int(time.Millisecond*300))
	a := gogam.NewAnimation([]*gogam.AnimationFrame{stillAf2, stillAf3})
	duck.AddAnimation("still", a)
	duck.SetAnimation("still")

	eng.Draw(duck)
}