本文整理匯總了Golang中github.com/0xe2-0x9a-0x9b/Go-SDL/sdl.Surface.Flip方法的典型用法代碼示例。如果您正苦於以下問題:Golang Surface.Flip方法的具體用法?Golang Surface.Flip怎麽用?Golang Surface.Flip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/0xe2-0x9a-0x9b/Go-SDL/sdl.Surface
的用法示例。
在下文中一共展示了Surface.Flip方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: undrawColor
func undrawColor(ss *sdl.Surface, w, h int32, col uint32) {
var x, y int32
for y = 0; y < h; y++ {
for x = 0; x < w; x++ {
col := sdlGet(x, y, ss) & (^col)
sdlSet2(x, y, col, ss)
}
}
ss.Flip()
}
示例2: setDist
// Set distance of nearby points (from point ax,ay -> bx,by) in given dir (0=N,
// 1=S, 2=E, 3=W)
func setDist(ss *sdl.Surface, rmc [][]int32, dist [][][]int32, aX, aY, bX, bY, dir, w, h, r, currBestDist, lastSetX, lastSetY int32, done, found bool, round int) (newDone, newFound bool, newBest int32, setX, setY int32) {
newDone, newFound, newBest, setX, setY = done, found, currBestDist, lastSetX, lastSetY
if !inRect(bX, bY, w, h) {
return
}
dA := dist[aX][aY]
_, best := bestDist(dA)
best += 4 * (r + 1) * (r + 1)
if best >= currBestDist { // we alredy have better distance (smaller is better)
return
}
dB := dist[bX][bY]
rmCount := removeCount(ss, rmc, w, h, bX, bY, r)
if currBestDist == DistMax && rmCount > 0 && best < DistMax {
//fmt.Printf("==== found rmCount=%d best=%d bX=%d bY=%d\n", rmCount, best, bX, bY)
newBest = best
newFound = true
}
//fmt.Printf("setDist aX=%d aY=%d bX=%d bY=%d rmCount=%d\n", aX, aY, bX, bY, rmCount)
if best < dB[dir] && rmCount != -1 { // part of model would be removed
if aX&7 == 0 && aY&7 == 0 {
if round > 20 {
fmt.Printf("setDist x=%d y=%d value=%d dB[dir]=%d\n", aX, aY, best, dB[dir])
}
sdlSet(aX, aY, ColDebug, ss)
if aX&63 == 0 && aY&63 == 0 {
ss.Flip()
}
}
dB[dir] = best - rmCount // favourize paths that remove more material
newDone = false
setX, setY = bX, bY
}
return
}
示例3: findAndRemove
//.........這裏部分代碼省略.........
}
dstMin := DistMax
tX, tY := int32(-1), int32(-1)
removed := false
for x, y, a, ok := nearRectBegin(cX, cY, w, h, 1); ok; x, y, a, ok = nearRectNext(cX, cY, x, y, a, w, h) {
if removeCount(ss, rmc, w, h, x, y, r) <= 0 {
continue
}
removed = true
dst := DistMax
if found {
_, dst = bestDist(dist[x][y])
} else {
dst = abs32(cX-x) + abs32(cY-y)
}
if dst < dstMin {
dstMin, tX, tY = dst, x, y
}
}
fmt.Printf("removed=%t found=%t dstMin=%d tX=%d tY=%d\n", removed, found, dstMin, tX, tY)
if !removed {
return false, false, tX, tY
}
if !found {
return true, false, tX, tY
}
var dirs []int
for x, y := tX, tY; x != cX || y != cY; {
dir, _ := bestDist(dist[x][y])
dirs = append(dirs, dir)
if dir == dir_N {
y--
} else if dir == dir_S {
y++
} else if dir == dir_E {
x++
} else if dir == dir_W {
x--
} else if dir == dir_NW {
x, y = x-1, y-1
} else if dir == dir_NE {
x, y = x+1, y-1
} else if dir == dir_SW {
x, y = x-1, y+1
} else if dir == dir_SE {
x, y = x+1, y+1
}
/*fmt.Printf(" N S E W NW NE SE SW| N S E W NW NE SE SW| N S E W NW NE SE SW| N S E W NW NE SE SW| N S E W NW NE SE SW\n")
for i := y - 3; i <= y+3; i++ {
for j := x - 3; j <= x+3; j++ {
if !inRect(i, j, w, h) {
continue
}
dumpDists(dist[j][i])
fmt.Printf("| ")
}
fmt.Println()
}
fmt.Printf("x=%d y=%d dir=%d bestDist=%d\n", x, y, dir, dst)
fmt.Scanln()*/
}
for x, y, i := cX, cY, len(dirs)-1; i >= 0; i-- {
dir := dirs[i]
if dir == dir_N {
y++
} else if dir == dir_S {
y--
} else if dir == dir_E {
x--
} else if dir == dir_W {
x++
} else if dir == dir_NW {
x, y = x+1, y+1
} else if dir == dir_NE {
x, y = x-1, y+1
} else if dir == dir_SW {
x, y = x+1, y-1
} else if dir == dir_SE {
x, y = x-1, y-1
}
//fmt.Printf("cX=%d cY=%d tX=%d tY=%d x=%d y=%d\n", cX, cY, tX, tY, x, y)
moveXy(tc, x, y, r, removeCount(ss, rmc, w, h, x, y, r))
removeMaterial(ss, rmc, w, h, x, y, r)
sdlSet(x, y, ColDebug, ss)
ss.Flip()
//fmt.Scanln()
}
return true, true, tX, tY
}