0% found this document useful (0 votes)
277 views1 page

Pygame Zero Cheat Sheet: by Via

This document is a cheat sheet for Pygame Zero that provides examples of code and explanations of key concepts. It includes a sample game code that moves an alien actor across the screen and reacts to mouse clicks by changing the alien's image. It also lists mouse and keyboard buttons and explains the behind-the-scenes game loop structure of process input, update, and draw.

Uploaded by

Joan Petit Gros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
277 views1 page

Pygame Zero Cheat Sheet: by Via

This document is a cheat sheet for Pygame Zero that provides examples of code and explanations of key concepts. It includes a sample game code that moves an alien actor across the screen and reacts to mouse clicks by changing the alien's image. It also lists mouse and keyboard buttons and explains the behind-the-scenes game loop structure of process input, update, and draw.

Uploaded by

Joan Petit Gros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Pygame Zero Cheat Sheet

by Mamat Rahmat (coderbodoh) via cheatography.com/68741/cs/17325/

 Working Example - Code  Behind the Scene

TITLE = 'Alien Click' while game_has_not_ended():


WIDTH = 500 ​ ​ ​ ​pro​ces​s_i​nput()
HEIGHT = 200 ​ ​ ​ ​upd​ate()
alien = Actor(​'al​ien') ​ ​ ​ ​draw()
alien.pos = (0, HEIGHT//2)
def draw(): Mouse Button
​ ​ ​ ​scr​een.cl​ear()
mouse.LEFT mouse.RIGHT
​ ​ ​ ​ali​en.d​raw()
mouse.MI​DDLE
def update():
​ ​ ​ ​ali​en.left += 2 mouse.WH​EEL_UP mouse.WH​EEL​_DOWN

​ ​ ​ if alien.left > WIDTH:


​ ​ ​ ​ ​ ​ ​ ​ali​en.r​ight = 0  Keyboard Button

def on_mou​se_​dow​n(pos): BACKSPACE TAB


​ ​ ​ if alien.c​ol​lid​epo​int​(pos):
CLEAR RETURN
​ ​ ​ ​ ​ ​ ​ ​ali​en.i​mage = 'alien​_hurt'
PAUSE ESCAPE
​ ​ ​ ​ ​ ​ ​ ​sou​nds.ee​p.p​lay()
SPACE EXCLAIM
​ ​ ​ ​ ​ ​ ​ ​ani​mat​e(a​lien, tween=​'ac​cel​erate',
QUOTEDBL HASH
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​on_​fin​ish​ed=​set​_al​ien​_back,
​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​pos​=(a​lie​n.x​+200, alien.y)) DOLLAR AMPERSAND

def set_al​ien​_ba​ck(): QUOTE LEFTPAREN


​ ​ ​ ​ali​en.i​mage = 'alien' RIGHTPAREN ASTERISK

PLUS COMMA
Working Example - Result
MINUS PERIOD

SLASH K_0

K_1 K_2

K_3 K_4

K_5 K_6

K_7 K_8

K_9 COLON

SEMICOLON LESS

EQUALS GREATER

QUESTION AT

LEFTBR​ACKET BACKSLASH

RIGHTB​RACKET CARET

UNDERSCORE BACKQUOTE

By Mamat Rahmat (coderbodoh) Not published yet. Sponsored by CrosswordCheats.com


cheatography.com/coderbodoh/ Last updated 3rd October, 2018. Learn to solve cryptic crosswords!
olimpiadeinformatika.com Page 1 of 1. http://crosswordcheats.com

You might also like