[source code] Pygame (Python Game Development) Tutorials 1-10

+2 Bucky Roberts · November 13, 2014
Pygame Tutorial 1
import pygame


Pygame Tutorial 2
import pygame

pygame.init()

white = (255,255,255)
black = (0,0,0)
red = (255,0,0)

gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Slither')

gameExit = False

lead_x = 300
lead_y = 300
lead_x_change = 0

clock = pygame.time.Clock()


while not gameExit:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
           gameExit = True
       if event.type == pygame.KEYDOWN:
           if event.key == pygame.K_LEFT:
               lead_x_change = -10
           if event.key == pygame.K_RIGHT:
               lead_x_change = 10

               
       

   lead_x += lead_x_change
   gameDisplay.fill(white)
   pygame.draw.rect(gameDisplay, black, [lead_x,lead_y,10,10])
   pygame.display.update()

   clock.tick(30)
   

pygame.quit()
quit()


Pygame Tutorial 3
import pygame

pygame.init()

gameDisplay = pygame.display.set_mode((800,600))

pygame.display.update()

pygame.quit()
quit()


Pygame Tutorial 4
import pygame

pygame.init()

gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Slither')

pygame.display.update()

gameExit = False

while not gameExit:
   for event in pygame.event.get():
       print(event)

   
   

pygame.quit()
quit()


Pygame Tutorial 5
import pygame

pygame.init()

gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Slither')

pygame.display.update()

gameExit = False

while not gameExit:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
           gameExit = True


pygame.quit()
quit()


Pygame Tutorial 6
import pygame

pygame.init()

white = (255,255,255)
black = (0,0,0)
red = (255,0,0)

gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Slither')


gameExit = False

while not gameExit:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
           gameExit = True

   gameDisplay.fill(white)
   pygame.display.update()
   

   


   


pygame.quit()
quit()


Pygame Tutorial 7
import pygame

pygame.init()

white = (255,255,255)
black = (0,0,0)
red = (255,0,0)

gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Slither')


gameExit = False

while not gameExit:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
           gameExit = True

   gameDisplay.fill(white)
   pygame.draw.rect(gameDisplay, black, [400,300,10,10])

   gameDisplay.fill(red, rect=[200,200,50,50])

   

   
   
   
   pygame.display.update()
   

   


   


pygame.quit()
quit()


Pygame Tutorial 8
import pygame

pygame.init()

white = (255,255,255)
black = (0,0,0)
red = (255,0,0)

gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Slither')

gameExit = False

lead_x = 300
lead_y = 300

while not gameExit:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
           gameExit = True
       if event.type == pygame.KEYDOWN:
           if event.key == pygame.K_LEFT:
               lead_x -= 10
           if event.key == pygame.K_RIGHT:
               lead_x += 10

   gameDisplay.fill(white)
   pygame.draw.rect(gameDisplay, black, [lead_x,lead_y,10,10])
   pygame.display.update()
   

pygame.quit()
quit()


Pygame Tutorial 9
import pygame

pygame.init()

white = (255,255,255)
black = (0,0,0)
red = (255,0,0)

gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Slither')

gameExit = False

lead_x = 300
lead_y = 300
lead_x_change = 0

while not gameExit:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
           gameExit = True
       if event.type == pygame.KEYDOWN:
           if event.key == pygame.K_LEFT:
               lead_x_change = -10
           if event.key == pygame.K_RIGHT:
               lead_x_change = 10

   lead_x += lead_x_change
   gameDisplay.fill(white)
   pygame.draw.rect(gameDisplay, black, [lead_x,lead_y,10,10])
   pygame.display.update()
   

pygame.quit()
quit()


Pygame Tutorial 10
import pygame

pygame.init()

white = (255,255,255)
black = (0,0,0)
red = (255,0,0)

gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Slither')

gameExit = False

lead_x = 300
lead_y = 300
lead_x_change = 0

clock = pygame.time.Clock()


while not gameExit:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
           gameExit = True
       if event.type == pygame.KEYDOWN:
           if event.key == pygame.K_LEFT:
               lead_x_change = -10
           if event.key == pygame.K_RIGHT:
               lead_x_change = 10

   lead_x += lead_x_change
   gameDisplay.fill(white)
   pygame.draw.rect(gameDisplay, black, [lead_x,lead_y,10,10])
   pygame.display.update()

   clock.tick(15)
   

pygame.quit()
quit()

Post a Reply

Replies

Oldest  Newest  Rating
0 ANIL BAKHLA · November 19, 2014
i cannot able to find the videos for Pygame (Python Game Development) Tutorials 1-78
  • 1

Python

107,339 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator