func CreateGame(client *Client) (g *Game_t, id uint32) { id = GameCounter GameCounter += 1 g = &Game_t{id, make([]*Client, 0), make([]*GameObject, 0), nil, 0, 0, time.Now(), time.Now(), true, false, -1, 0, list.New()} g.RegisterPlayer(client) g.Space = chipmunk.NewSpace() g.Space.Gravity = vect.Vect{0, -9.8} RegisterGame(g) return g, id }
// createBodies sets up the chipmunk space and static bodies func createBodies() { space = chipmunk.NewSpace() space.Gravity = vect.Vect{0, -900} staticBody := chipmunk.NewBodyStatic() staticLines = []*chipmunk.Shape{ chipmunk.NewSegment(vect.Vect{111.0, 280.0}, vect.Vect{407.0, 246.0}, 0), chipmunk.NewSegment(vect.Vect{407.0, 246.0}, vect.Vect{407.0, 343.0}, 0), } for _, segment := range staticLines { segment.SetElasticity(0.6) staticBody.AddShape(segment) } space.AddBody(staticBody) }