Cheat Sheet on Pygame Module
import pygame
pygame.init()
pygame.display.set_mode((width, height))
display.set_caption('Title of the window')
pygame.display.update()
pygame.Color(R, G, B)
Surface.fill(color)
pygame.font.SysFont('Font Name', FontSize)
Surface.blit(source, dest, area, speical_flags)
|
pygame.time.Clock()
|
Creates a clock object and you can control the clock using tick() function
|
|
pygame.time.Clock.get_fps()
|
Returns the clock framerate
|
|
pygame.time.Clock.get_time()
|
Returns the time used in previous tick
|
|
pygame.time.delay()
|
Pause for time specified
|
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
|
pygame.event.post()
|
Places a new event that you specify on the queue
|
|
pygame.event.Event()
|
Creates a new event object
|
|
pygame.event.get()
|
Gets the event from the queue
|
|
pygame.event.clear()
|
removes all the events from the queue
|
|
pygame.image.load()
|
Loads a new image from a file that you specify
|
|
pygame.image.save()
|
You can save the image to your drive using this function
|
|
pygame.mixer.init()
|
Initializes the mixer module
|
|
pygame.mixer.music.load()
|
Loads the music file you specify as the argument
|
|
pygame.mixer.music.play()
|
Plays the sound
|
|
pygame.mixer.music.stop()
|
Stops the music from being played
|
|
pygame.mixer.quit()
|
UnInitializes the mixer module
|
|
pygame.quit()
|
Quits the game
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.