Skip to content

shiva-karthick/py_games

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Games tutorial with pygame

Dependencies

  • Python 3.6 and above
  • pygame module
Windows : pip install pygame

Racing

Racing

Bricks

Bricks

Pygame crash course

Welcome to a quick pygame crash course. Firstly, Install pygame.

Windows : pip install pygame

The below code shows a basic framework that is included in every pygame.

import pygame
from pygame.locals import *
import os
import sys
import math
import random

pygame.init()
fpsClock = pygame.time.Clock()
pygame.display.set_caption('Flappy Bird')
main_surface = pygame.display.set_mode((800, 600))
BLACK = pygame.Color(0, 0, 0)

# initialise all things here


while True:
    main_surface.blit()

    # draw something


    # draw something


    # draw something

    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

    # main game logic

    pygame.display.update()  # pygame.display.flip()
    clock.tick(60) # 60 frames

pygame.quit()
quit()