I'm in the middle of creating a platformer game similar to Mario, I have a level ready and sprites that decorate the level. Right now I am just trying to display the level as grey tiles in my game window with the draw method:
self.terrain_sprites.draw(self.display_surface)
but it isn't working, it's just displaying a black screen. Does anyone know the solution to fix this? Any help will be appreciated.
import pygame
from support import import_csv_layout
from settings import tile_size
from tiles import Tile
# setup for the level
class Level:
def __init__(self,level_data,surface):
self.display_surface = surface
terrain_layout = import_csv_layout(level_data['terrain'])
self.terrain_sprites = self.create_tile_group(terrain_layout,'terrain') # to let python know that we need the terrain files
def create_tile_group(self,layout,type):
sprite_group = pygame.sprite.Group()
for row_index, row in enumerate(layout):
for col_index,val in enumerate(row):
if val != '-1':
x = col_index * tile_size
y = row_index * tile_size
if type == 'terrain':
sprite = Tile(tile_size,x,y)
sprite_group.add(sprite)
return sprite_group
def run(self):
# runs the entire game / level
self.terrain_sprites.draw(self.display_surface)