1 回答
TA贡献1805条经验 获得超10个赞
我发现出了什么问题,我实际上不得不对表面进行更改。这是代码:
package main
import (
"fmt"
"github.com/veandco/go-sdl2/sdl"
)
func main() {
var (
winTitle string = "Surface At"
winWidth, winHeight int32 = 1200, 720
window *sdl.Window
surface *sdl.Surface
)
window, _ = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, winWidth, winHeight, sdl.WINDOW_SHOWN)
surface, _ = window.GetSurface()
surface.FillRect(&sdl.Rect{50, 50, 600, 300}, 39700) //Change color from x - {50; 600}, y - {50; 300}
color1 := surface.At(100, 100)
color2 := surface.At(5, 5)
fmt.Printf("%v color at %d x, %d y\n", color1, 100, 100)
fmt.Printf("%v color at %d x, %d y\n", color2, 5, 5)
sdl.Delay(4000)
sdl.Quit()
}
输出是:
{20 155 0 255} 颜色在 100 x、100 y
{0 0 0 255} 颜色在 5 x, 5 y
- 1 回答
- 0 关注
- 100 浏览
添加回答
举报