Anda di halaman 1dari 28

WHAT IS PYGAME…?

INTRODUCTON
 Based on creating games.

 Can run on any platform.

 User friendly.

 Varieties of modules.
WEBSITE

• http://www.pygame.org
HOW TO INSTALL..?
MODULES
MODULES IN PYGAME

CD Channel Font Joystick Rect


Sound Surface pygame UserRect
cdrom constants cursors display
draw event font image joystick
key mixer mixer_music mouse
surfarray time transform version
RECT
•collidepoint - point inside rectangle.
Rect.collidepoint(x, y)

•colliderect -check overlapping rectangles.


Rect.colliderect(rectstyle)

•move_ip - move the Rect by the given


offset.
Rect.move_ip(x, y)
SURFACE

•blit - copy a one Surface to another.


Surface.blit(source, destpos, [sourcerect])

•get_rect - get a rectangle covering the


entire surface.
Surface.get_rect()
PYGAME

•Rect - create a new rectangle.


pygame.Rect(rectstyle)

•Surface - create a new Surface.


pygame.Surface(size, [flags,
[Surface|depth, [masks]]])
•get_error - get current error message.
pygame.get_error()

• init - autoinitialize all imported pygame


modules.
pygame.init()
CONSTANTS
•events - These constants define the various
event types.
pygame.constants.events (constants)

•keyboard - These constants represent the


keys on the keyboard.
pygame.constants.keyboard (constants)
DISPLAY
•flip - update the display.
pygame.display.flip()

•get_caption -get the current title of the


window.
pygame.display.get_caption()
•set_caption - changes the title of the window.
pygame.display.set_caption(title, [icontitle])

•update - update an area of the display.


pygame.display.update([rectstyle])
IMAGE
•load - load an image to a new Surface.
pygame.image.load(file, [namehint])

•save - save surface as BMP data.


pygame.image.save(Surface, file)
KEY
•get_pressed - get the pressed state for all
keys.
pygame.key.get_pressed()

• name - get the name of a key.


pygame.key.name(int)
MOUSE
•get_pos - gets the cursor position.
pygame.mouse.get_pos()

• get_pressed - state of the mouse buttons.


pygame.mouse.get_pressed()
•set_cursor - state of shape of the mouse
cursor.
pygame.mouse.set_cursor(size,hotspot,
xormasks, andmasks)

• set_pos - moves the cursor position.


pygame.mouse.set_pos(pos)

•set_visible - show or hide the mouse cursor.


pygame.mouse.set_visible(bool)
TIME

•delay - delay for a number of milliseconds.


pygame.time.delay(millseconds)

•get_ticks - milliseconds since startup.


pygame.time.get_ticks()
CREATING GAMES WITH
PYGAME
FIRST STEP:

• The first step in creating our game is to


import Pygame.

SYNTAX:
import pygame
SECOND STEP:
• Basic steps to follow on main function
are:-

1.Initializing .
2.Loading game resources .
3.Preparing game objects .
4.Entering the game loop .
INITIALIZING
• Initialize the default pygame modules
for you.

SYNTAX:

pygame.init()
DISPLAYING SURFACE:
• The next part of our main function is
creating the
display surface.

SYNTAX

pygame.display.set_mode((640, 480),
FULLSCREEN)
IMAGE LOADING:
• Next step is to load the image.

SYNTAX

pygame.image.load('a.bmp‘)
Preparing game objects.

Entering the game loop .


Project guidance:
Mr. A.Ponnusamy

Project done by :
K.Karthik
P.R.Mani
D.Arun Kumar
S.Caroll
ANY QUERIES.?

Anda mungkin juga menyukai