25 lines
534 B
Python
25 lines
534 B
Python
import random
|
|
|
|
# 位置
|
|
class Point:
|
|
def __init__(self, x, y):
|
|
self.x = x
|
|
self.y = y
|
|
|
|
# 按纽
|
|
class Button:
|
|
def __init__(self, x1, y1, x2 = 0, y2 = 0):
|
|
self.x1 = x1
|
|
self.y1 = y1
|
|
self.x2 = x2
|
|
self.y2 = y2
|
|
|
|
def get_point(self, ran = True):
|
|
if ran == True and self.x2 > 0 and self.y2 > 0:
|
|
return Point(int(random.uniform(self.x1, self.x2)), int(random.uniform(self.y1, self.y2)))
|
|
else:
|
|
return Point(self.x1, self.y1)
|
|
|
|
|
|
|
|
|