Find all about S.I

lundi 7 octobre 2013

Creating your first game in Python pygame python

Load up your favorite IDE and type in the following code (Python is sensitive to indention, so be sure to include them!):

Setting up

1) Download and install the Python programming language software: http://www.python.org/download/.  As of this writing, the latest Python version is 2.5.1.
2) Download and install PyGame from http://www.pygame.org/download.shtml.  The latest version is 1.7.1 and make sure you download the PyGame binary for your operating system that has been compiled for Python 2.5.
3) For writing code, here are a couple of free Integrated Development Environments (IDEs) which I recommend:
• WingIDE  101:  http://wingware.com/downloads/wingide-101/installers
• Eclipse:  http://www.eclipse.org/downloads/  (Download the Eclipse classic)
o You’ll also need the PyDev Python plug-in for Eclipse:  http://pydev.sourceforge.net/download.html

Load up your favorite IDE and type in the following code (Python is sensitive to indention, so be sure to include them!):
èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè

#!/usr/bin/env python

"""Proof of concept gfxdraw example"""

import pygame
import pygame.gfxdraw

def main():
    pygame.init()
    screen = pygame.display.set_mode((500,500))
    screen.fill((255, 0, 0))
    s = pygame.Surface(screen.get_size(), pygame.SRCALPHA, 32)
    pygame.gfxdraw.aacircle(s, 250, 250, 200, (0, 0, 0))
    screen.blit(s, (0, 0))
    pygame.display.flip()
    try:
        while 1:
            event = pygame.event.wait()
            if event.type == pygame.QUIT:
                break
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE or event.unicode == 'q':
                    break
            pygame.display.flip()
    finally:
        pygame.quit()

if __name__ == '__main__':
    main()

Aucun commentaire:

Enregistrer un commentaire