
-----------------------------------
Waked
Fri Apr 12, 2013 9:24 pm

what does init () do?
-----------------------------------
could someone please explain what does init () do?
example:


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 ... 

[code] ... code ... [/code ]
[/code]

-----------------------------------
DemonWasp
Fri Apr 12, 2013 9:39 pm

RE:what does init () do?
-----------------------------------
Try looking up the documentation: http://www.pygame.org/docs/ref/pygame.html

-----------------------------------
Waked
Fri Apr 12, 2013 9:46 pm

RE:what does init () do?
-----------------------------------
Thanks alot.
