Example #1
0
def setup(level):  # Setup objects for the level from module courses
    global line, par, hole, power, ballStationary, objects, ballColor, stickyPower, superPower, mullagain, freeShot
    global halo
    ballColor = (255, 255, 255)
    stickyPower = False
    superPower = False
    mullagain = False
    freeShot = False
    halo = False
    if level >= 10:
        endScreen()  # Completed the course
    else:
        list = courses.getPar(1)
        par = list[level - 1]
        pos = courses.getStart(level, 1)
        ballStationary = pos

        objects = courses.getLvl(level)

        # Create the borders if sand is one of the objects
        for i in objects:
            if i[4] == 'sand':
                objects.append([i[0] - 16, i[1], 16, 64, 'edge'])
                objects.append(
                    [i[0] + ((i[2] // 64) * 64), i[1], 16, 64, 'edge'])
                objects.append([i[0], i[1] + 64, i[2], 16, 'bottom'])
            elif i[4] == 'flag':
                # Define the position of the hole
                hole = (i[0] + 2, i[1] + i[3])

        line = None
        power = 1
Example #2
0
def setup():  # Setup objects for the level from module courses
    global level, line, par, hole, power, ball, level_map, stickyPower, superPower, mullagain
    ball.color = (255,255,255)
    stickyPower = False
    superPower = False
    mullagain = False
    if level >= 10:
        endScreen()  # Completed the course
    else:
        list = courses.getPar(1)
        par = list[level - 1]
        pos = courses.getStart(level, 1)
        ball.set_coordinates(*pos)

        level_map = Map(courses.getLvl(level))

        # Create the borders if sand is one of the objects
        for flag in level_map.flags():
            hole = MapHole(flag.x1 + 2, flag.y1 + flag.y2)

        line = None
        power = 1
Example #3
0
def overHole(x, y):  # Determine if we are over top of the hole
    if hole[0] - 6 < x < hole[0] + 6:
        if hole[1] - 13 < y < hole[1] + 10:
            return True
        else:
            return False
    else:
        return False


list = courses.getPar(1)
par = list[level - 1]
sheet = ScoreSheet(list)

pos = courses.getStart(level, 1)
ballStationary = pos
setup(1)

# MAIN GAME LOOP:
# - Collision of ball
# - Locking angle and power
# - Checking if power up buttons are clicked
# - Shooting the ball, uses physics module
# - Keeping track of strokes
# - Calls all functions and uses modules/classes imported and defined above

# Start loop
# Display start screen
hover = False
starting = True
Example #4
0
def onGreen():  # Determine if we are on the green
    for green in level_map.greens():
        return green.is_on_me(ball)

def on_green_angle_line(level_map):
    if ball.x > level_map.flagx():
        return math.pi, (ball.x - 30, ball.y)
    else:
        return 0, (ball.x + 30, ball.y)

list = courses.getPar(1)
par = list[0]
sheet = scoreSheet(list)

pos = courses.getStart(1, 1)
ball.set_coordinates(*pos)
setup()


# MAIN GAME LOOP:
# - Collision of ball
# - Locking angle and power
# - Checking if power up buttons are clicked
# - Shooting the ball, uses physics module
# - Keeping track of strokes
# - Calls all functions and uses modules/classes imported and defined above

# Start loop
# Display start screen
run_start_screen(win)