Zane
Zane

Reputation: 21

'pygame.Surface ' object is not callable error

I keep getting a Traceback error that says 'pygame.Surface' object is not callable.

Here's the script that I'm working on (it's mostly made by Meloonatic Melons but I'm a beginner trying to learn)

import pygame, sys, time
from Scripts.Textures import *

pygame.init()

cSec = 0
cFrame = 0
FPS = 0

tile_size = 32

FPS_font = pygame.font.Font("C:\\Windows\\Fonts\\Verdana.ttf", 20)

sky = pygame.image.load("Graphics\\Sky.png")
Sky = pygame.Surface(sky.get_size(), pygame.HWSURFACE)
Sky.blit(sky, (0, 0))
del sky

def showFPS():
    fps_overlay = FPS_font.render(str(FPS), True, (104, 98, 7))
    window.blit(fps_overlay, (0, 0))


def createWindow():
    global window, window_width, window_height, window_title
    window_width, window_height = 800, 600
    window_title = "Mystic RPG"
    pygame.display.set_caption(window_title)
    window = pygame.display.set_mode((window_width, window_height), pygame.HWSURFACE|pygame.DOUBLEBUF)

def countFPS():
    global cSec, cFrame, FPS

    if cSec == time.strftime("%S"):
        cFrame += 1
    else:
        FPS = cFrame
        cFrame = 0
        cSec = time.strftime("%S")

createWindow()

isRunning = True

while isRunning:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            isRunning = False

    countFPS()

    window.blit(Sky (0, 0))

    for x in range(0, 640, tile_size):
        for y in range(0, 480, tile_size):
            window.blit(Tiles.Grass, (x,y))

    showFPS()

    pygame.display.update()

pygame.quit()
sys.exit()

The error says

 Traceback (most recent call last):
  File "C:/Users/Zane/Desktop/Python RPG/Mystic RPG.py", line 52, in <module>
    window.blit(Sky (0, 0))
TypeError: 'pygame.Surface' object is not callable

I am using Python 3.6.4

Anyone know whats going wrong and how I can fix it.

Upvotes: 0

Views: 69

Answers (1)

Gareth Ma
Gareth Ma

Reputation: 329

I am not familiar with this but in the showFPS() function, you wrote this:

Window.blit(fps_overlay, (0, 0))

While the error line, line 52, you write this:

window.blit(Sky (0, 0))

I believe you need a comma between the parameters.

Upvotes: 2

Related Questions