pyGame

How to import pygame

import pygame

Create game window

How do i create a window

variable = pygame.display.set_mode((x, y))

How do i keep the window open until i press X
running = True
while running:
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			running = False

Title Logo Background

How do i set the title

pygame.display.set_caption('title of the game')

How do i set the logo
logo = pygame.image.load('name of image.jpg')
pygame.display.set_icon(logo)
How do i set the background colour
main loop:
	screen.fill((r, g, b))
	pygame.display.update()
How do i set the background image
background = pygame.image.load('image name.png')

#main loop
screen.blit(background, (0,0))

Create a player

Image of the player
playerImage = pygame.image.load('player.jpg')
location of player
xLocation = number
ylocation = number
create player
def player():
	screen.blit(playerImg, (xLocation, yLocation))

Move objects

How do i move a object

Get the object function and increase the value by said amount

The idea is that you will over lay the object with each game loop by the background

Key pressed events

How to check if the left arrow was pressed
for event in pygame.event.get():
	#checks if key has been pressed down, 'pygame.KEYUP' checks if released
	if event.type == pygame.KEYDOWN:
		#was that key the left arrow key
		if event.key == pygame.K_LEFT:

Boundaries

How to keep player in boundarys

Use a if statement, to tell the player to go the negative of the direction player is moving