SlideShare a Scribd company logo
1 of 59
Download to read offline
Introduction to
            PyGame
Abhishek Mishra   hello@ideamonk.com
Agenda
• Games - 2d games
• Basics
• Python
• PyGame
• Examples
Whats inside a Game?
• Multidisciplinary Process
• Graphics
• Input Control
• Game Logic / AI
• Sound effects / Music
• Communication
• Physics, etc
• Frameworks ^ Libraries ^^
Basics - Drawing
• Drawing primitives
• Pixels, Square, Rect, Ellipse, etc
• Provided by development env
Basics - Animation

• Draw things
• Change their positon
• Draw them again
• Repeat
Basics - Animation

• Draw things
• Change their positon
• Draw them again
• Repeat
Basics - Animation

• Draw things
• Change their positon
• Draw them again
• Repeat
Basics - Animation

• Draw things
• Change their positon
• Draw them again
• Repeat
Basics - Animation

• Draw things
• Change their positon
• Draw them again
• Repeat
Basics - Surfaces
• Drawing primitives use algorithms
• Slow for repetitive work
Basics - Surfaces
• Drawing primitives use algorithms
• Slow for repetitive work
Basics - Surfaces
• How do we save time?
Basics - Surfaces
• How do we save time?
Basics - Surfaces
• How do we save time?


      A Surface / Bitmap
Basics - Surfaces
• How do we save time?



                         RAM
Basics - Surfaces
• How do we save time?



                         RAM
Basics - Surfaces
• Bitmaps
• Rectangular
• CPU Inexpensive
• Can be layered
Basics - Surfaces
  • Bitmaps
  • Rectangular
  • CPU Inexpensive
  • Can be layered
Sky layer
 Trees
Enemies
Basics - Animation Again!
• Monitors have refresh rate
• Can’t draw so many surfaces on live screen
• How do we make it smooth?
• How do we sync?
Basics - Animation Again!
• Draw on a buffer surface
• Wait for vertical sync
• Transfer the whole buffer to screen
Basics - Animation Again!
• Draw on a buffer surface
• Wait for vertical sync
• Transfer the whole buffer to screen
Basics - Animation Again!
• Draw on a buffer surface
• Wait for vertical sync
• Transfer the whole buffer to screen
Basics - Animation Again!
• Draw on a buffer surface
• Wait for vertical sync
• Transfer the whole buffer to screen
Collision Detection
Collision Detection




     2D Bound checks
Collision Detection




                        Pixel Perfect
http://wiki.allegro.cc/index.php?title=Pixel_Perfect_Collision
Introduction to Game programming with PyGame Part 1
Ah! So many things to do?
Ah! So many things to do?
  Enter Frameworks /
   Engines/ Libraries
    & other angels
Programming
• Lot of repetitive tasks
• Lot of things you don’t wish to figure out
• Technologies - OpenGL, DirectX, SDL
• Interfacing Libraries
• Generic set of solutions - frameworks
• Complete solutions - Game Engines,
  toolsets
