本文整理匯總了Golang中github.com/skarr/GarageEngine/engine.Vector.Add方法的典型用法代碼示例。如果您正苦於以下問題:Golang Vector.Add方法的具體用法?Golang Vector.Add怎麽用?Golang Vector.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/skarr/GarageEngine/engine.Vector
的用法示例。
在下文中一共展示了Vector.Add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetCollisions2
func (m *Map) GetCollisions2(worldPosition engine.Vector, width, height float32, xCollisions, yCollisions []int) (x, y []int) {
_, x1, y1 := m.PositionToTile(worldPosition.Add(engine.Vector{width / 2, height / 2, 0}))
_, x2, y2 := m.PositionToTile(worldPosition.Add(engine.Vector{-width / 2, -height / 2, 0}))
if x1 > x2 {
x1, x2 = x2, x1
}
if y1 > y2 {
y1, y2 = y2, y1
}
for ; y1 <= y2; y1++ {
for x := x1; x <= x2; x++ {
if !m.IsTileWalkabke(x, y1) {
if xCollisions == nil {
xCollisions = make([]int, 0, 4)
}
if yCollisions == nil {
yCollisions = make([]int, 0, 4)
}
xCollisions = append(xCollisions, x)
yCollisions = append(yCollisions, y1)
}
}
}
return xCollisions, yCollisions
}
示例2: CheckCollision
func (m *Map) CheckCollision(worldPosition engine.Vector, width, height float32) bool {
_, x1, y1 := m.PositionToTile(worldPosition.Add(engine.Vector{width / 2, height / 2, 0}))
_, x2, y2 := m.PositionToTile(worldPosition.Add(engine.Vector{-width / 2, -height / 2, 0}))
if x1 > x2 {
x1, x2 = x2, x1
}
if y1 > y2 {
y1, y2 = y2, y1
}
for ; y1 <= y2; y1++ {
for x := x1; x <= x2; x++ {
if !m.IsTileWalkabke(x, y1) {
return true
}
}
}
return false
}