Esempio n. 1
0
// RenderText is a helper function to generate and track a surface with some text on it
func (am *AssetManager) RenderText(surfaceKey, fontKey string, text string, color sdl.Color) (*sdl.Surface, error) {
	surface, err := util.RenderText(am.Fonts[fontKey], text, color)

	if err == nil {
		am.AddSurface(surfaceKey, surface)
	}

	return surface, err
}
Esempio n. 2
0
// constructInterludeImage builds the "LEVEL X" image
func (ps *PlayState) constructInterludeImage() {
	surface, err := util.RenderText(ps.assetManager.Fonts["interludeFont"], fmt.Sprintf("LEVEL %d", ps.level), sdl.Color{R: 255, G: 255, B: 0, A: 255})

	if err != nil {
		panic(fmt.Sprintf("Error constructing interlude text: %v", err))
	}

	ps.interludeTextEntity.Surface = surface
	ps.interludeTextEntity.W = surface.W // hackishly make centering work on the next line
	scenegraph.CenterEntityInParent(ps.interludeTextEntity, ps.rootEntity)
}