Exemple #1
0
func (this *Race) RegisterRacer(player *Player) {
	box := chipmunk.NewBox(vect.Vector_Zero, player.Ship.Prototype.Width, player.Ship.Prototype.Height)
	box.SetElasticity(0.9)
	body := chipmunk.NewBody(player.Ship.Prototype.Mass, box.Moment(player.Ship.Prototype.Moment))
	body.AddShape(box)
	player.Ship.Body = body
	this.Racers = append(this.Racers, &PlayerPosition{player.Name, vect.Vect{player.Ship.Prototype.Width, player.Ship.Prototype.Height}, vect.Vector_Zero, 0, 0, make([]int, 0), false, player, make([]*Message, 0), make([]*Location, 0)})
}
Exemple #2
0
func addBall() {
	x := rand.Intn(1135) + 115
	//ball := chipmunk.NewCircle(vect.Vector_Zero, vect.Float(ballRadius))
	ball := chipmunk.NewBox(vect.Vector_Zero, 50, 50)
	ball.SetElasticity(0.9)
	body := chipmunk.NewBody(vect.Float(10000000), ball.Moment(vect.Float(100000000)))
	body.SetPosition(vect.Vect{vect.Float(x), 100.0})
	body.SetAngle(vect.Float(rand.Float64() * 2 * math.Pi))
	//	t := 2
	//	if(rand.Intn(2) == 1){
	//		t *= -1
	//	}
	//	body.AddTorque(vect.Float(t))
	body.AddShape(ball)
	space.AddBody(body)
	balls = append(balls, &Ship{x, ball})
}