Esempio n. 1
0
def check_all_balls_collision():
    for ball_a in BALLS:
        for ball_b in BALLS:
            if collide(ball_a, ball_b) == True:
                collided_radius_a = ball_a.ball_radius
                collid
                ed_radius_b = ball_b.ball_radius
        if ball_a > ball_b:
            collided_radius_a += 1
            while ball_dx or ball_dy > 0:
                ball_b = circle(screen_xpos, screen_ypos, ball_dx, ball_dy,
                                ball_radius)
        elif ball_b > ball_a:
            collided_radius_b += 1
            while ball_dx or ball_dy > 0:
                ball_a = circle(screen_xpos, screen_ypos, ball_dx, ball_dy,
                                ball_radius)
Esempio n. 2
0
def check_myball_collision():
    for my_ball in Balls:
        if collide(my_ball, Balls) == True:
            my_ball_radius = my_ball.ball_radius
            other_ball = ball_b.ball_radius
        if my_ball < ball_b:
            check_myball_collision = False
        elif my_ball > ball_b:
            my_ball += 1
            ball_b = circle(screen_xpos, screen_ypos, ball_dx, ball_dy,
                            ball_radius)
Esempio n. 3
0
from turtle import *
import time
import random
from ball4 import circle
import math
tracer(0)
hideturtle()
RUNNING = True
SLEEPING = 0.0077
SCREEN_WIDTH = getcanvas().winfo_width() / 2
SCREEN_HEIGHT = getcanvas().winfo_height() / 2

my_ball = circle(100, 10, 10, 10, 20, 'black')
NUMBER_OF_BALLS = 5
MINIMUM_BALL_RADIUS = 10
MAXIMUM_BALL_RADIUS = 30
MINIMUM_BALL_DX = -5
MAXIMUM_BALL_DX = 5
MINIMUM_BALL_DY = -5
MAXIMUM_BALL_DY = 5
BALLS = []
for i in range(NUMBER_OF_BALLS):
    screen_xpos = random.randint(int(-SCREEN_WIDTH + MAXIMUM_BALL_RADIUS),
                                 int(SCREEN_WIDTH - MAXIMUM_BALL_RADIUS))
    screen_ypos = random.randint(int(-SCREEN_HEIGHT + MAXIMUM_BALL_RADIUS),
                                 int(SCREEN_HEIGHT - MAXIMUM_BALL_RADIUS))
    ball_dx = random.randint(int(MINIMUM_BALL_DX), int(MAXIMUM_BALL_DX))
    ball_dy = random.randint(int(MINIMUM_BALL_DY), int(MAXIMUM_BALL_DY))
    ball_radius = random.randint(int(MINIMUM_BALL_RADIUS),
                                 int(MAXIMUM_BALL_RADIUS))
    new_ball = circle(screen_xpos, screen_ypos, ball_dx, ball_dy, ball_radius)
Esempio n. 4
0
from turtle import *
import time
import random
from ball4 import circle
tracer(0)
hideturtle()
RUNNING = True
SLEEPING = 0.0077
SCREEN_WIDTH = getcanvas().winfo_width() / 2
SCREEN_HEIGHT = getcanvas().winfo_height() / 2

my_ball = circle(100, 10, 10, 10, 15)
NUMBER_OF_BALLS = 5
MINIMUM_BALL_RADIUS = 10
MAXIMUM_BALL_RADIUS = 100
MINIMUM_BALL_DX = -5
MAXIMUM_BALL_DX = 5
MINIMUM_BALL_DY = -5
MAXIMUM_BALL_DY = 5
BALLS = []
for i in range(NUMBER_OF_BALLS):
    screen_xpos = random.randint(int(-SCREEN_WIDTH + MAXIMUM_BALL_RADIUS),
                                 int(SCREEN_WIDTH - MAXIMUM_BALL_RADIUS))
    screen_ypos = random.randint(int(-SCREEN_HEIGHT + MAXIMUM_BALL_RADIUS),
                                 int(SCREEN_HEIGHT - MAXIMUM_BALL_RADIUS))
    ball_dx = random.randint(int(MINIMUM_BALL_DX), int(MAXIMUM_BALL_DX))
    ball_dy = random.randint(int(MINIMUM_BALL_DY), int(MAXIMUM_BALL_DY))
    ball_radius = random.randint(int(MINIMUM_BALL_RADIUS),
                                 int(MAXIMUM_BALL_RADIUS))
    new_ball = circle(screen_xpos, screen_ypos, ball_dx, ball_dy, ball_radius)
    BALLS.append(new_ball)
Esempio n. 5
0
clear()
write('2', move=True, align='center', font=('Arial', 70, 'normal'))
time.sleep(1)
clear()
write('1', move=True, align='center', font=('Arial', 70, 'normal'))
clear()
time.sleep(1)

tracer(0)
hideturtle()
RUNNING = True
SLEEPING = 0.0077
SCREEN_WIDTH = getcanvas().winfo_width() / 2
SCREEN_HEIGHT = getcanvas().winfo_height() / 2
score = 0
shark_ball = circle(30, 20, 2, 5, 15, 'blue')
# intro()

my_ball = circle(100, 10, 0, 0, 20, 'black')
NUMBER_OF_BALLS = 5
MINIMUM_BALL_RADIUS = 10
MAXIMUM_BALL_RADIUS = 30
MINIMUM_BALL_DX = -5
MAXIMUM_BALL_DX = 5
MINIMUM_BALL_DY = -5
MAXIMUM_BALL_DY = 5
BALLS = []
for i in range(NUMBER_OF_BALLS):
    screen_xpos = random.randint(int(-SCREEN_WIDTH + MAXIMUM_BALL_RADIUS),
                                 int(SCREEN_WIDTH - MAXIMUM_BALL_RADIUS))
    screen_ypos = random.randint(int(-SCREEN_HEIGHT + MAXIMUM_BALL_RADIUS),