This is the error File "e:Pygamemain.py", line 23, in new self.createTilemap() AttributeError: 'Game' object has no attribute 'createTilemap'
I created a Tilemap on a separate code named config and following a tutorial from 3 years ago I wrote down this code;
`import pygame
from sprites import *
from config import *
import sys
class Game:
def init(self):
pygame.init()
self.screen = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))
self.clock = pygame.time.Clock()
self.running = True
def createTilemap(self):
for i, row in enumerate(tilemap):
for j, column in enumerate(row):
if column == "B":
Block(self, j, i)
if column == "P":
Player(self, j, i)
def new(self):
self.createTilemap()
# a new game starts
self.playing = True
self.all_sprites = pygame.sprite.LayeredUpdates()
self.blocks = pygame.sprite.LayeredUpdates()
self.enemies = pygame.sprite.LayeredUpdates()
self.attacks = pygame.sprite.LayeredUpdates()
self.createTilemap()`
everything else works but the self.createTilemap() line wouldn’t run, spent a whole hour to check the internet and debugging yet no viable answer
Ace Skywalker – Gaming Videos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.