Commit f10121ba by BellCodeEditor

save project

parent 3acbaf8c
Showing with 10 additions and 2 deletions
import pygame
from pygame import locals
import random
import sprite
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -18,6 +18,12 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
class Player(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image=image
self.rect=self.image.get_rect()
index = 0
y = 400
jumpState = "runing"
......@@ -63,7 +69,7 @@ while True:
# 将背景图画上去
screen.blit(background, (0, 0)) # 远处背景
screen.blit(road, (changex, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
screen.blit(wukong.image, (150, y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失
# 创建障碍物对象
obstacle = random.choice([bush,stone,cacti])
......@@ -75,3 +81,4 @@ while True:
# 刷新画面
pygame.display.update()
FPS.tick(30)
pygame.sprite.collide_rect()
\ No newline at end of file
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