本文整理汇总了Golang中github.com/awesomegroupidunno/game-server/state.GameState.Vehicles方法的典型用法代码示例。如果您正苦于以下问题:Golang GameState.Vehicles方法的具体用法?Golang GameState.Vehicles怎么用?Golang GameState.Vehicles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/awesomegroupidunno/game-server/state.GameState
的用法示例。
在下文中一共展示了GameState.Vehicles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func (t *ConnectCommandProcessor) Run(g *state.GameState, c cmd.GameCommand) {
command := c.(*cmd.ConnectCommand)
// if the user already has a vehicle, ignore
vehicle := g.GetVehicle(command.UserId)
if vehicle != nil {
return
}
// For now, randomly join team 0 or 1
teamNum := len(g.Vehicles) % 2
size := state.NewSized(t.Physics.VehicleWidth, t.Physics.VehicleHeight)
pt := t.Physics.findSpace(size, *g)
newVehicle := state.Vehicle{
Point: pt,
Sized: size,
Velocity: 0.0,
Angle: 0,
TeamId: teamNum,
MaxHealth: t.Physics.VehicleHealth,
CurrentHealth: t.Physics.VehicleHealth,
Owner: command.UserId,
Mass: 10,
IsAlive: true,
ActivePowerup: NO_POWERUP,
StoredPowerup: NO_POWERUP,
OverRideSpeedTill: time.Now().Add(-5 * time.Second)}
g.Vehicles = append(g.Vehicles, &newVehicle)
}