Last active
April 10, 2020 07:35
-
-
Save channel2007/71a16c6867e293a0ac94de4d938ea8f4 to your computer and use it in GitHub Desktop.
那些年我們一起玩過的遊戲(三)-打磚塊 - drew.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
#------------------------------------------------------------------------- | |
# 畫Box. | |
#------------------------------------------------------------------------- | |
class Box(object): | |
#------------------------------------------------------------------------- | |
# 建構式. | |
# pygame : pygame. | |
# canvas : 畫佈. | |
# name : 物件名稱. | |
# rect : 位置、大小. | |
# color : 顏色. | |
#------------------------------------------------------------------------- | |
def __init__( self, pygame, canvas, name, rect, color): | |
self.pygame = pygame | |
self.canvas = canvas | |
self.name = name | |
self.rect = rect | |
self.color = color | |
self.visible = True | |
#------------------------------------------------------------------------- | |
# 更新. | |
#------------------------------------------------------------------------- | |
def update(self): | |
if(self.visible): | |
self.pygame.draw.rect( self.canvas, self.color, self.rect) | |
#------------------------------------------------------------------------- | |
# 畫圓. | |
#------------------------------------------------------------------------- | |
class Circle(object): | |
#------------------------------------------------------------------------- | |
# 建構式. | |
# pygame : pygame. | |
# canvas : 畫佈. | |
# name : 物件名稱. | |
# pos : 位置. | |
# radius : 大小. | |
# color : 顏色. | |
#------------------------------------------------------------------------- | |
def __init__( self, pygame, canvas, name, pos, radius, color): | |
self.pygame = pygame | |
self.canvas = canvas | |
self.name = name | |
self.pos = pos | |
self.radius = radius | |
self.color = color | |
self.visible = True | |
#------------------------------------------------------------------------- | |
# 更新. | |
#------------------------------------------------------------------------- | |
def update(self): | |
if(self.visible): | |
self.pygame.draw.circle( self.canvas, self.color, self.pos , self.radius) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment