469,360 Members | 2,242 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Pygame TypeError: python.surface object unsubscriptable

I am trying to run some pygame code and get this error:
Pygame TypeError: python.surface object unsubscriptable
Here is the code:
Expand|Select|Wrap|Line Numbers
  1. ball1 = [ 100 ,50 , 1, 0]
  2.  
  3. def ball (x,y,movex,movey):
  4.     if x < 0 :
  5.         x * -1
  6.     if x > 580:
  7.         x= x* -1
  8.     if y < 0:
  9.         y = y* -1
  10.     if y > 260:
  11.         y = y*-1
  12.  
  13.     x+= movex
  14.     y+= movey
  15.  
  16.     return x ,y
  17.  
  18.   ball1x = ball1 [0]
  19.   ball1y = ball1 [1]
  20.   ball1x ,ball1y  = ball( ball1x, ball1y  ,1 ,0 )
  21.  
Note: Obviously this isn't all the code.

The function will work with real number though.i.e
Expand|Select|Wrap|Line Numbers
  1. ball1x , ball1y = ball ( 10 , 450, 1 ,0)
But it can't assign to an item in a list.
Expand|Select|Wrap|Line Numbers
  1. ball1 [0], ball1 [1] = ball( 10, 405, 1 ,0 )
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
Jul 4 '11 #1
0 1454

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.