0
votes

hey so i've been getting a type error that says "traceback (most recent call last): File "(stdin)", line 1 in, (module) TypeError: unsupported operand type(s) for -: 'str' and 'int'

The entire code is:

    # 1 - Import library
    ... import.pygame
    from pygame.locals import *
    # 2 - Initialize the game
    ... pygame.init() 
    (6, 0)
    "width", "height" - 640, 480

then the error message occurs after that please help me to fix it because i'm clueless.

2
What do you expect "height" - 640 to do? - Blender
The line "width", "height" - 640, 480 is telling. You cannot subtract an int from a string. Perhaps you mean ("width", "height", "-", "640", "480") -- i.e., all strings. - dawg
@Blender i don't know probably adjust the height to 640? i'm clueless right now man :| - user3282362
@dawg thanks dude that fixed it - user3282362

2 Answers

1
votes

Sorry, but I can not identify a working code and therefore analyze the error in total, so I am just referencing a tutorial example now.

In my opinion, you are not defining width and height as they should be defined (should be defined for/as resolution.

See a simple example here: http://jonasbsb.jo.funpic.de/hendrix/pygame-example.html

Hope this helps.

0
votes

The error is definitely due to "height" - 640 because you can't subtract an integer from a strong.

I would guess that the minus sign is a typo, and that the line should actually read

width, height = 640, 480   # VGA screen resolution