私は小さなゲームを作っていますが、推測できるようにお願いします.私には問題があります:p
私の最初のクラス (ゲームの最初の部分から元の画面を取得します)
import pygame
from pygame.locals import *
import pygbutton
class part():
def __init__(self,originalscreen):
self.screen = originalscreen
self.part()
def part(self):
""" Finally: the game!"""
# But first, some variables and imports
parton = True
import makemap
# Looping
while parton:
# The screen
self.screen.fill(0)
makemap.mapmaker(self.screen)
# Events
for event in pygame.event.get():
if event.type == QUIT:
exit()
# Updating the screen
pygame.display.flip()
ご覧のとおり、makemapをインポートして画面を渡します
import pygame
from pygame.locals import *
""" Add tiles here"""
grass = pygame.image.load("tiles/grass.png")
def mapmaker(screen):
height = screen.get_height()
width = screen.get_width()
# Set the size of each tile (25 pixels)
xscale = width / 40
yscale = height / 24
# Loading file
mapfile = open("part1map.txt", "r")
# Making the map
xco = 0
yco = 0
lines = mapfile.readlines()
for line in lines:
for typeoftile in range(0, len(line)):
if str(typeoftile) == "g":
screen.blit(grass, (xco*xscale, yco*yscale))
xco = xco + 1
yco = yco + 1
しかし、その後、問題が発生します。背景が黒 (0) のままであるため、mapmaker-function は画面を最初のコード ファイルに戻しません。
画面を編集して (マップメーカーで行うように)、表示するにはどうすればよいですか?
誰かが私を助けてくれることを願っています ルーカス
ps: ご不明な点がございましたら、お問い合わせください。そして私の英語でごめんなさい、私はオランダ人です...