Commit a660560e by BellCodeEditor

save project

parent 2742489a
Showing with 13 additions and 9 deletions
...@@ -2,13 +2,13 @@ import pygame ...@@ -2,13 +2,13 @@ import pygame
from pygame import locals from pygame import locals
import random import random
class Block(pygame.sprite.Sprite): class Block(pygame.sprite.sprite):
def __init__(self,image1,image2,image3): def _init_(self,imag1,imag2,imag3):
super().__init__() super()._init_()
self.image=random.choice([image1,image2,image3]) self.image = random.choice([image1,image2,image3,])
self.rect=self.image.get_rect() self.rect = self.image.get_rect()
self.rect.x=1000 self.rect.x = 1000
self.rect.y=500-self.rect.height self.rect.y = 500 - self.rect.height
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
...@@ -78,8 +78,12 @@ while True: ...@@ -78,8 +78,12 @@ while True:
# 创建障碍物对象 # 创建障碍物对象
aa=Block(bush,cacti,stone) aa=Block(bush,cacti,stone)
aa.rect.x -= 8 aa.rect.x -= 8
obstacle = Block(bush,cacti,stone)
block_list.add(obstacle)
for sprite in block_list:
sprite.rect.x -= 8
screen.blit(sprite.image,(sprite,rect.x, sprite.rect.y))
screen.blit(aa.image, (aa.rect.x, aa.rect.y)) screen.blit(aa.image, (aa.rect.x, aa.rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
......
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