0
コード
#Importing files/modules
import pygame
import random
#Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
ORANGe = (255, 115, 0)
YELLOW = (242, 255, 0)
BROWN = (115, 87, 39)
PURPLE = (298, 0, 246)
GRAY = (168, 168, 168)
BLUE = (0, 0, 255)
GROUND = (156,168,91)
pygame.init()
#Screen
screenx = 1000
screeny = 700
screentotal = [screenx,screeny]
screen = pygame.display.set_mode(screentotal)
#Caption
pygame.display.set_caption("Animation attempt one")
#Variables
x = 500
y = 1000
a = 0
b = 500
c = 1500
d = 1000
#Booleans
go = True
#Graphics
one = pygame.image.load("uno.jpg").convert()
two = pygame.image.load("dos.jpg").convert()
three = pygame.image.load("tres.jpg").convert()
#Position
position = [0,0]
#Time management
clock = pygame.time.Clock()
FPS = 60
animation_timer = pygame.time.Clock()
animation_time = 0
screen.fill(GREEN)
#MAIN LOOP _________________________________________________________
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if go:
animation_timer.tick()
animation_time += animation_timer.get_time()
if animation_time < x and animation_time > a:
screen.blit(one,position)
x += 1000
a += 1000
if animation_time < y and animation_time> b:
screen.blit(two,position)
y += 1000
b += 1000
if animation_time < c and animation_time > d:
screen.blit(three,position)
c += 1000
d += 1000
#Flip the display
pygame.display.flip()
clock.tick(FPS)
#Quit
pygame.quit()
を存続問題
は私のコードは、アニメーションで3枚の画像を描画し、インクリメンタルそれアニメーションのループにするABCDを追加することになっています。 if文の2つの最初のイメージでそれを行うだけでうまくいきます。しかし、3番目のif imageステートメントを追加すると、3秒ごとに3枚の画像が表示されてアニメーションが表示されますが、初めてアニメーションすると3枚目の画像はポップアップせず、最初の2枚の画像のみが動作します。私はタイミングと変数を変更しようとしましたが、動作しません。アニメーションの問題
はあなたが提供することができます任意の助けをありがとう:)
私はこれがアニメーション化しようとしているのは非常に複雑な方法である知っているが、それは私が一番好きな方法です。ありがとう
正確に何が起こりたいのか分かりません。これはアニメーションのことについては非常に混乱する方法です。 –
私は3つの画像を半分ごとにblitするが、前の画像は消えてループが再開すると表示される。私の3番目の画像が一度表示されてから問題が起きてから戻ってくることはありません。私はこのようにアニメーションを作るのが好きです。私は他の方法があることを知っています。 – abc1234