Commit 74e5cb93 by BellCodeEditor

auto save

parent 15d4ae5b
Showing with 23 additions and 1 deletions
import pygame import pygame
import random
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
...@@ -18,6 +19,11 @@ index=0 ...@@ -18,6 +19,11 @@ index=0
jumpState="runing" jumpState="runing"
y=400 y=400
t=30 t=30
zhangai_x=1000
zhangai_y=50
zhangai=[stone,cacti,apple]
zhang=random.choice(zhangai)
zhangrect=zhang.get_rect()
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:
...@@ -50,11 +56,26 @@ while True: ...@@ -50,11 +56,26 @@ while True:
zhen+=1 zhen+=1
if zhen==5: if zhen==5:
zhen=0 zhen=0
wx=hero.get_rect().x
wy=hero.get_rect().y
zx=zhang.get_rect().x
zy=zhang.get_rect().y
ww=hero.get_rect().width
wh=hero.get_rect().height
zw=zhang.get_rect().width
zh=zhang.get_rect().height
print(wx,wy,ww,wh,zx,zy,zw,zh)
if zhangai_x<0-zhangrect.width:
zhang=random.choice(zhangai)
zhangai_x=1000
zhangai_x-=10
if zx+zw<wx and zx>wx+ww and zy>wy+wh and zy+zh<wy:
print(wx,wy,ww,wh,zx,zy,zw,zh)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(hero, (150, y)) screen.blit(hero, (150, y))
screen.blit(zhang,(zhangai_x,500-zhangrect.height))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ 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