[Tutor] a pyball python app

dean garrad thankyouforthevenom1971 at hotmail.co.uk
Thu Apr 3 16:27:16 CEST 2008



this is the part im lil confused about to add the extra ball

location=[img.size[0]/2,img.size[1]/2]
speed=[0.,0.]
blobsize=16
xs,ys=img.size[0]-blobsize,img.size[1]-blobsize
acceleration=0.05
friction = 0.993

import time
start_time=time.clock()
n_frames=0


i tried copying but it did nothing do i need to copy it and change something so the python app dont read the same txt twice and jus do nothing?





also on the txt bellow if i add another bal somehow i dotn have to copy or change the txt bellow do i? it should create same value for both balls?


   
    x_bounce_factor = .8 * (1 - min(6,abs(sense_conn.delta[0])) / 9) 
    y_bounce_factor = .8 * (1 - min(6,abs(sense_conn.delta[1])) / 9) 

    if location[0]>xs:
        location[0]=xs-(location[0]-xs)
        speed[0]= -x_bounce_factor * speed[0]
        speed[1]=0.90*speed[1]
    if location[0]<0:
        location[0]=-location[0]
        speed[0]= -x_bounce_factor * speed[0]
        speed[1]=0.90*speed[1]
    if location[1]>ys:
        location[1]=ys-(location[1]-ys)
        speed[0]=0.90*speed[0]
        speed[1]= -y_bounce_factor * speed[1]
    if location[1]<0:
        location[1]=-location[1]
        speed[0]=0.90*speed[0]
        speed[1]= -y_bounce_factor * speed[1]





im just confused on how to get the programme to add another ball into it and keep everything the same.. 

i tried changing and copying some of the script but the app jus loads the whole ball script twice and seperate ball on each. 



also could you link advise any good tuturials that would help me ive read some on the net but need more help really.

thank you for your time. . 

> Date: Thu, 3 Apr 2008 10:16:37 -0400
> From: kent37 at tds.net
> To: thankyouforthevenom1971 at hotmail.co.uk
> CC: tutor at python.org
> Subject: Re: [Tutor] a pyball python app
> 
> dean garrad wrote:
> > i kind of understood what you were saying but not sure how to go by this 
> > i am still new to python script and learning it as much as i can.
> 
> OK. Do you understand how the current script works? If not, what parts 
> are confusing?
> 
> Do you understand object-oriented programming at all (classes)? If not, 
> you should probably read some tutorials and get at least a basic 
> understanding.
> 
> You could add another ball by brute-force copying of lots of code, or by 
> making a list of (location, speed) values for each ball, but the code 
> will end up simpler and easier to understand if you use a class to hold 
> the parameters for the ball.
> 
> Kent

_________________________________________________________________
Win 100’s of Virgin Experience days with BigSnapSearch.com
http://www.bigsnapsearch.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080403/957557d1/attachment-0001.htm 


More information about the Tutor mailing list