Exemplo n.º 1
0
func (me *Drawer) init() bool {
	me.anim = gfx.NewAnimation(1000)
	me.box = gfx.LoadImageSize("box.png", 100, 100)
	font := gfx.LoadFont("LiberationSans-Bold.ttf", 32)
	if font != nil {
		font.SetRGB(0, 0, 255)
		me.text = font.Write("starfish 0.12!")
		font.Free()
	} else {
		fmt.Println("Could not load LiberationSans-Bold.ttf.")
		return false
	}
	if me.box == nil {
		fmt.Println("Could not load box.png.")
		return false
	}
	me.anim.LoadImageSize("box.png", 70, 70)
	me.anim.LoadImageSize("dots.png", 70, 70)
	return true
}
Exemplo n.º 2
0
func (mm *MainMenu) init() bool {
	baseHeight := gfx.DisplayHeight()
	baseWidth := gfx.DisplayWidth()
	mm.logoY = baseHeight / 2
	mm.logoX = baseWidth / 2
	font := gfx.LoadFont("LiberationSans-Bold.ttf", 32)
	mm.logo = gfx.LoadImageSize("test.jpg", 16, 16)
	font.SetRGB(255, 60, 0)
	mm.menu = append(mm.menu, MenuItem{text: font.Write("Start"), x: (baseHeight / 2), y: (baseWidth / 5) + 50})
	mm.menu = append(mm.menu, MenuItem{text: font.Write("Do"), x: (baseHeight / 2), y: (baseWidth / 5) + 100})
	if font != nil {
		font.SetRGB(255, 60, 0)
		mm.Title = font.Write("Worldlord: Wrath of Chaos")
		font.Free()
	} else {
		println("Unable to load font")
		return false
	}
	return true
}