當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Rect.Y方法代碼示例

本文整理匯總了Golang中github.com/veandco/go-sdl2/sdl.Rect.Y方法的典型用法代碼示例。如果您正苦於以下問題:Golang Rect.Y方法的具體用法?Golang Rect.Y怎麽用?Golang Rect.Y使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/veandco/go-sdl2/sdl.Rect的用法示例。


在下文中一共展示了Rect.Y方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: RenderGraphic

// RenderGraphic draws the Graphic, g, on the screen at postion (x,y).
// 'width' and 'height' specifiy the width and height of the Graphic, g.
//
// RenderGraphic will panic if:
// 1. The Graphic, g, does not contain a Graphic type.
//
// 2. The toolbox has not been initialised.
//
// 3. Any one of x, y, width or height are negative
func RenderGraphic(g Graphic, x, y, width, height int) {
	if !initialised {
		// this stops execution here, so ne need for an else after the if
		panic(notInitialisedMessage)
	}
	if g == nil {
		panic(nilGraphicMessage)
	}
	if x < 0 || y < 0 || width < 0 || height < 0 {
		panic("One of x, y, width or height is negative.")
	}
	var src, dst sdl.Rect

	src.X = 0
	src.Y = 0
	src.W = int32(width)
	src.H = int32(height)

	dst.X = int32(x)
	dst.Y = int32(y)
	dst.W = int32(width)
	dst.H = int32(height)

	renderer.Copy(g, &src, &dst)
}
開發者ID:gophercoders,項目名稱:toolbox,代碼行數:34,代碼來源:toolbox.go

示例2: renderGameOver

func renderGameOver() {
	var src, dst sdl.Rect

	src.X = 0
	src.Y = 0
	src.W = int32(gameOverW)
	src.H = int32(gameOverH)

	dst.X = int32(gameOverX)
	dst.Y = int32(gameOverY)
	dst.W = int32(gameOverW)
	dst.H = int32(gameOverH)

	renderer.Copy(gameOverGfx, &src, &dst)
}
開發者ID:gophercoders,項目名稱:pong,代碼行數:15,代碼來源:pong.go

示例3: renderComputersScore

func renderComputersScore() {
	var src, dst sdl.Rect

	src.X = 0
	src.Y = 0
	src.W = int32(scoreW)
	src.H = int32(scoreH)

	dst.X = int32(computersScoreX)
	dst.Y = int32(computersScoreY)
	dst.W = int32(scoreW)
	dst.H = int32(scoreH)

	renderer.Copy(scoresGfx[computersScore], &src, &dst)
}
開發者ID:gophercoders,項目名稱:pong,代碼行數:15,代碼來源:pong.go

示例4: DrawText

// DrawText is
func (T *TextWidget) DrawText(text string, rect *sdl.Rect, colorName string, fontName string) {
	if strings.TrimSpace(text) == "" {
		return
	}
	// log.Println("DRAW:", text, colorName, fontName)
	font, ok := T.Fonts[fontName]
	if !ok {
		font = T.Fonts["default"]
	}
	color, ok := T.Colors[colorName]
	if !ok {
		colorHex, err := hex.DecodeString(colorName[1:])
		if err != nil || len(colorHex) < 3 {
			color = T.Colors["foreground"]
		} else {
			T.AddColor(colorName, colorHex[0], colorHex[1], colorHex[2])
			color = T.Colors[colorName]
		}
	}
	message, err := font.RenderUTF8_Blended(text, color)
	if err != nil {
		log.Fatal(err)
	}
	defer message.Free()
	srcRect := sdl.Rect{}
	message.GetClipRect(&srcRect)
	if fontName != "default" {
		_, h, _ := T.Fonts["default"].SizeUTF8("A")
		_, h2, _ := font.SizeUTF8("A")
		rect.Y -= int32((h2 - h) / 2)
	}
	message.Blit(&srcRect, T.Surface, rect)
}
開發者ID:averrin,項目名稱:shadow-go,代碼行數:34,代碼來源:widget.go

示例5: renderBall

func renderBall() {

	var src, dst sdl.Rect

	src.X = 0
	src.Y = 0
	src.W = int32(ballW)
	src.H = int32(ballH)

	dst.X = int32(ballX)
	dst.Y = int32(ballY)
	dst.W = int32(ballW)
	dst.H = int32(ballH)

	renderer.Copy(ball, &src, &dst)

}
開發者ID:gophercoders,項目名稱:pong,代碼行數:17,代碼來源:pong.go

示例6: renderComputersBat

func renderComputersBat() {

	var src, dst sdl.Rect

	src.X = 0
	src.Y = 0
	src.W = int32(computersBatW)
	src.H = int32(computersBatH)

	dst.X = int32(computersBatX)
	dst.Y = int32(computersBatY)
	dst.W = int32(computersBatW)
	dst.H = int32(computersBatH)

	renderer.Copy(computersBat, &src, &dst)

}
開發者ID:gophercoders,項目名稱:pong,代碼行數:17,代碼來源:pong.go


注:本文中的github.com/veandco/go-sdl2/sdl.Rect.Y方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。