473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1649

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

Similar topics

32
by: siggi | last post by:
@Ben Sizer Hi Ben, in January I received your message re Pygame and Python 2.5: As a Python (and programming ) newbie allow me a - certainly naive - question:
5
by: vml | last post by:
I have a python com object which contains a method to inverse an array in vb 6 the definition of the class is : class Fop: _public_methods_ = def SqVal(self,*val): #vol=(val,val)...
3
by: Mathew | last post by:
Hi I have seen examples from Mark Hammonds book where a Python COM object is accessed from Excel with a VBA script. But, what if I want to Insert a Python COM into the Sheet itself? When I try...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.