By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

Pygame TypeError: python.surface object unsubscriptable

P: 4
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
Share this question for a faster answer!
Share on Google+

Post your reply

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