本文整理汇总了Golang中github.com/runningwild/haunts/game.Entity.Dims方法的典型用法代码示例。如果您正苦于以下问题:Golang Entity.Dims方法的具体用法?Golang Entity.Dims怎么用?Golang Entity.Dims使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/runningwild/haunts/game.Entity
的用法示例。
在下文中一共展示了Entity.Dims方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: distBetweenEnts
func distBetweenEnts(e1, e2 *game.Entity) int {
x1, y1 := e1.Pos()
dx1, dy1 := e1.Dims()
x2, y2 := e2.Pos()
dx2, dy2 := e2.Dims()
var xdist int
switch {
case x1 >= x2+dx2:
xdist = x1 - (x2 + dx2)
case x2 >= x1+dx1:
xdist = x2 - (x1 + dx1)
default:
xdist = 0
}
var ydist int
switch {
case y1 >= y2+dy2:
ydist = y1 - (y2 + dy2)
case y2 >= y1+dy1:
ydist = y2 - (y1 + dy1)
default:
ydist = 0
}
if xdist > ydist {
return xdist
}
return ydist
}
示例2: findDoors
func (a *Interact) findDoors(ent *game.Entity, g *game.Game) []*house.Door {
room_num := ent.CurrentRoom()
room := g.House.Floors[0].Rooms[room_num]
x, y := ent.Pos()
dx, dy := ent.Dims()
ent_rect := makeIntFrect(x, y, x+dx, y+dy)
var valid []*house.Door
for _, door := range room.Doors {
if door.AlwaysOpen() {
continue
}
if ent_rect.Overlaps(makeRectForDoor(room, door)) {
valid = append(valid, door)
}
}
return valid
}
示例3: AiInteractWithObject
func (a *Interact) AiInteractWithObject(ent, object *game.Entity) game.ActionExec {
if ent.Stats.ApCur() < a.Ap {
return nil
}
if distBetweenEnts(ent, object) > a.Range {
return nil
}
x, y := object.Pos()
dx, dy := object.Dims()
if !ent.HasLos(x, y, dx, dy) {
return nil
}
var exec interactExec
exec.SetBasicData(ent, a)
exec.Target = object.Id
return &exec
}