コード例 #1
0
ファイル: engine.go プロジェクト: monopole/volley
// Find the ball closest to the impulse and within a reasonable
// range, apply new velocity to the ball.
func (gn *Engine) applyImpulse(impulse *model.Ball) {
	if gn.chatty {
		log.Printf("Got impulse: %s", impulse.String())
	}
	closest, ball := gn.closestDsq(impulse.GetPos())
	if ball == nil {
		if gn.chatty {
			log.Printf("No ball to punch.")
		}
		return
	}
	if gn.chatty {
		log.Printf("DSQ to ball: %f.1\n", closest)
	}
	if closest <= gn.maxDistSqForImpulse {
		if gn.chatty {
			log.Printf("Punching ball.\n")
		}
		ball.SetVel(impulse.GetVel().X, impulse.GetVel().Y)
	} else {
		if gn.chatty {
			log.Printf("Ball further than %f.1\n",
				gn.maxDistSqForImpulse)
		}
	}
}
コード例 #2
0
ファイル: engine.go プロジェクト: monopole/volley
func (gn *Engine) throwOneBall(b *model.Ball, direction model.Direction) {
	// Before throwing, normalize the Y coordinate to a dimensionless
	// percentage.  Recipient converts it based on their own dimensions,
	// so that if the ball left one tenth of the way up the screen, it
	// enters the next screen at the same relative position.
	b.SetPos(b.GetPos().X, b.GetPos().Y/gn.scn.Height())
	gn.chBallCommand <- model.BallCommand{b, direction}
}
コード例 #3
0
ファイル: v23_manager.go プロジェクト: monopole/volley
func serializeBall(b *model.Ball) ifc.Ball {
	wp := ifc.Player{int32(b.Owner().Id())}
	return ifc.Ball{
		wp, b.GetPos().X, b.GetPos().Y, b.GetVel().X, b.GetVel().Y}
}