|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import pygame
import sys
class Shap1(object):
def __init__(self):
#rc = [(255,0,0),(255,255,0),(0,255,0),(0,128,255),(128,0,255),(255,128,0)]#颜色
#rp = [(225,-200),(200,-50)]#矩形形状描述(长)
#rs = [(50,250),(100,100)]#矩形形状描述(高)
#rq0 = [(175,-50),(225,-50),(225,0),(275,0),(325,0),(325,100),(275,100),(275,50),(175,50)]#多边形定点列表
#rq1 = [(275,-50),(325,-50),(325,50),(225,50),(225,100),(175,100),(175,0),(275,0)]#多边形定点列表
#rq2 = [(200,-100),(300,-100),(300,100),(250,100),(250,-50),(200,-50)]#多边形定点列表
#rq3 = [(200,-100),(300,-100),(300,-5),(250,-50),(250,100),(200,100)]#多边形定点列表
self.shap1X = 225
self.shap1Y = -200
self.speed = 5000
self.gravity = 5
self.down = False
def shap1Upade(self):
if self.down:
self.shap1Y += self.speed
else:
self.shap1Y += self.gravity
def createMap():
screen.fill((255, 255, 255))
shap1 = pygame.draw.rect(screen,(255,0,0),(Shap1.shap1X,Shap1.shap1Y,50,225))
Shap1.shap1Upade()
pygame.display.update()
if __name__ == '__main__':
'''主程序'''
pygame.init()
size = width,height = 650,750
screen = pygame.display.set_mode(size)
pygame.display.set_caption('俄罗斯方块')
clock = pygame.time.Clock()
Shap1 = Shap1()
createMap()
while True:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
break
if event.type ==pygame.KEYDOWN:
Shap1.down = True
else:
createMap()
while True:
clock.tick(40)
createMap()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
break
if event.type ==pygame.KEYDOWN:
Shap1.down = True
最后那段改成这样,你把createMap()放到event循环中去了,意思就是如果没任何事件发生更本都不会动(你鼠标、键盘没操作不会动);
|
|