Commit 8e2804a0 by BellCodeEditor

save project

parent ee59b50b
Showing with 24 additions and 1 deletions
import
\ No newline at end of file
import pygame
cacti = pygame.image.load('cacti.png')
rect = cacti.get_rect()
print(rect)
print(rect.x)
print(rect.y)
print(rect.width)
print(rect.height)
\ No newline at end of file
import pygame import pygame
import random
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
...@@ -21,7 +22,10 @@ wukong_number = 0 ...@@ -21,7 +22,10 @@ wukong_number = 0
sss = "running" sss = "running"
t = 30 t = 30
y = 400 y = 400
si = random.choice([apple,cacti,stone])
rect = si.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -55,5 +59,12 @@ while True: ...@@ -55,5 +59,12 @@ while True:
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
# 刷新画面 # 刷新画面
rect.x -= 8
screen.blit(si,(rect.x,rect.y))
if rect.x < 0-rect.width:
si = random.choice([apple,cacti,stone])
rect = si.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
pygame.display.update() pygame.display.update()
FPS.tick(30) FPS.tick(30)
\ 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