Commit db465cd8 by BellCodeEditor

save project

parent a68d356f
File added
bg.png

200 KB

bush.png

14.5 KB

cacti.png

5.58 KB

hero1.png

627 Bytes

hero2.png

907 Bytes

hero3.png

926 Bytes

hero4.png

856 Bytes

hero5.png

939 Bytes

import pygame
from pygame import locals
import random
pygame.init()
screen = pygame.display.set_mode((1000,600))
pygame.display.set_caption('额我的回答i2额u好的好的2欸偶还得u 华为陌好欸一一 iueh23 好3iuh3 iuh3iu3 虎 还 一和i汇入瑞额u海域 23 3让 io23晕ueji')
FPS = pygame.time.Clock()
background = pygame.image.load('bg.png')
road = pygame.image.load('road.png')
stone = pygame.image.load('stone.png')
cacti = pygame.image.load('cacti.png')
apple = pygame.image.load('bush.png')
hero = [pygame.image.load('hero5.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero2.png'),
pygame.image.load('hero1.png')]
i = 0
y = 400
jumpState = 'running'
t = 15
obstacle = random.choice([apple,stone,cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_SPACE and jumpState == 'running':
jumpState = 'up'
if jumpState == 'up':
if t > 0:
y -= t
t -= 0.5
else:
jumpState = 'down'
if jumpState == 'down':
if t <= 15:
y += t
t += 0.5
else:
jumpState = 'running'
t = 15
screen.blit(background,(0,0))
screen.blit(road,(0,500))
screen.blit(hero[i%5],(150,y))
if jumpState == 'running':
i += 1
screen.blit(obstacle,(rect.x,rect.y))
rect.x -= 5
if rect.x < -rect.width:
obstacle = random.choice([apple,stone,cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
road.png

34.7 KB

{"第1名": 0, "第2名": 0, "第3名": 0}
\ No newline at end of file
stone.png

11.3 KB

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