I am trying to run some pygame code and get this error:
Pygame TypeError: python.surface object unsubscriptable
Here is the code:
Note: Obviously this isn't all the code.
The function will work with real number though.i.e
But it can't assign to an item in a list.
Are these just pygame restrictions? Or am I doing something wrong?
Also, everytime I get an error like this after I create the pygame window I can't close the window and it become unresponsive.
I there any fix to that?
thank!
mahem1
Pygame TypeError: python.surface object unsubscriptable
Here is the code:
Code:
ball1 = [ 100 ,50 , 1, 0]
def ball (x,y,movex,movey):
if x < 0 :
x * -1
if x > 580:
x= x* -1
if y < 0:
y = y* -1
if y > 260:
y = y*-1
x+= movex
y+= movey
return x ,y
ball1x = ball1 [0]
ball1y = ball1 [1]
ball1x ,ball1y = ball( ball1x, ball1y ,1 ,0 )
The function will work with real number though.i.e
Code:
ball1x , ball1y = ball ( 10 , 450, 1 ,0)
Code:
ball1 [0], ball1 [1] = ball( 10, 405, 1 ,0 )
Also, everytime I get an error like this after I create the pygame window I can't close the window and it become unresponsive.
I there any fix to that?
thank!
mahem1