我正在尝试制作动画片#34;对于我的游戏开始,但随着我的代码的继续,它开始对我所做的改变没有反应。例如,即使我使ML = 99999999而不是在ML = 1时重新开始,它仍将重置动画。这对我来说毫无意义。请提前帮助和谢谢。
elif V == 4:
if event.type == event_250ms:
if ML == 1:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN1, (40, 140))
B(LLCS1, (400, 240))
ML = 2
elif ML == 2:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN2, (41, 140))
B(LLCS2, (399, 240))
ML = 3
elif ML == 3:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN3, (42, 140))
B(LLCS3, (398, 240))
ML = 4
elif ML == 4:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN4, (43, 140))
B(LLCS4, (397, 240))
ML = 5
elif ML == 5:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN5, (44, 140))
B(LLCS5, (396, 240))
ML = 6
elif ML == 6:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN6, (45, 140))
B(LLCS6, (395, 240))
ML = 7
elif ML == 7:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN7, (46, 140))
B(LLCS7, (394, 240))
ML = 1
elif ML == 8:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN8, (47, 140))
B(LLCS8, (393, 240))
ML = 9
elif ML == 9:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN9, (48, 140))
B(LLCS9, (392, 240))
ML = 10
elif ML == 10:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN10, (49, 140))
B(LLCS10, (391, 240))
ML = 11
elif ML == 11:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN11, (50, 140))
B(LLCS11, (390, 240))
ML = 12
elif ML == 12:
D.fill(MEXON)
x_coord = 0
y_coord = 0
direction = 'up'
B(LLCN12, (51, 140))
B(LLCS12, (389, 240))
ML = 1
这是相关动画的代码。接下来是我声明所有语句的部分。
import pygame, sys, random
from pygame.locals import *
pygame.init()
BLACK = ( 0, 0, 0)
PINDLER = (255, 123, 90)
MEXON = (200, 180, 220)
WHITE = (255, 255, 255)
YELLOW = (255, 255, 0)
RED = (255, 0, 0)
BLUE = ( 0, 0, 255)
size = [700, 500]
D = pygame.display.set_mode(size)
L = pygame.draw.aaline
R = pygame.draw.rect
G = random.randrange(1, 10)
GM = 1
GMT = 2
CIP = 1
SH = 0
AAC = 2
CHBP = 0
STHB = 1
CC = 0
CM = 1
PL = pygame.draw.line
PE = pygame.draw.ellipse
GMFT = 0
HTT = 0
CO = 2
V = 5
ML = 1
PFO = 0
CL = 0
Blue = 1
Red = 1
LEVEL = 1
event_250ms = pygame.USEREVENT + 1
pygame.time.set_timer(event_250ms, 250)
pygame.display.set_caption("Moline")
myfont1 = pygame.font.SysFont("monospace", 40)
myfont2 = pygame.font.SysFont("monospace", 60)
myfont3 = pygame.font.SysFont("monospace", 20)
myfont4 = pygame.font.SysFont("monospace", 100)
T1 = myfont1.render
T2 = myfont2.render
T3 = myfont3.render
T4 = myfont4.render
MOL = "MOLINE"
M1S = "DIRECTIONS:"
M2S = "1. Use the arrow keys to control the four characters"
M2F = " off of the track to move them."
M3S = "2. To win a level, line up the four characters on"
M3F = " the crossmark before the runner on the track"
M3C = " reaches the finish line."
M4S = "3. If the runner reaches the finish line, then"
M4F = " you lose."
M5S = "4. When you lose you go back to level one. There"
M5F = " are eight levels."
M6S = "5. Key input makes the runner move slightly"
M6F = " faster, but he will move without input."
M6C = " Additionally, mouse movement makes him even faster."
M7S = "6. It should be noted that whenever you click to"
M7F = " start, the game will immediately begin so have"
M7C = " your arrow keys ready to go."
ISC = "Left-Click to Start Game"
LEST = "Level: "
LU1 = "1"
LU2 = "2"
LU3 = "3"
LU4 = "4"
LU5 = "5"
LU6 = "6"
LU7 = "7"
LU8 = "8"
VTC2 = "Left-Click To Begin Next Level"
VTC3 = "Left-Click To Start Over"
VTC1 = "Left-Click to Start Over"
VT3 = "YOU WIN!!!"
VT2 = "LEVEL COMPLETE"
VT1 = "GAME OVER"
LCN = "Titancorp"
LCS = "Studios"
LCP = "Presents"
LLCS1 = T2(LCS, 1, (200, 180, 220))
LLCS2 = T2(LCS, 1, (205, 187, 200))
LLCS3 = T2(LCS, 1, (210, 194, 180))
LLCS4 = T2(LCS, 1, (215, 201, 160))
LLCS5 = T2(LCS, 1, (220, 208, 140))
LLCS6 = T2(LCS, 1, (225, 215, 120))
LLCS7 = T2(LCS, 1, (230, 222, 100))
LLCS8 = T2(LCS, 1, (235, 229, 80))
LLCS9 = T2(LCS, 1, (240, 236, 60))
LLCS10 = T2(LCS, 1, (245, 243, 40))
LLCS11 = T2(LCS, 1, (250, 250, 20))
LLCS12 = T2(LCS, 1, (255, 255, 0))
LLCN1 = T2(LCN, 1, (200, 180, 220))
LLCN2 = T2(LCN, 1, (205, 187, 200))
LLCN3 = T2(LCN, 1, (210, 194, 180))
LLCN4 = T2(LCN, 1, (215, 201, 160))
LLCN5 = T2(LCN, 1, (220, 208, 140))
LLCN6 = T2(LCN, 1, (225, 215, 120))
LLCN7 = T2(LCN, 1, (230, 222, 100))
LLCN8 = T2(LCN, 1, (235, 229, 80))
LLCN9 = T2(LCN, 1, (240, 236, 60))
LLCN10 = T2(LCN, 1, (245, 243, 40))
LLCN11 = T2(LCN, 1, (250, 250, 20))
LLCN12 = T2(LCN, 1, (255, 255, 0))
#MOLINE TEXT GOES AT (170, 70)
LLCN10000 = T4(MOL, 1, (255, 255, 0))
LLCN2000 = T4(MOL, 1, (235, 235, 50))
LLCN30000 = T4(MOL, 1, (225, 220, 100))
LLCN4000 = T4(MOL, 1, (215, 205, 200))
LLCN50000 = T4(MOL, 1, (200, 180, 220))
L1 = T3(M1S, 1, (255, 255, 0))
L2 = T3(M2S, 1, (255, 255, 0))
L2C = T3(M2F, 1, (255, 255, 0))
L3 = T3(M3S, 1, (255, 255, 0))
L3C = T3(M3F, 1, (255, 255, 0))
L3F = T3(M3C, 1, (255, 255, 0))
L4 = T3(M4S, 1, (255, 255, 0))
L4C = T3(M4F, 1, (255, 255, 0))
L5 = T3(M5S, 1, (255, 255, 0))
L5C = T3 (M5F, 1, (255, 255, 0))
L6 = T3(M6S, 1, (255, 255, 0))
L6C = T3(M6F, 1, (255, 255, 0))
L6F = T3(M6C, 1, (255, 255, 0))
L7 = T3(M7S, 1, (255, 255, 0))
L7C = T3(M7F, 1, (255, 255, 0))
L7F = T3(M7C, 1, (255, 255, 0))
SFGL = T1(ISC, 1, (255, 255, 0))
LES = T3(LEST, 1, (255, 255, 0))
LAS1 = T3(LU1, 1, (255, 255, 0))
LAS2 = T3(LU2, 1, (255, 255, 0))
LAS3 = T3(LU3, 1, (255, 255, 0))
LAS4 = T3(LU4, 1, (255, 255, 0))
LAS5 = T3(LU5, 1, (255, 255, 0))
LAS6 = T3(LU6, 1, (255, 255, 0))
LAS7 = T3(LU7, 1, (255, 255, 0))
LAS8 = T3(LU8, 1, (255, 255, 0))
V3CB = T3(VTC3, 1, (255, 255, 0))
V3CY = T3(VTC3, 1, ( 0, 0, 255))
V2CB = T3(VTC2, 1, (255, 255, 0))
V2CY = T3(VTC2, 1, ( 0, 0, 255))
V1CB = T3(VTC1, 1, ( 0, 0, 0))
V1CR = T3(VTC1, 1, (255, 0, 0))
V3B = T2(VT3, 1, (255, 255, 0))
V3Y = T2(VT3, 1, ( 0, 0, 0))
V2B = T2(VT2, 1, (255, 255, 0))
V2Y = T2(VT2, 1, ( 0, 0, 255))
V1R = T2(VT1, 1, ( 0, 0, 0))
V1B = T2(VT1, 1, (255, 0, 0))
B = D.blit
Fx = 10
Fy = 10
答案 0 :(得分:1)
您是否在问为什么正在运行的程序无法反映您在开始运行后所做的更改?它不会那样工作,Python在编译时加载整个脚本。之后它永远不会寻找变化。
答案 1 :(得分:-1)
我发现了我的问题。我在代码中输了一个错误,其中ML = 1而不是前进到ML = 8.此外,我意识到我的问题相当含糊,所以我为此道歉。