コード例 #1
0
ファイル: raptgo.go プロジェクト: manveru/raptgo
// draw lines of text aligned around center of screen
func DrawTextLines(strings []string) {
	var dstrect, srcrect *sdl.Rect
	var line *sdl.Surface
	var w, h, prevH uint16

	centerX := int16(Width / 2)
	centerY := int16(Height / 2)

	for _, str := range strings {
		line = RenderText(str, Red)
		line.GetClipRect(srcrect)

		w, h = uint16(line.W), uint16(line.H)

		dstrect = &sdl.Rect{
			X: centerX - int16(w/2),
			Y: (centerY + int16(prevH)) - int16(h/2),
			W: w,
			H: h,
		}

		prevH += h

		Screen.Blit(dstrect, line, srcrect)
		line.Free()
	}
}