Im making 2d-tiled game using Pygame, after creating an object TypeError: ‘object’ object is not callable
from pygame import *
from Classes import *
from Variables import *
from Objects import *
game_map = [['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','3','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','3','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "3", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','3','0','0','0','0','0','0','0','0','0','0','0','3','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "3", "0", "0", "0", "0", "0", "0"],
['0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"],
['1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1', "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"],
['1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1', "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"]]
while True:
"other code"
if screen == "game":
if lose == True:
screen = "Lose"
for event in pygame.event.get():
if event.type == pygame.QUIT:
game = False
pygame.quit()
exit()
window.fill(white)
tile_rects = []
y = 0
for row in game_map:
x = 0
for tile in row:
if tile == '0':
window.blit(air, (x * TILE_SIZE, y * TILE_SIZE))
if tile == '1':
window.blit(floor_block, (x * TILE_SIZE, y * TILE_SIZE))
if tile == '2':
window.blit(cmon_block, (x * TILE_SIZE, y * TILE_SIZE))
if tile == '3':
coin_ex = Coin("Coin1.jpg", x * TILE_SIZE, y * TILE_SIZE, 10, 16, 16)
coins.append(coin_ex)
if tile != '0':
tile_rects.append(pygame.Rect(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE))
x += 1
y += 1
"Other code"
Here`s Classes
class GameSprite(sprite.Sprite):
def __init__(self, filename, x, y, speed, w, h):
super().__init__()
self.speed = speed
self.image = transform.scale(image.load(filename), (w, h))
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.w = w
self.h = h
def reset(self):
window.blit(self.image, (self.rect.x, self.rect.y))
"GameSprite logic"
class Coin(GameSprite):
def __init__(self, filename, x, y, speed, w, h):
GameSprite.__init__(self, filename, x, y, speed, w, h)
self.counter = 0
self.isPicked = False
"Coin Logic"
Error
coin_ex = Coin(“Coin1.jpg”, x * TILE_SIZE, y * TILE_SIZE, 10, 16, 16)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ‘Coin’ object is not callable
I tried using call method, but it didnt worked, i dunno why
New contributor
ALTXAIR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.