嘿伙计们,所以我对编码很陌生,我们明天就需要这个我已经很想今天得到答案所以呃这里是我们的代码我希望这可以快速解决。我真的不知道如何改变它,但我相信将改变的代码只在这部分。
def main():
global cameraX, cameraY
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode(DISPLAY, FLAGS, DEPTH)
pygame.display.set_caption("JCLT Game")
Timer = pygame.time.Clock()
pygame.display.set_mode(size, FULLSCREEN)
bg = Surface((32, 32))
up = down = left = right = runnning = False
bg = Surface((WIN_WIDTH,WIN_HEIGHT)).convert_alpha()
bg.fill(Color("skyblue"))
screen.blit(bg, [0,0])
entities = pygame.sprite.Group()
player = Player(16*3,16*3)
platforms = []
# build the level
for row in level:
for col in row:
if col == "P":
p = Platform(x, y)
platforms.append(p)
entities.add(p)
if col == "E":
e = ExitBlock(x, y)
platforms.append(e)
entities.add(e)
if col == "R":
r = Rgspikes(x, y)
platforms.append(r)
entities.add(r)
if col == "L":
l = Lgspikes(x, y)
platforms.append(l)
entities.add(l)
if col == "U":
u = Upleftspikes(x, y)
platforms.append(u)
entities.add(u)
if col == "I":
i = Uprightspikes(x, y)
platforms.append(i)
entities.add(i)
if col == "D":
d = Downallaroundspikes(x, y)
platforms.append(d)
entities.add(d)
if col == "T":
t = Leftspikes(x, y)
platforms.append(t)
entities.add(t)
if col == "Z":
z = Rightspikes(x, y)
platforms.append(z)
entities.add(z)
if col == "G":
g = Groundspikes(x, y)
platforms.append(p)
entities.add(p)
if col == "S":
s = SpecialBlock(x, y)
platforms.append(s)
entities.add(s)
if col == "J":
j = Downaroundspikesl(x, y)
platforms.append(j)
entities.add(j)
if col == "K":
k = Downaroundspikesr(x, y)
platforms.append(k)
entities.add(k)
if col == "M":
m = Allaroundspikes(x, y)
platforms.append(m)
entities.add(m)
if col == "N":
n = Downspikes(x, y)
platforms.append(n)
entities.add(n)
x += 16*3
y += 16*3
x = 0
total_level_width = len(level[0])*32*3
total_level_height = len(level)*32*3
camera = Camera(complex_camera, total_level_width, total_level_height)
entities.add(player)
while 1:
Timer.tick(60)
for e in pygame.event.get():
if e.type == KEYDOWN and e.key == K_ESCAPE:
pygame.quit()
sys.exit()
if e.type == KEYDOWN and e.key == K_UP:
up = True
if e.type == KEYDOWN and e.key == K_LEFT:
left = True
if e.type == KEYDOWN and e.key == K_RIGHT:
right = True
if e.type == KEYUP and e.key == K_UP:
up = False
if e.type == KEYUP and e.key == K_DOWN:
down = False
if e.type == KEYUP and e.key == K_RIGHT:
right = False
if e.type == KEYUP and e.key == K_LEFT:
left = False
if e.type == KEYDOWN and e.key == K_w:
up = True
if e.type == KEYDOWN and e.key == K_s:
down = True
if e.type == KEYDOWN and e.key == K_a:
left = True
if e.type == KEYDOWN and e.key == K_d:
right = True
if e.type == KEYUP and e.key == K_w:
up = False
if e.type == KEYUP and e.key == K_s:
down = False
if e.type == KEYUP and e.key == K_d:
right = False
if e.type == KEYUP and e.key == K_a:
left = False
screen.blit(bg,(0,0))
答案 0 :(得分:1)
up = down = left = right = runnning = False
将其转为
up = down = left = False
right = running = True