2
我試圖讓物體像地球一樣墜落。我已經讓他們知道我想要他們的位置,但我似乎無法制作他們的動畫。Pygame:我如何讓我的形象下降?
這是我欲墜
import pygame
class circle():
def __init__(self, screen):
planet_color = (255,0,0)
planet_radius = 20
self.screen = screen
ev = pygame.event.get()
self.image = pygame.image.load('../images/jupiter.bmp')
self.image = pygame.transform.scale(self.image, (80, 80))
def blitme(self):
self.x = pygame.mouse.get_pos()
self.rect = self.image.get_rect()
self.rect.center = self.x
self.screen.blit(self.image, self.rect)
對象,這是運行它的代碼。當鼠標被點擊時,木星的一張小圖片被點擊鼠標。我如何獲得這張圖片?
import pygame
import gravfunc as gf
from gravfunc import circle
import sys
def run_game():
screen_height = 670
screen_width = 1270
pygame.init()
screen = pygame.display.set_mode((screen_width, screen_height))
screen.fill((10,10,30))
running = True
circ = circle(screen)
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN:
circ.blitme()
pygame.display.flip()
run_game()
這裏的一個[pygame的子畫面子畫面和組教程(http://programarcadegames.com/index.php?chapter=introduction_to_sprites&lang=en#section_13)。 – skrx