I'm making a little game, but ask you could guess, i have a problem :p
My first class (it gets originalscreen from the first part of the game)
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()
As you can read, I import makemap and pass the screen to it
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
But then my problem occurs: my background stays black (0), so the mapmaker-function doesn't pass the screen back to my first file of code.
How can i edit the screen (like i do in mapmaker) and then display it?
I hope someone can help me Lukas
ps: if you have any questions, please ask. And sorry for my English, I'm dutch...