import pygame
from pygame.locals import*import sys
import math
pygame.init()
width, height =800,600
screen = pygame.display.set_mode((width, height))
c=pygame.time.Clock()
q =[[1,1,1,1,1,1,1,1],[1,0,0,0,0,0,0,1],[1,0,0,0,0,0,0,1],[1,0,0,0,0,0,0,1],[1,0,0,0,0,0,0,1],[1,0,0,0,0,0,0,1],[1,0,0,0,0,0,0,1],[1,1,1,1,1,1,1,1]]
ci=0
x=0
y=0
erpaix=0
erpaiy=0
# def qiang(ci):
# global x
# global y
# global erpaix
# global erpaiy
# for i in range(len(q)):
# if(q[i]==1 and i<4):
# #print(ci,i)
# ci = ci +60
# pygame.draw.rect(screen,(140,140,140),(x + ci, y,60,60),width=6)
# if(q[i]==1 and i==4):
# erpaiy=y+60#如果y=y+60就会所有墙块一起移动
# erpaix=60
# pygame.draw.rect(screen,(140,40,1),(erpaix , erpaiy,60,60),width=1)
while True:
screen.fill((255,255,255))
c.tick(7)for event in pygame.event.get():if event.type== QUIT:
pygame.quit()
sys.exit()
keys = pygame.key.get_pressed()if keys[pygame.K_UP]:
f = True
if event.type== pygame.KEYUP:
f = False
#qiang(ci)for h in range(len(q)):print(q[h],"行",h)for g in range(len(q[h])):if q[h][g]==1:print(q[h][g],"个",g,h)
pygame.draw.rect(screen,(140,240,40),(h*60, g*60,60,60))
# for i in range(len(q)):
# ci=ci+1
# pygame.draw.rect(screen,(40,40,40),(0+ci,0,60,60))在这直接写会变成子弹,写成函数qiang(ci)就能画成一次,不会移动的墙
pygame.display.flip()