[PyGame] PLEASE HELP! TypeError: unsupported operand type(s) for +: 'pygame.Surface' and 'int' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Game Development (https://python-forum.io/forum-11.html) +--- Thread: [PyGame] PLEASE HELP! TypeError: unsupported operand type(s) for +: 'pygame.Surface' and 'int' (/thread-11032.html) |
PLEASE HELP! TypeError: unsupported operand type(s) for +: 'pygame.Surface' and 'int' - keyfive - Jun-19-2018 Very new coder here. Line 32 says player = pygame.draw.rect(gDisplay, red, ((gDisplay + playerStartingx),(gDisplay + playerStartingy), 60, 60), 0) TypeError: unsupported operand type(s) for +: 'pygame.Surface' and 'int' import pygame import time import random import sys pygame.init() #screen variables sWidth = 1280 sHeight = 720 #colours red = (255,0,0) black = (0,0,0) white = (255,255,255) #Main mechanics gDisplay = pygame.display.set_mode((sWidth,sHeight)) clock = pygame.time.Clock() pygame.display.set_caption('Zube') def gameStart(): #Mechanics gDisplay.fill(white) pygame.display.update() clock.tick(60) #Shapes and stuff playerStartingx = 64 playerStartingy = 36 player = pygame.draw.rect(gDisplay, red, ((gDisplay - playerStartingx),(gDisplay - playerStartingy), 60, 60), 0) pygame.display.update() #Game Loop Variable playing = True while playing: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() gameStart() RE: PLEASE HELP! TypeError: unsupported operand type(s) for +: 'pygame.Surface' and 'int' - volcano63 - Jun-19-2018 gDisplay is an object of type pygame.Surface, you probably meant its width and height(gDisplay.get_width() - playerStartingx),(gDisplay.get_height() - playerStartingy) |