-
Notifications
You must be signed in to change notification settings - Fork 0
/
stumps.py
28 lines (24 loc) · 883 Bytes
/
stumps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Stumps class - drawing and check collisions
from cmu_112_graphics import *
from utilities import *
import math
import numpy
from batter import *
#stumps class
class Stumps(object):
def __init__(self, mode):
self.topX = mode.margin + 50
self.topY = mode.height - mode.lowerMargin - 100
self.bottomX = mode.margin + 50
self.bottomY = mode.height - mode.lowerMargin
#draws stumps
def drawStumps(mode, canvas):
canvas.create_line(mode.stumps.topX, mode.stumps.topY, mode.stumps.bottomX,
mode.stumps.bottomY, width=5, fill='orange')
#checks if ball hits stumps
def checkBallHitStumps(mode):
stumps = mode.stumps
for ball in mode.balls:
if ball.cx - ball.radius < stumps.topX < ball.cx + ball.radius and \
stumps.topY < ball.cy + ball.radius < stumps.bottomY:
batterOut(mode)