Commit 44272c16 by BellCodeEditor

save project

parent 0ee2e1a8
Showing with 17 additions and 1 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random
x=150 x=150
y=400 y=400
...@@ -20,6 +21,10 @@ apple = pygame.image.load('bush.png') # 灌木丛 ...@@ -20,6 +21,10 @@ apple = pygame.image.load('bush.png') # 灌木丛
Hero = [pygame.image.load('hero1.png'), pygame.image.load('hero2.png'),pygame.image.load('hero3.png'),pygame.image.load('hero4.png') Hero = [pygame.image.load('hero1.png'), pygame.image.load('hero2.png'),pygame.image.load('hero3.png'),pygame.image.load('hero4.png')
,pygame.image.load('hero5.png')] ,pygame.image.load('hero5.png')]
obstacle=random.choice([stone,cacti,apple])
rect=cacti.get_rect()
rect.x=1000
rect.y=500-rect.height
index = 0 index = 0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -55,11 +60,22 @@ while True: ...@@ -55,11 +60,22 @@ while True:
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(guku, (x, y)) screen.blit(guku, (x, y))
if rect.x < 0 -rect.width:
obstacle=random.choice([stone,cacti,apple])
rect=cacti.get_rect()
rect.x=1000
rect.y=500-rect.height
rect.x-=5
screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
RECT=
......
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