我在这里有这个代码,在开始菜单中我想要一些图像从天而降,但它不起作用。我尝试了很多东西,但都没有奏效。
这是代码:
import pygame
import random
pygame.init()
display_width= 1000
display_height= 600
black = (0,0,0)
white = (255, 255, 255)
blue = (0, 0, 112)
x=0
y=0
gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption("Name")
clock = pygame.time.Clock()
def text_objects(text, font, color):
textSurface = font.render(text, True, color)
return textSurface, textSurface.get_rect()
Stmenpic = pygame.image.load("Start_menu_sky_back_ground.png")
def StartMenPic(x,y):
gameDisplay.blit(Stmenpic, (x,y) )
def Title_Of_Game(text):
Title_Text = pygame.font.Font("ARDESTINE.ttf", 115)
TextSurf, TextRect = text_objects(text, Title_Text, blue)
TextRect.center = ((500),(100))
gameDisplay.blit(TextSurf, TextRect)
pygame.display.update
Baby_1=pygame.image.load("Baby_1.png")
def things(x,y):
gameDisplay.blit(Baby_1,(x, y ))
x_change = 0
def Title_of_Game():
Title_Of_Game("Title")
def Start_Menu():
StartMenu=True
while StartMenu:
x = 0
y = 0
x_change = 0
thing_startx = random.randrange(0, display_width)
thing_starty = -600
thing_speed = 7
thing_width= 30
thing_height=30
for event in pygame.event.get():
#print(event)
if event.type == pygame.QUIT:
pygame.quit()
quit()
Title_of_Game()
x_change=0
x+= x_change
if thing_starty > display_height:
thing_starty = 0 - thing_height
thing_startx = random.randrange(0, display_width)
pygame.display.update()
clock.tick(60)
StartMenPic(0, 0)
Start_Menu()
pygame.quit()
quit()
这可能很明显,但我才刚刚开始,所以我需要很多帮助。感谢您对这个问题的所有帮助。现在我遇到了块的问题,它总是在随机位置生成但不会下降。
手掌心
相关分类