本文整理汇总了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
}