Programming
• Many options to choose from -
• DirectQB (old MSDOS days)
• Allegro (C/C++, cross platform)
• PyGame (Python, SDL)
• PyGlet (Python, OpenGL)
• XNA (Windows, XBox, dotNET, C#,VB)
• DirectX (Windows specific,VC++, C# ...)
Programming
• Many options to choose from -
• DirectQB (old MSDOS days)
• Allegro (C/C++, cross platform)
• PyGame (Python, SDL)
• PyGlet (Python, OpenGL)
• XNA (Windows, XBox, dotNET, C#,VB)
• DirectX (Windows specific,VC++, C# ...)
A Basic Game Loop
Start       While player is alive

           take input

           find collisions

           draw on buffer

           put everything on screen
A Basic Game Loop
Start       While player is alive

           take input

           find collisions

           draw on buffer

           put everything on screen
A Basic Game Loop
Start       While player is alive

           take input

           find collisions

           draw on buffer

           put everything on screen
A Basic Game Loop
Start       While player is alive

           take input

           find collisions

           draw on buffer

           put everything on screen
A Basic Game Loop
Start       While player is alive

           take input

           find collisions

           draw on buffer

           put everything on screen
A Basic Game Loop
Start       While player is alive

           take input

           find collisions

           draw on buffer

           put everything on screen
A Basic Game Loop
Start       While player is alive

           take input

           find collisions

           draw on buffer

           put everything on screen
What now?
• An entertaining idea
• A Programming Language
• A Game programming framework
• Some bells, whistles & decorations
Python
• Dynamic, Interpreted, Interactive
• Object Oriented
• Easy to write, easy to read
• Popular - education, prototyping, quick
  hacks, research, unlimited
• Batteries included
• From web to standalones
Python
• Free
• On many platforms (Unix, Linux, Windows,
  OS X, Symbian S60, Java, BeOS)
• Lacks type declaration
• Huge library of modules
Python
• printf (“Hi %s”, name);
  print “Hi %s” % name
• int x = 45;   float y = 1.01
  x = 45        y = 1.01
• int a[4] = {1,2,3,4}
  a = [1,2,3,4]
  a = [1,2,‘abhishek’, 4, 4.5]
Python
Indentation

if (name == ‘abc’):
    print “Yes”
else:
    print “No”
Python
Strings

fruit = “Apple”
fruit = ‘Apple’
fruit = “““ Apple and ‘apple” ”””
fruit = ‘‘‘ foo bar ’’’
message = “Hello %s. Total is %d” % (name, total)
Python
Lists

l = [1,2,3, ‘foo’, 4.5]
print l[3]
foo
l = [ [1,2,3], ‘a’, ‘b’, ‘c’ ]
innerlist = l[0]
print innerlist
[1,2,3]
Python
Dictionaries

Associative key => value pairs
d = { ‘name’ : ‘Ram’, ‘age’:45 }
print d[‘name’]
print d[‘age’]
d[‘salary’] = 45000
Python
Loops

for (int x=0; x<10; x+=2) { // do something }
for x in range(0,10,2):
   # do something
Python
Loops

L = [1,2,4,5,3,1]
for i in L:
   print i
1
2
4
5
3
1
Python
Functions

def factorial( num ):
  if num==1:
      return 1
  else:
      return num * factorial(num-1)

print factorial(4)
24
Python
Comments

# single line comment
“““ multi
            line ”””
Python
Modules

import math
print math.pi
• Based on SDL (Simple Directmedia Layer)
• Works on Windows, OSX, Linux, N900, etc
• Big array of modules, does a lot to save
  time
• http://pygame.org
• $ sudo easy_install pygame
Introduction to Game programming with PyGame Part 1
http://www.pygame.org/docs/

http://www.pygame.org/docs/
       ref/examples.html
Introduction to Game programming with PyGame Part 1
pygame.Color pygame.transform    pygame.draw
pygame.Rect    pygame.Surface   pygame.mouse

pygame.image   pygame.movie     pygame.display

               pygame.camera     pygame.time
pygame.midi
pygame.event   pygame.mixer      pygame.font

                                       ...
Code / Demo time
To be continued ...

More Related Content

What's hot

Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaEdureka!
 
Physically Based Rendering
Physically Based RenderingPhysically Based Rendering
Physically Based RenderingKoray Hagen
 
Game design as a career
Game design as a career Game design as a career
Game design as a career Shanthi Ravi
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming KrishnaMildain
 
POWER OF PYTHON PROGRAMMING LANGUAGE
POWER OF PYTHON PROGRAMMING LANGUAGE POWER OF PYTHON PROGRAMMING LANGUAGE
POWER OF PYTHON PROGRAMMING LANGUAGE teachersduniya.com
 
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | EdurekaPython Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | EdurekaEdureka!
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPriyaSoundararajan1
 
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)David Salz
 
Intro to liveops
Intro to liveopsIntro to liveops
Intro to liveopsCrystin Cox
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaEdureka!
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!Fariz Darari
 
Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...David Salz
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentationMartin McBride
 
PRESENTATION ON Game Engine
PRESENTATION ON Game EnginePRESENTATION ON Game Engine
PRESENTATION ON Game EngineDiksha Bhargava
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAgung Wahyudi
 

What's hot (20)

Python basic
Python basicPython basic
Python basic
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Python
PythonPython
Python
 
Physically Based Rendering
Physically Based RenderingPhysically Based Rendering
Physically Based Rendering
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Game design as a career
Game design as a career Game design as a career
Game design as a career
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
 
POWER OF PYTHON PROGRAMMING LANGUAGE
POWER OF PYTHON PROGRAMMING LANGUAGE POWER OF PYTHON PROGRAMMING LANGUAGE
POWER OF PYTHON PROGRAMMING LANGUAGE
 
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | EdurekaPython Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.ppt
 
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
 
Intro to liveops
Intro to liveopsIntro to liveops
Intro to liveops
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
 
Snake PY Game.pptx
Snake PY Game.pptxSnake PY Game.pptx
Snake PY Game.pptx
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
 
PRESENTATION ON Game Engine
PRESENTATION ON Game EnginePRESENTATION ON Game Engine
PRESENTATION ON Game Engine
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 

Viewers also liked

3D Computer Graphics with Python
3D Computer Graphics with Python3D Computer Graphics with Python
3D Computer Graphics with PythonMartin Christen
 
Minecraft in 500 lines with Pyglet - PyCon UK
Minecraft in 500 lines with Pyglet - PyCon UKMinecraft in 500 lines with Pyglet - PyCon UK
Minecraft in 500 lines with Pyglet - PyCon UKRichard Donkin
 
Minecraft in 500 lines of Python with Pyglet
Minecraft in 500 lines of Python with PygletMinecraft in 500 lines of Python with Pyglet
Minecraft in 500 lines of Python with PygletRichard Donkin
 
Introduction to Game Programming Tutorial
Introduction to Game Programming TutorialIntroduction to Game Programming Tutorial
Introduction to Game Programming TutorialRichard Jones
 
Intro to Game Programming
Intro to Game ProgrammingIntro to Game Programming
Intro to Game ProgrammingRichard Jones
 
Introduction To Facebook: Opportunities and Challenges For The Institution
Introduction To Facebook: Opportunities and Challenges For The InstitutionIntroduction To Facebook: Opportunities and Challenges For The Institution
Introduction To Facebook: Opportunities and Challenges For The Institutionlisbk
 
Python games
Python gamesPython games
Python gamesdxbeeh
 
Facebook Development for Beginners
Facebook Development for BeginnersFacebook Development for Beginners
Facebook Development for BeginnersJesse Stay
 
RDS_Photoscan_Eval_Cloud
RDS_Photoscan_Eval_CloudRDS_Photoscan_Eval_Cloud
RDS_Photoscan_Eval_CloudRaminder Singh
 
Introduction to Facebook Python API
Introduction to Facebook Python APIIntroduction to Facebook Python API
Introduction to Facebook Python APIColin Su
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scriptingAmirul Shafeeq
 
Server and Client side comparision
Server and Client side comparisionServer and Client side comparision
Server and Client side comparisionStew Duncan
 
Workshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKWorkshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKDimitar Danailov
 
Introduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKIntroduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKColin Su
 
Facebook Python SDK - Introduction
Facebook Python SDK - IntroductionFacebook Python SDK - Introduction
Facebook Python SDK - IntroductionColin Su
 
Facebook essay ideas
Facebook essay ideasFacebook essay ideas
Facebook essay ideasLisa Shaw
 
Scripting languages
Scripting languagesScripting languages
Scripting languagesteach4uin
 

Viewers also liked (20)

3D Computer Graphics with Python
3D Computer Graphics with Python3D Computer Graphics with Python
3D Computer Graphics with Python
 
Minecraft in 500 lines with Pyglet - PyCon UK
Minecraft in 500 lines with Pyglet - PyCon UKMinecraft in 500 lines with Pyglet - PyCon UK
Minecraft in 500 lines with Pyglet - PyCon UK
 
Minecraft in 500 lines of Python with Pyglet
Minecraft in 500 lines of Python with PygletMinecraft in 500 lines of Python with Pyglet
Minecraft in 500 lines of Python with Pyglet
 
Introduction to Game Programming Tutorial
Introduction to Game Programming TutorialIntroduction to Game Programming Tutorial
Introduction to Game Programming Tutorial
 
Intro to Game Programming
Intro to Game ProgrammingIntro to Game Programming
Intro to Game Programming
 
Introduction To Facebook: Opportunities and Challenges For The Institution
Introduction To Facebook: Opportunities and Challenges For The InstitutionIntroduction To Facebook: Opportunities and Challenges For The Institution
Introduction To Facebook: Opportunities and Challenges For The Institution
 
Python games
Python gamesPython games
Python games
 
Facebook Development for Beginners
Facebook Development for BeginnersFacebook Development for Beginners
Facebook Development for Beginners
 
RDS_Photoscan_Eval_Cloud
RDS_Photoscan_Eval_CloudRDS_Photoscan_Eval_Cloud
RDS_Photoscan_Eval_Cloud
 
Introduction to Facebook Python API
Introduction to Facebook Python APIIntroduction to Facebook Python API
Introduction to Facebook Python API
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
 
Server and Client side comparision
Server and Client side comparisionServer and Client side comparision
Server and Client side comparision
 
Workshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDKWorkshop : Facebook JavaScript SDK
Workshop : Facebook JavaScript SDK
 
Website vs web app
Website vs web appWebsite vs web app
Website vs web app
 
Introduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDKIntroduction to Facebook JavaScript & Python SDK
Introduction to Facebook JavaScript & Python SDK
 
Facebook Python SDK - Introduction
Facebook Python SDK - IntroductionFacebook Python SDK - Introduction
Facebook Python SDK - Introduction
 
Mobile app Vs Web App
Mobile app Vs Web AppMobile app Vs Web App
Mobile app Vs Web App
 
Client & server side scripting
Client & server side scriptingClient & server side scripting
Client & server side scripting
 
Facebook essay ideas
Facebook essay ideasFacebook essay ideas
Facebook essay ideas
 
Scripting languages
Scripting languagesScripting languages
Scripting languages
 

Similar to Introduction to Game programming with PyGame Part 1

C101 – Intro to Programming with C
C101 – Intro to Programming with CC101 – Intro to Programming with C
C101 – Intro to Programming with Cgpsoft_sk
 
Programming the Raspberry Pi element14
Programming the Raspberry Pi element14Programming the Raspberry Pi element14
Programming the Raspberry Pi element14Imad Rhali
 
Intro To Java Alpharetta Meetup Day-1
Intro To Java Alpharetta Meetup Day-1Intro To Java Alpharetta Meetup Day-1
Intro To Java Alpharetta Meetup Day-1introtojava
 
[Osxdev]3.swift playgrounds
[Osxdev]3.swift playgrounds[Osxdev]3.swift playgrounds
[Osxdev]3.swift playgroundsNAVER D2
 
Pa++ern - esoteric language for embroidery (2009)
Pa++ern - esoteric language for embroidery  (2009)Pa++ern - esoteric language for embroidery  (2009)
Pa++ern - esoteric language for embroidery (2009)daitomanabe
 
놀아요 Swift Playgrounds
놀아요 Swift Playgrounds놀아요 Swift Playgrounds
놀아요 Swift PlaygroundsWooKyoung Noh
 
Python week 2 2019 2020 for g10 by eng.osama ghandour
Python week 2 2019 2020 for g10 by eng.osama ghandourPython week 2 2019 2020 for g10 by eng.osama ghandour
Python week 2 2019 2020 for g10 by eng.osama ghandourOsama Ghandour Geris
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hdslantsixgames
 
Game design & development
Game design & developmentGame design & development
Game design & developmentHemanth Sharma
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP PerspectiveBarry Jones
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi boardThierry Gayet
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeyEasy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeypprem
 

Similar to Introduction to Game programming with PyGame Part 1 (20)

05 python.pdf
05 python.pdf05 python.pdf
05 python.pdf
 
Charming python
Charming pythonCharming python
Charming python
 
C101 – Intro to Programming with C
C101 – Intro to Programming with CC101 – Intro to Programming with C
C101 – Intro to Programming with C
 
Programming the Raspberry Pi element14
Programming the Raspberry Pi element14Programming the Raspberry Pi element14
Programming the Raspberry Pi element14
 
Intro To Java Alpharetta Meetup Day-1
Intro To Java Alpharetta Meetup Day-1Intro To Java Alpharetta Meetup Day-1
Intro To Java Alpharetta Meetup Day-1
 
[Osxdev]3.swift playgrounds
[Osxdev]3.swift playgrounds[Osxdev]3.swift playgrounds
[Osxdev]3.swift playgrounds
 
Pa++ern - esoteric language for embroidery (2009)
Pa++ern - esoteric language for embroidery  (2009)Pa++ern - esoteric language for embroidery  (2009)
Pa++ern - esoteric language for embroidery (2009)
 
놀아요 Swift Playgrounds
놀아요 Swift Playgrounds놀아요 Swift Playgrounds
놀아요 Swift Playgrounds
 
God Of War : post mortem
God Of War : post mortemGod Of War : post mortem
God Of War : post mortem
 
python_class.pptx
python_class.pptxpython_class.pptx
python_class.pptx
 
Python week 1 2020-2021
Python week 1 2020-2021Python week 1 2020-2021
Python week 1 2020-2021
 
Python week 2 2019 2020 for g10 by eng.osama ghandour
Python week 2 2019 2020 for g10 by eng.osama ghandourPython week 2 2019 2020 for g10 by eng.osama ghandour
Python week 2 2019 2020 for g10 by eng.osama ghandour
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hd
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to Coding
 
Game design & development
Game design & developmentGame design & development
Game design & development
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP Perspective
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
 
py4inf-01-intro.ppt
py4inf-01-intro.pptpy4inf-01-intro.ppt
py4inf-01-intro.ppt
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeyEasy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkey
 

More from Abhishek Mishra

Scraping with Python for Fun and Profit - PyCon India 2010
Scraping with Python for Fun and Profit - PyCon India 2010Scraping with Python for Fun and Profit - PyCon India 2010
Scraping with Python for Fun and Profit - PyCon India 2010Abhishek Mishra
 
Amritadhara - Issues, Challenges, and a Solution
Amritadhara - Issues, Challenges, and a SolutionAmritadhara - Issues, Challenges, and a Solution
Amritadhara - Issues, Challenges, and a SolutionAbhishek Mishra
 
Project SpaceLock - Architecture & Design
Project SpaceLock - Architecture & DesignProject SpaceLock - Architecture & Design
Project SpaceLock - Architecture & DesignAbhishek Mishra
 
The Beginning - Jan 20 2009
The Beginning - Jan 20 2009The Beginning - Jan 20 2009
The Beginning - Jan 20 2009Abhishek Mishra
 
SpaceLock Meetup - Plan 25 Jan 09
SpaceLock Meetup - Plan 25 Jan 09SpaceLock Meetup - Plan 25 Jan 09
SpaceLock Meetup - Plan 25 Jan 09Abhishek Mishra
 
Identification Simplified - An Introduction to Biometrics
Identification Simplified - An Introduction to BiometricsIdentification Simplified - An Introduction to Biometrics
Identification Simplified - An Introduction to BiometricsAbhishek Mishra
 

More from Abhishek Mishra (11)

Paddles at pelham
Paddles at pelhamPaddles at pelham
Paddles at pelham
 
All in a day
All in a dayAll in a day
All in a day
 
Scraping with Python for Fun and Profit - PyCon India 2010
Scraping with Python for Fun and Profit - PyCon India 2010Scraping with Python for Fun and Profit - PyCon India 2010
Scraping with Python for Fun and Profit - PyCon India 2010
 
Introducing BugBase 1.0
Introducing BugBase 1.0Introducing BugBase 1.0
Introducing BugBase 1.0
 
Amritadhara - Issues, Challenges, and a Solution
Amritadhara - Issues, Challenges, and a SolutionAmritadhara - Issues, Challenges, and a Solution
Amritadhara - Issues, Challenges, and a Solution
 
Gibson Guitar Robot
Gibson Guitar RobotGibson Guitar Robot
Gibson Guitar Robot
 
Space Lock Web UI
Space Lock Web UISpace Lock Web UI
Space Lock Web UI
 
Project SpaceLock - Architecture & Design
Project SpaceLock - Architecture & DesignProject SpaceLock - Architecture & Design
Project SpaceLock - Architecture & Design
 
The Beginning - Jan 20 2009
The Beginning - Jan 20 2009The Beginning - Jan 20 2009
The Beginning - Jan 20 2009
 
SpaceLock Meetup - Plan 25 Jan 09
SpaceLock Meetup - Plan 25 Jan 09SpaceLock Meetup - Plan 25 Jan 09
SpaceLock Meetup - Plan 25 Jan 09
 
Identification Simplified - An Introduction to Biometrics
Identification Simplified - An Introduction to BiometricsIdentification Simplified - An Introduction to Biometrics
Identification Simplified - An Introduction to Biometrics
 

Recently uploaded

Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 

Recently uploaded (20)

Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 

Introduction to Game programming with PyGame Part 1

  • 1. Introduction to PyGame Abhishek Mishra hello@ideamonk.com
  • 2. Agenda • Games - 2d games • Basics • Python • PyGame • Examples
  • 3. Whats inside a Game? • Multidisciplinary Process • Graphics • Input Control • Game Logic / AI • Sound effects / Music • Communication • Physics, etc • Frameworks ^ Libraries ^^
  • 4. Basics - Drawing • Drawing primitives • Pixels, Square, Rect, Ellipse, etc • Provided by development env
  • 5. Basics - Animation • Draw things • Change their positon • Draw them again • Repeat
  • 6. Basics - Animation • Draw things • Change their positon • Draw them again • Repeat
  • 7. Basics - Animation • Draw things • Change their positon • Draw them again • Repeat
  • 8. Basics - Animation • Draw things • Change their positon • Draw them again • Repeat
  • 9. Basics - Animation • Draw things • Change their positon • Draw them again • Repeat
  • 10. Basics - Surfaces • Drawing primitives use algorithms • Slow for repetitive work
  • 11. Basics - Surfaces • Drawing primitives use algorithms • Slow for repetitive work
  • 12. Basics - Surfaces • How do we save time?
  • 13. Basics - Surfaces • How do we save time?
  • 14. Basics - Surfaces • How do we save time? A Surface / Bitmap
  • 15. Basics - Surfaces • How do we save time? RAM
  • 16. Basics - Surfaces • How do we save time? RAM
  • 17. Basics - Surfaces • Bitmaps • Rectangular • CPU Inexpensive • Can be layered
  • 18. Basics - Surfaces • Bitmaps • Rectangular • CPU Inexpensive • Can be layered Sky layer Trees Enemies
  • 19. Basics - Animation Again! • Monitors have refresh rate • Can’t draw so many surfaces on live screen • How do we make it smooth? • How do we sync?
  • 20. Basics - Animation Again! • Draw on a buffer surface • Wait for vertical sync • Transfer the whole buffer to screen
  • 21. Basics - Animation Again! • Draw on a buffer surface • Wait for vertical sync • Transfer the whole buffer to screen
  • 22. Basics - Animation Again! • Draw on a buffer surface • Wait for vertical sync • Transfer the whole buffer to screen
  • 23. Basics - Animation Again! • Draw on a buffer surface • Wait for vertical sync • Transfer the whole buffer to screen
  • 25. Collision Detection 2D Bound checks
  • 26. Collision Detection Pixel Perfect http://wiki.allegro.cc/index.php?title=Pixel_Perfect_Collision
  • 28. Ah! So many things to do?
  • 29. Ah! So many things to do? Enter Frameworks / Engines/ Libraries & other angels
  • 30. Programming • Lot of repetitive tasks • Lot of things you don’t wish to figure out • Technologies - OpenGL, DirectX, SDL • Interfacing Libraries • Generic set of solutions - frameworks • Complete solutions - Game Engines, toolsets
  • 31. Programming • Many options to choose from - • DirectQB (old MSDOS days) • Allegro (C/C++, cross platform) • PyGame (Python, SDL) • PyGlet (Python, OpenGL) • XNA (Windows, XBox, dotNET, C#,VB) • DirectX (Windows specific,VC++, C# ...)
  • 32. Programming • Many options to choose from - • DirectQB (old MSDOS days) • Allegro (C/C++, cross platform) • PyGame (Python, SDL) • PyGlet (Python, OpenGL) • XNA (Windows, XBox, dotNET, C#,VB) • DirectX (Windows specific,VC++, C# ...)
  • 33. A Basic Game Loop Start While player is alive take input find collisions draw on buffer put everything on screen
  • 34. A Basic Game Loop Start While player is alive take input find collisions draw on buffer put everything on screen
  • 35. A Basic Game Loop Start While player is alive take input find collisions draw on buffer put everything on screen
  • 36. A Basic Game Loop Start While player is alive take input find collisions draw on buffer put everything on screen
  • 37. A Basic Game Loop Start While player is alive take input find collisions draw on buffer put everything on screen
  • 38. A Basic Game Loop Start While player is alive take input find collisions draw on buffer put everything on screen
  • 39. A Basic Game Loop Start While player is alive take input find collisions draw on buffer put everything on screen
  • 40. What now? • An entertaining idea • A Programming Language • A Game programming framework • Some bells, whistles & decorations
  • 41. Python • Dynamic, Interpreted, Interactive • Object Oriented • Easy to write, easy to read • Popular - education, prototyping, quick hacks, research, unlimited • Batteries included • From web to standalones
  • 42. Python • Free • On many platforms (Unix, Linux, Windows, OS X, Symbian S60, Java, BeOS) • Lacks type declaration • Huge library of modules
  • 43. Python • printf (“Hi %s”, name); print “Hi %s” % name • int x = 45; float y = 1.01 x = 45 y = 1.01 • int a[4] = {1,2,3,4} a = [1,2,3,4] a = [1,2,‘abhishek’, 4, 4.5]
  • 44. Python Indentation if (name == ‘abc’): print “Yes” else: print “No”
  • 45. Python Strings fruit = “Apple” fruit = ‘Apple’ fruit = “““ Apple and ‘apple” ””” fruit = ‘‘‘ foo bar ’’’ message = “Hello %s. Total is %d” % (name, total)
  • 46. Python Lists l = [1,2,3, ‘foo’, 4.5] print l[3] foo l = [ [1,2,3], ‘a’, ‘b’, ‘c’ ] innerlist = l[0] print innerlist [1,2,3]
  • 47. Python Dictionaries Associative key => value pairs d = { ‘name’ : ‘Ram’, ‘age’:45 } print d[‘name’] print d[‘age’] d[‘salary’] = 45000
  • 48. Python Loops for (int x=0; x<10; x+=2) { // do something } for x in range(0,10,2): # do something
  • 49. Python Loops L = [1,2,4,5,3,1] for i in L: print i 1 2 4 5 3 1
  • 50. Python Functions def factorial( num ): if num==1: return 1 else: return num * factorial(num-1) print factorial(4) 24
  • 51. Python Comments # single line comment “““ multi line ”””
  • 53. • Based on SDL (Simple Directmedia Layer) • Works on Windows, OSX, Linux, N900, etc • Big array of modules, does a lot to save time • http://pygame.org • $ sudo easy_install pygame
  • 57. pygame.Color pygame.transform pygame.draw pygame.Rect pygame.Surface pygame.mouse pygame.image pygame.movie pygame.display pygame.camera pygame.time pygame.midi pygame.event pygame.mixer pygame.font ...
  • 58. Code / Demo time