Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 what does init () do?
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Waked




PostPosted: Fri Apr 12, 2013 9:24 pm   Post subject: what does init () do?

could someone please explain what does init () do?
example:

Python:

from pygame import *

init()
size = width, height = 1024, 768
screen = display.set_mode(size)
badX, badY = 0,0
red = 255, 0, 0
green = 0, 255, 0

running = True
myClock = time.Clock()

while running:
    for evnt in event.get():            # checks all events that happen
        if evnt.type == QUIT:
            running = False

    goodX, goodY = mouse.get_pos()      # input from the user & move good guy

    if goodX > badX +5:                 # move bad guy - this is my AI
        badX+=5                   
    elif goodX < badX-5:   
        badX-=5       
    if goodY > badY +5:
        badY+=5
    elif goodY < badY-5:
        badY-=5

    if ((goodX-badX)**2 + (goodY-badY)**2)**0.5 < 20:   # check interactions
        badX, badY = 0,0
     
    screen.fill((0,0,0))                # drawScene
    draw.circle(screen, red, (badX, badY), 20)
    draw.circle(screen, (0,255,0), (goodX, goodY), 20)
    display.flip()
   
    myClock.tick(60)                    # delay

quit()




Mod Edit:
Please wrap you code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
code:

[syntax="python"] ... code ... [/syntax]

[code] ... code ... [/code ]
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Fri Apr 12, 2013 9:39 pm   Post subject: RE:what does init () do?

Try looking up the documentation: http://www.pygame.org/docs/ref/pygame.html
Waked




PostPosted: Fri Apr 12, 2013 9:46 pm   Post subject: RE:what does init () do?

Thanks alot.
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: