SlideShare ist ein Scribd-Unternehmen logo
1 von 59
Downloaden Sie, um offline zu lesen
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
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
http://www.pygame.org/docs/

http://www.pygame.org/docs/
       ref/examples.html
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 ...

Weitere ähnliche Inhalte

Was ist angesagt?

game project presentation
game project presentationgame project presentation
game project presentationKavi Kumar
 
python presntation 2.pptx
python presntation 2.pptxpython presntation 2.pptx
python presntation 2.pptxArpittripathi45
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPriyaSoundararajan1
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAgung Wahyudi
 
Game development
Game developmentGame development
Game developmentRareCoders
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...Edureka!
 
Introduction to python programming, Why Python?, Applications of Python
Introduction to python programming, Why Python?, Applications of PythonIntroduction to python programming, Why Python?, Applications of Python
Introduction to python programming, Why Python?, Applications of PythonPro Guide
 
Game object models - Game Engine Architecture
Game object models - Game Engine ArchitectureGame object models - Game Engine Architecture
Game object models - Game Engine ArchitectureShawn Presser
 
Introduction to Game Design
Introduction to Game DesignIntroduction to Game Design
Introduction to Game DesignMartin Sillaots
 
Mobile Game Development in Unity
Mobile Game Development in UnityMobile Game Development in Unity
Mobile Game Development in UnityHakan Saglam
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | EdurekaEdureka!
 

Was ist angesagt? (20)

Python Intro
Python IntroPython Intro
Python Intro
 
game project presentation
game project presentationgame project presentation
game project presentation
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
 
PyCharm demo
PyCharm demoPyCharm demo
PyCharm demo
 
python presntation 2.pptx
python presntation 2.pptxpython presntation 2.pptx
python presntation 2.pptx
 
First-person Shooters
First-person ShootersFirst-person Shooters
First-person Shooters
 
Python
PythonPython
Python
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.ppt
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Game development
Game developmentGame development
Game development
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
 
Introduction to python programming, Why Python?, Applications of Python
Introduction to python programming, Why Python?, Applications of PythonIntroduction to python programming, Why Python?, Applications of Python
Introduction to python programming, Why Python?, Applications of Python
 
Game object models - Game Engine Architecture
Game object models - Game Engine ArchitectureGame object models - Game Engine Architecture
Game object models - Game Engine Architecture
 
Python basic
Python basicPython basic
Python basic
 
Introduction to Game Design
Introduction to Game DesignIntroduction to Game Design
Introduction to Game Design
 
Python basic
Python basicPython basic
Python basic
 
Mobile Game Development in Unity
Mobile Game Development in UnityMobile Game Development in Unity
Mobile Game Development in Unity
 
Python made easy
Python made easy Python made easy
Python made easy
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | Edureka
 

Andere mochten auch

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
 

Andere mochten auch (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
 
Pygame presentation
Pygame presentationPygame presentation
Pygame presentation
 
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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

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
  • 27.
  • 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
  • 54.
  • 56.
  • 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