-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathball.py
55 lines (35 loc) · 881 Bytes
/
ball.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
from globalVars import *
import frame
import math
class Ball(object):
def __init__(self):
self.x, self.y = ball_origin[0], ball_origin[1]
self.zoom = 1
def Move(self,xcoord,ycoord):
self.x = xcoord
self.y = ycoord
#self.zoom = ?
if self.x < 0:
self.x = 0
elif self.x >= screen_size[0]:
self.x = screen_size[0]
if self.y < 0:
self.y = 0
elif self.y >= screen_size[1]:
self.y = screen_size[1]
def Draw(self,f):
xmin = 0
xmax = BALL_SIZE_X * 2
ymin = 0
ymax = BALL_SIZE_Y * 2
xmin = (xmin*self.zoom)
ymin = (ymin*self.zoom)
xmax = (xmax*self.zoom)
ymax = (ymax*self.zoom)
xmin += self.x
xmax += self.x
ymin += self.y
ymax += self.y
f.LineTo((xmin,ymin), 0x80000000)
f.PolyLineOneColor([(xmin,ymin),(xmin,ymax),(xmax,ymax),(xmax,ymin)], 0xFFFFFF,True)