top of page

소스 코드 제출

공개·회원 52명

3573747


import pygame
pygame.init()
white = (255, 255, 255)
black = (0, 0, 0)
address = 'C:/Python/Pygame/20240202/haha/'
image_p = address + "b_bshop.png"
image_a = address +"b_n.png"
image_t = address +"b_p.png"
image_h = address +"b_rok.png"
image_pa = address +"black_king.png"
image_pat = address +"black_qin.py.png"
image_path = address +"w_b.png"
image_pp = address +"w_k.png"
image_aa = address +"w_n.png"
image_tt = address +"w_p.png"
image_hh = address +"w_q.png"
image_qaa = address +"w_r.png"
width, height = 1024, 1024
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Chessboard")
clock = pygame.time.Clock()

ic,jc=8,8
size=width//jc
image = pygame.image.load(image_p)
imag = pygame.image.load(image_a)
ima = pygame.image.load(image_t)
im = pygame.image.load(image_h)
iage = pygame.image.load(image_pa)
imge = pygame.image.load(image_pat)
ige = pygame.image.load(image_path)
ime = pygame.image.load(image_pp)
iga = pygame.image.load(image_aa)
imja = pygame.image.load(image_tt)
ge = pygame.image.load(image_hh)
mage = pygame.image.load(image_qaa)
player_pos = pygame.Vector2(screen.get_width() / 2, screen.get_height() / 2)
def draw(): # 체스판그리는 함수    for i in range(ic): # 가로 8개만큼 반복
        for j in range(jc): # 세로 8개만큼 반복
            x = j * size   # j행 흰색사각형 위치
            y = i * size   # i열 흰색사각형 위치
        if (i + j) % 2 == 0: # i열 +j행이 0부터해서 짝수면 그칸을 흰색으로
            color = white
        else:#아니면 검은색
            color = black

        pygame.draw.rect(screen, color, (x, y,size, size))#(가로위치,세로위치 ,세로길이,가로길이)
running = Truewhile
running
for event in pygame.event.get():
    if event.type == pygame.QUIT:
        running = False
draw()
pygame.display.flip()
clock.tick(60)
pygame.quit()

4회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page