balls

BaseBall

class gobigger.balls.base_ball.BaseBall(ball_id, position, score, border, **kwargs)[source]
Overview:

Base class of all balls

check_border()[source]
Overview:

Check to see if the position of the ball exceeds the bounds of the map. If it exceeds, the speed and acceleration in the corresponding direction will be zeroed, and the position will be edged

static default_config()[source]
Overview:

Default config

eat(ball)[source]
Overview:

Describe the rules of eating and being eaten

Parameters:

ball <BaseBall>: Eaten ball

get_dis(ball)[source]
Overview:

Get the distance between the centers of the two balls

Parameters:

ball <BaseBall>: another ball

judge_cover(ball)[source]
Overview:

Determine whether the center of the two balls is covered

Parameters:

ball <BaseBall>: another ball

Returns:

is_covered <bool>: covered or not

judge_in_rectangle(rectangle)[source]
Overview:

Determine if the ball and rectangle intersect

Parameters:

rectangle <List>: left_top_x, left_top_y, right_bottom_x, right_bottom_y

Returns:

<bool> : intersect or not

move(direction, duration)[source]
Overview:

Realize the movement of the ball, pass in the direction and time parameters, and return the new position

Parameters:

direction <Vector2>: A point in the unit circle duration <float>: time

Returns:

position <Vector2>: position after moving

remove()[source]
Overview:

Things to do when being removed from the map

FoodBall

class gobigger.balls.food_ball.FoodBall(ball_id, position, score, border, **kwargs)[source]
Overview:
  • characteristic:

  • Can’t move, can only be eaten, randomly generated

static default_config()[source]
Overview:

Default config

eat(ball)[source]
Overview:

Describe the rules of eating and being eaten

Parameters:

ball <BaseBall>: Eaten ball

move(direction, duration)[source]
Overview:

Realize the movement of the ball, pass in the direction and time parameters, and return the new position

Parameters:

direction <Vector2>: A point in the unit circle duration <float>: time

Returns:

position <Vector2>: position after moving

ThornsBall

class gobigger.balls.thorns_ball.ThornsBall(ball_id, position, score, border, **kwargs)[source]
Overview:
  • characteristic:

  • Can’t move actively

  • Can eat spores. When eating spores, it will inherit the momentum of the spores and move a certain distance.

  • Can only be eaten by balls heavier than him. After eating, it will split the host into multiple smaller units.

  • Nothing happens when a ball lighter than him passes by

static default_config()[source]
Overview:

Default config

eat(ball)[source]
Overview:

Describe the rules of eating and being eaten

Parameters:

ball <BaseBall>: Eaten ball

move(direction=None, duration=0.05, **kwargs)[source]
Overview:

Realize the movement of the ball, pass in the direction and time parameters, and return the new position

Parameters:

direction <Vector2>: A point in the unit circle duration <float>: time

Returns:

position <Vector2>: position after moving

CloneBall

class gobigger.balls.clone_ball.CloneBall(ball_id, position, score, border, team_id, player_id, vel_given=<Vector2(0, 0)>, acc_given=<Vector2(0, 0)>, from_split=False, from_thorns=False, split_direction=<Vector2(0, 0)>, spore_settings={'score_init': 1.5, 'vel_init': 50, 'vel_zero_frame': 10}, sequence_generator=None, **kwargs)[source]
Overview:

One of the balls that a single player can control - characteristic: * Can move * Can eat any other ball smaller than itself * Under the control of the player, the movement can be stopped immediately and contracted towards the center of mass of the player * Skill 1: Split each unit into two equally * Skill 2: Spit spores forward * There is a percentage of weight attenuation, and the radius will shrink as the weight attenuates

static default_config()[source]
Overview:

Default config

eat(ball, clone_num=None)[source]
Parameters:

clone_num <int>: The total number of balls for the current player

eject(direction=None) list[source]
Overview:

When spit out spores, the spores spit out must be in the moving direction of the ball, and the position is tangent to the original ball after spitting out

Returns:

Return a list containing the spores spit out

judge_rigid(ball)[source]
Overview:

Determine whether two balls will collide with a rigid body

Parameters:

ball <CloneBall>: another ball

Returns:

<bool>: collide or not

move(given_acc=None, given_acc_center=None, duration=0.05)[source]
Overview:

Realize the movement of the ball, pass in the direction and time parameters

on_thorns(split_num) list[source]
Overview:

Split after encountering thorns, calculate the score, position, speed, acceleration of each ball after splitting

Parameters:

split_num <int>: Number of splits added

Returns:

Return a list that contains the newly added balls after the split, the distribution of the split balls is a circle and the center of the circle has a ball

rigid_collision(ball)[source]
Overview:

When two balls collide, We need to determine whether the two balls belong to the same player A. If not, do nothing until one party is eaten at the end B. If the two balls are the same owner, judge whether the age of the two is full or not meet the fusion condition, if they are satisfied, do nothing. C. If the two balls are the same owner, judge whether the age of the two is full or not meet the fusion condition, Then the two balls will collide with rigid bodies This function completes the C part: the rigid body collision part, the logic is as follows:

  1. To determine the degree of fusion of the two balls, use [the radius of both] and subtract [the distance between the two] as the magnitude of the force

  2. Calculate the coefficient according to the weight, the larger the weight, the smaller the coefficient will be

  3. Correct the position of the two according to the coefficient and force

Parameters:

ball <CloneBall>: another ball

Returns:

state <bool>: the operation is successful or not

score_decay()[source]
Overview:

Control the score of the ball to decay over time

split(clone_num, direction=None) list[source]
Overview:

Active splitting, the two balls produced by splitting have the same volume, and their positions are tangent to the forward direction

Parameters:

clone_num <int>: The total number of balls for the current player

Returns:

The return value is the new ball after the split

SporeBall

class gobigger.balls.spore_ball.SporeBall(ball_id, position, border, score, direction=<Vector2(0, 0)>, owner=-1, **kwargs)[source]
Overview:

Spores spit out by the player ball - characteristic: * Can’t move actively * can not eat * Can be eaten by CloneBall and ThornsBall * There is an initial velocity at birth, and it decays to 0 within a period of time

static default_config()[source]
Overview:

Default config

eat(ball)[source]
Overview:

Describe the rules of eating and being eaten

Parameters:

ball <BaseBall>: Eaten ball

move(direction=None, duration=0.05)[source]
Overview:

Realize the movement of the ball, pass in the direction and time parameters, and return the new position

Parameters:

direction <Vector2>: A point in the unit circle duration <float>: time

Returns:

position <Vector2>: position after moving