Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] PLEASE HELP! TypeError: unsupported operand type(s) for +: 'pygame.Surface' and 'int'
#1
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()

Quote
#2
gDisplay is an object of type pygame.Surface, you probably meant its width and height
(gDisplay.get_width() - playerStartingx),(gDisplay.get_height() - playerStartingy)
nilamo likes this post
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  pygame.surface Graham 10 590 Nov-29-2018, 04:45 PM
Last Post: nilamo
  TypeError: this function takes 3 arguments (5 given) mario1919 1 619 Apr-05-2018, 06:05 PM
Last Post: nilamo
  [PyGame] Problem importing pygame / installing pygame Klar 4 1,801 Dec-16-2017, 05:48 PM
Last Post: Klar
  [PyGame] TypeError: unsupported operand type(s) for -: 'int' and 'instancemethod' SnekLover123 5 3,711 Oct-05-2017, 07:39 PM
Last Post: SnekLover123
  downloading pygame wheel or MSI type DAS 3 1,832 Jun-09-2017, 02:27 PM
Last Post: DAS
  [Pygame] Avoid SentDex pygame tutorials georgecoopers 1 1,412 Apr-09-2017, 12:40 PM
Last Post: metulburr

Forum Jump:


Users browsing this thread: 1 Guest(s)