Commit 4b4ded04 by BellCodeEditor

save project

parent fbdcb24d
Showing with 12 additions and 0 deletions
......@@ -2,6 +2,14 @@ import pygame
from pygame import locals
import random
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self.image=random.choice([image1,image2,image3])
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -22,6 +30,7 @@ index = 0
y = 400
t = 30
jumpState = "runing"
obstacle = random.choice([bush,stone,cacti])
rect = opstacle.get_rect()
rect.x = 1000
......@@ -30,6 +39,7 @@ rect.y = 500 - rect.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
......@@ -56,11 +66,13 @@ while True:
screen.blit(background, (0, 0))
road_
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y))
if rect.x <= 0-rect.width:
obstacle = random.choice([bush,stone,cacti])
rect = opstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment