2012-01-07 5 views
1

내가하고 싶은 것은 (brick_tile)이라는 타일 이미지로 덮여있는 (0,390), (0,450), (610,390), (610,450)입니다. 지금까지 내가 가진 모든이있다 : 루프에서 방금 블럭 전송해야 벽돌 타일, 블릿, 블럭 전송으로어떻게 파이썬/파이 게임에서 타일 (이미지) 영역을 커버합니까?

import pygame 
from pygame.locals import* 

cloud_background = pygame.image.load('clouds.bmp') 
brick_tile = pygame.image.load('brick_tile.png') 

pink = (255, 64, 64) 
w = 640 
h = 480 
screen = pygame.display.set_mode((w, h)) 
running = 1 

while running: 
    screen.fill((pink)) 
    screen.blit(cloud_background,(0,0)) 
    screen.blit(brick_tile,(0,450)) 
    pygame.display.flip() 

    event = pygame.event.poll() 
    if event.type == pygame.QUIT: sys.exit() 

답변

2

: 내가 추가

import pygame 
import sys 
import itertools 

cloud_background = pygame.image.load('clouds.bmp') 
brick_tile = pygame.image.load('brick_tile.png') 

pink = (255, 64, 64) 
w = 640 
h = 480 
screen = pygame.display.set_mode((w, h)) 
running = 1 

def setup_background(): 
    screen.fill((pink)) 
    screen.blit(cloud_background,(0,0)) 
    brick_width, brick_height = brick_tile.get_width(), brick_tile.get_height() 
    for x,y in itertools.product(range(0,610+1,brick_width), 
           range(390,450+1,brick_height)): 
     # print(x,y) 
     screen.blit(brick_tile, (x, y)) 
    pygame.display.flip() 

while running: 
    setup_background()  
    event = pygame.event.poll() 
    if event.type == pygame.QUIT: sys.exit() 
+0

확인이 프로그램의 끝. 그리고 벽돌은 초기화되지 않는다. – enrique2334

+0

'setup_background()'함수를 호출해야한다. 내가 의미하는 바를 보여주기 위해 코드를 편집했습니다. – unutbu

+0

'역 추적 (가장 최근 통화 최종) : 파일 : setup_background에서 "C \ 사용자 엔리케 \ 드롭 박스 \ GAMEZ_PYGAME \의 gamez.py을 \", 라인 (14),() 나가서 설명하자면 NameError : 이름 'setup_background은' – enrique2334

관련 문제