本文整理汇总了Golang中github.com/awesomegroupidunno/game-server/state.GameState.Bullets方法的典型用法代码示例。如果您正苦于以下问题:Golang GameState.Bullets方法的具体用法?Golang GameState.Bullets怎么用?Golang GameState.Bullets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/awesomegroupidunno/game-server/state.GameState
的用法示例。
在下文中一共展示了GameState.Bullets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func (t *FireCommandProcessor) Run(g *state.GameState, c cmd.GameCommand) {
if t.lastFired == nil {
t.lastFired = make(map[string]time.Time)
}
command := c.(*cmd.FireCommand)
vehicle := g.GetVehicle(command.UserId)
if vehicle == nil || !vehicle.IsAlive {
return
}
last := t.lastFired[vehicle.Owner]
diff := time.Now().Sub(last)
if diff < t.Physics.BulletDelay {
return
}
t.lastFired[vehicle.Owner] = time.Now()
b := state.Bullet{
Point: state.NewPoint(vehicle.X, vehicle.Y),
Sized: state.NewSized(t.Physics.BulletWidth, t.Physics.BulletWidth),
Velocity: t.Physics.BulletVelocity,
Angle: vehicle.Angle,
OwnerId: vehicle.Owner,
}
g.Bullets = append(g.Bullets, &b)
}