Я хочу сделать прямоугольники из правого края
Как я могу заставить эти прямоугольники двигаться горизонтально?Я пытался понять это из этого урока, но я не смог здесь , поэтому любые идеи об этом моем маленьком призраке персонажа btata.png
import pygame
from pygame.locals import *
import sys
import time
import random
pygame.init()
display_width = 800
display_height = 600
gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('FullMarx')
black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
crashed = False
ghostImg = pygame.image.load('btata.png')
clock = pygame.time.Clock()
def ghost(x,y):
gameDisplay.blit(ghostImg, (x,y))
def things(thingx, thingy, thingw, thingh, color):
pygame.draw.rect(gameDisplay, color, [thingx, thingy, thingw, thingh])
def text_objects(text, font):
textSurface = font.render(text, True, black)
return textSurface, textSurface.get_rect()
def message_display(text):
largeText = pygame.font.Font('freesansbold.ttf',20)
TextSurf, TextRect = text_objects(text, largeText)
TextRect.center = ((display_width/2),(display_height/2))
gameDisplay.blit(TextSurf, TextRect)
def gameOver():
message_display('Game Over')
def rect():
pygame.draw.rect(screen, color, (x,y,width,height), thickness)
def event():
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
pygame.quit()
sys.exit()
def game():
ghost_width = 50
x = 20
y = 180
isJump = False
jumpCount = 9
#x_change = 0
thing_startx = random.randrange(0, display_width)
thing_starty = -300
thing_speed = 7
thing_width = 30
thing_height = 30
while True:
event()
gameDisplay.fill(white)
ghost(x,y)
#____Ghost_Motion___________#
keys = pygame.key.get_pressed()
if not(isJump):
if keys[pygame.K_UP] or keys[pygame.K_SPACE] or keys[pygame.K_w]:
isJump = True
walkCount = 0
else:
if jumpCount >= -9:
neg = 1
if jumpCount < 0:
neg = -1
y -= (jumpCount ** 2) * 0.5 * neg
jumpCount -= 1
else:
isJump = False
jumpCount = 9
clock.tick(50)
#____Ghost_Motion___________#
# things(thingx, thingy, thingw, thingh, color)
things(thing_startx, thing_starty, thing_width, thing_height, black)
thing_starty += thing_speed
ghost(x,y)
if thing_starty > display_height:
thing_starty = 0 - thing_height
thing_startx = random.randrange(0,display_width)
if y < thing_starty+thing_height:
print('y crossover')
if x > thing_startx and x < thing_startx + thing_width or x+ghost_width > thing_startx and x + ghost_width < thing_startx+thing_width:
print('x crossover')
gameOver()
pygame.display.update()
#clock.tick(60)
game()
pygame.quit()
quit()