新上手pygame,断断续续学习python也有一短时间了,心血来潮复刻一个小游戏(其实差的不少)。
界面就是这样:
游戏目标也很简单:四色方框来回碰撞移动,控制黑色方框躲避他们,得分是坚持多少的秒数。
贴代码,新手水平,可以打磨的地方还有很多
import sys,pygame,time
from pygame.locals import *
pygame.init()
class box(object):
"""this produce a box which may block the controller"""
def __init__(self, x, y, color, hor, ver, box_len):
"""x and y as the position of box. ver is for vertical, hor is for horizontal. those are the moving speed of box.
box_len is the size"""
self.x = x
self.y = y
self.color = color
self.ver = ver
self.hor = hor
self.length = box_len
pygame.dra