SlideShare une entreprise Scribd logo
1  sur  21
Pygame - Game
Development
Matheus Melo
XIX PUG-PE
Schedule
 Introduction


 What   is PyGame?

 PyGame   essential Elements

 Developing     games with Pygame
What is Pygame?
 Set   of Python modules for writing games

 Compatible    with SDL

 Free   
Best Features
 No need to OpenGL setup
 Multi-core
 C/Assembler Core Functions
 Portable
 Easy to use
 Comunity
Problems
 Python     is slow 
     But you can do something to turn this out.


 You     write too much

 Isn’t   a Game Engine, it’s a library.
Essential Elements
   Surface
       What is surface?
       2D and 3D planes.

       Eg:
         tamanho = ( 640 , 480 )
         cor = ( 255 , 0 , 0 ) # v e rme lho
         superficie = Surface ( tamanho )
         superficie . set_at ( ( 10 , 20 ) , cor )
         superficie . fill ( cor , ( 11 , 21 , 50 , 50 ) )
         tela = pygame . display . set_mode ( tamanho )
Surface – Important Functions
 fill(   color, area)
      Fill a area with the selected color
 get_at(     position )
      Returns the color that was in the setted
       position
 set_at(     position, color)
      Set the color on that position
Surface – Color Depth
 256   Colors



 24   bpp RGB
    3 Bytes per color
Surface - Transparency
 ColorKey
     One color is chosen to be transparent
 Image    Alpha
     Can have his Translucency between 0 and
      255
     Can be used together with ColorKey
 Per-Pixel   Alpha
     Has a associated Alpha component.
     Cannot be used with another transparency
What is Blit ?
 Convert  the current Surface Color Depth
  to the next Surface Color Depth

 It   is a very costly function

 What     is the alternative?
Rect
   What is it?

   Eg:
       r = Rect ( ( 10 , 10 , 50 , 100 ) )
       print r.top , r. bottom # 1 0 1 1 0
       print r.left , r. right # 1 0 6 0
       print r.midtop , r. midleft # ( 3 5 , 1 0 ) ( 1 0 , 6 0 )
       print r. center # ( 3 5 , 6 0 )
       c1 = r. collidepoint ( 30 , 40 )
       c2 = r. colliderect ( ( 0 , 0 , 100 , 200 ) )
       r2 = r. inflate ( 10 , 10 )
       r2. move_ip ( 5 , 5 )
Rect – Important Functions
   clamp (area)
       Returns a new rectangle inside this area
   clip(area)
       Returns a new rectangle with his area cliped to
        fill the new area
   collidepoint(x, y)
       Check if the point is in the rectangle.
   colliderect(area)
       Check if the area toch the current rectangle
Rect – Important Functions
   contains(area)
       Check if the area is in the rectangle.
   inflate(x,y)
       Returns a new rectangle with the dimensions of
        the current rectangle increased according to
        the passed value
   move(x,y)
       Returns a new rectangle with the positions of
        current rectangle driven by passed values ​
Display
   What is it?

   Eg:
       modos = pygame . display . list_modes ()
       tela = pygame . display . set_mode ( modos [ 0 ] )
       rect = pygame . Rect ( 0 , 0 , 10 , 10 )
       pygame . display . set_caption ( " Teste do PyGame " )
       while tela . get_rect (). contains ( rect ):
       tela . fill ( ( 0 , 0 , 0 ) )
       tela . fill ( ( 255 , 0 , 0 ) , rect )
       rect . move_ip ( 10 , 10 )
       pygame . display . flip ()
Display – Essential Functions
 flip()
     Update all the screen content
 get_surface()
     Return the current surface
 list_modes()
     List possible resolutions/dimensions
 set_caption(title)
     Change screen title
Display – Essential Functions
 set_mode(size)
     Setup the screen with the passed size
 toggle_fullscreen()
     Toggle to fullscreen
 update(rect_list)
     Update certain areas of the screen
      depending of the passed list of rectangles
Event
 What    is it?

 Thereare two methods to handle the line
 of events
    Event Queued
    Direct consultation of devices
Event Queued

 from  pygame . locals import *
 for event in pygame . event .get ():
     if event . type == QUIT :
       sys   . exit ()
     elif event . type == KEYDOWN :
       print   event .key
Direct Consultation of Devices
 from  pygame . locals import *
 while not ( pygame . mouse . get_pressed ()[ 0 ]
  or  pygame .key . get_pressed ()[ K_SPACE ] ):
        pygame . event . pump ()
References
   Python: http://www.python.org/
   PyGame: http://www.pygame.org/
   A Newbie Guide to pygame:
   http://www.pygame.org/docs/tut/newbieguide.html
   Introdução ao Pygame:
   http://www.pygame.org/docs/tut/intro/intro.html
   Dicas de Performance para Python: http:
   //www.python.org/moin/PythonSpeed/Performance
    Tips
   Introdução ao Módulo Sprite do PyGame:
   http://www.pygame.org/docs/tut/SpriteIntro.html
Contact Details
 Matheus Melo
 Work mail:
     matheus.melo@idealizza.com.br
 Personal   mail:
     matheuscmpm@gmail.com
 Twitter:
     @matheuscmpm
 Facebook
     /matheuscmpm

Contenu connexe

Tendances

Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
mua99
 
My lecture infix-to-postfix
My lecture infix-to-postfixMy lecture infix-to-postfix
My lecture infix-to-postfix
Senthil Kumar
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegression
Daniel K
 
Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGH
Sukhdeep Bisht
 

Tendances (20)

Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
 
Om (Cont.)
Om (Cont.)Om (Cont.)
Om (Cont.)
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 
Module 2 topic 2 notes
Module 2 topic 2 notesModule 2 topic 2 notes
Module 2 topic 2 notes
 
Bayesian learning
Bayesian learning Bayesian learning
Bayesian learning
 
Lesson 3.4
Lesson 3.4Lesson 3.4
Lesson 3.4
 
Application of Stacks
Application of StacksApplication of Stacks
Application of Stacks
 
My lecture infix-to-postfix
My lecture infix-to-postfixMy lecture infix-to-postfix
My lecture infix-to-postfix
 
Data visualization with multiple groups using ggplot2
Data visualization with multiple groups using ggplot2Data visualization with multiple groups using ggplot2
Data visualization with multiple groups using ggplot2
 
Geo Spatial Plot using R
Geo Spatial Plot using R Geo Spatial Plot using R
Geo Spatial Plot using R
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegression
 
Experement no 6
Experement no 6Experement no 6
Experement no 6
 
Data visualization using the grammar of graphics
Data visualization using the grammar of graphicsData visualization using the grammar of graphics
Data visualization using the grammar of graphics
 
Ejemplograficar
EjemplograficarEjemplograficar
Ejemplograficar
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics Functions
 
Test
TestTest
Test
 
Butterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite NetworksButterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite Networks
 
Array using recursion
Array using recursionArray using recursion
Array using recursion
 
Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGH
 

En vedette

E o que danado é o PUG-PE?
E o que danado é o PUG-PE?E o que danado é o PUG-PE?
E o que danado é o PUG-PE?
pugpe
 
Tdd not sure if testing or developing
Tdd  not sure if testing or developingTdd  not sure if testing or developing
Tdd not sure if testing or developing
Renato Oliveira
 
NoSQL com Cassandra e Python
NoSQL com Cassandra e PythonNoSQL com Cassandra e Python
NoSQL com Cassandra e Python
pugpe
 

En vedette (20)

E dá para desenvolver webgames com Django?
E dá para desenvolver webgames com Django?E dá para desenvolver webgames com Django?
E dá para desenvolver webgames com Django?
 
E o que danado é o PUG-PE?
E o que danado é o PUG-PE?E o que danado é o PUG-PE?
E o que danado é o PUG-PE?
 
[2012] XIX PUGPE - Projeto Amadeus
[2012] XIX PUGPE -  Projeto Amadeus[2012] XIX PUGPE -  Projeto Amadeus
[2012] XIX PUGPE - Projeto Amadeus
 
Lp script pug-pe
Lp script pug-peLp script pug-pe
Lp script pug-pe
 
Palestra Institucional PUG-PE
Palestra Institucional PUG-PEPalestra Institucional PUG-PE
Palestra Institucional PUG-PE
 
Mini-Curso de Python dia 21/03 (Segunda-Feira) no II Workshop de SL do CIN/UFPE
Mini-Curso de Python dia 21/03 (Segunda-Feira) no II Workshop de SL do CIN/UFPEMini-Curso de Python dia 21/03 (Segunda-Feira) no II Workshop de SL do CIN/UFPE
Mini-Curso de Python dia 21/03 (Segunda-Feira) no II Workshop de SL do CIN/UFPE
 
Suporte a macros na sua aplicação com PowerShell
Suporte a macros na sua aplicação com PowerShellSuporte a macros na sua aplicação com PowerShell
Suporte a macros na sua aplicação com PowerShell
 
Acelere - e melhore! - o feedback com testes automatizados rápidos
Acelere - e melhore! - o feedback com testes automatizados rápidosAcelere - e melhore! - o feedback com testes automatizados rápidos
Acelere - e melhore! - o feedback com testes automatizados rápidos
 
Com vocês, Django!
Com vocês, Django!Com vocês, Django!
Com vocês, Django!
 
Tdd not sure if testing or developing
Tdd  not sure if testing or developingTdd  not sure if testing or developing
Tdd not sure if testing or developing
 
W2py pyconpe
W2py pyconpeW2py pyconpe
W2py pyconpe
 
TDC2016SP - Luiza Labs - Migrando .NET p/ Python
TDC2016SP - Luiza Labs - Migrando .NET p/ PythonTDC2016SP - Luiza Labs - Migrando .NET p/ Python
TDC2016SP - Luiza Labs - Migrando .NET p/ Python
 
TDC2016SP - Flask para Web
TDC2016SP - Flask para WebTDC2016SP - Flask para Web
TDC2016SP - Flask para Web
 
Testes exploratórios não são sinônimo de bagunça! (TDC 2016 SP)
Testes exploratórios não são sinônimo de bagunça! (TDC 2016 SP)Testes exploratórios não são sinônimo de bagunça! (TDC 2016 SP)
Testes exploratórios não são sinônimo de bagunça! (TDC 2016 SP)
 
Python, A pílula Azul da programação
Python, A pílula Azul da programaçãoPython, A pílula Azul da programação
Python, A pílula Azul da programação
 
Devcommerce 2016: Migração plataforma Magazine Luiza e seu laboratório de in...
Devcommerce 2016: Migração plataforma Magazine Luiza e seu  laboratório de in...Devcommerce 2016: Migração plataforma Magazine Luiza e seu  laboratório de in...
Devcommerce 2016: Migração plataforma Magazine Luiza e seu laboratório de in...
 
Python e Cadeias de Markov GHMM
Python e Cadeias de Markov GHMMPython e Cadeias de Markov GHMM
Python e Cadeias de Markov GHMM
 
NoSQL com Cassandra e Python
NoSQL com Cassandra e PythonNoSQL com Cassandra e Python
NoSQL com Cassandra e Python
 
Python Debugger - PUG-PE
Python Debugger - PUG-PE Python Debugger - PUG-PE
Python Debugger - PUG-PE
 
Pyjamas: Uma Ferramenta Pythônica para Web
Pyjamas: Uma Ferramenta Pythônica para WebPyjamas: Uma Ferramenta Pythônica para Web
Pyjamas: Uma Ferramenta Pythônica para Web
 

Similaire à XIX PUG-PE - Pygame game development

Scala+swing
Scala+swingScala+swing
Scala+swing
perneto
 
Function recap
Function recapFunction recap
Function recap
alish sha
 
Function recap
Function recapFunction recap
Function recap
alish sha
 

Similaire à XIX PUG-PE - Pygame game development (20)

Hive function-cheat-sheet
Hive function-cheat-sheetHive function-cheat-sheet
Hive function-cheat-sheet
 
Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptx
 
Pygame presentation
Pygame presentationPygame presentation
Pygame presentation
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
functions
functionsfunctions
functions
 
compose_speaker_session.pdf
compose_speaker_session.pdfcompose_speaker_session.pdf
compose_speaker_session.pdf
 
Go Programming Patterns
Go Programming PatternsGo Programming Patterns
Go Programming Patterns
 
Basic_analysis.ppt
Basic_analysis.pptBasic_analysis.ppt
Basic_analysis.ppt
 
Berlin meetup
Berlin meetupBerlin meetup
Berlin meetup
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
The Ring programming language version 1.5.1 book - Part 175 of 180
The Ring programming language version 1.5.1 book - Part 175 of 180 The Ring programming language version 1.5.1 book - Part 175 of 180
The Ring programming language version 1.5.1 book - Part 175 of 180
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
 
Scala+swing
Scala+swingScala+swing
Scala+swing
 
Introduction to OpenCV
Introduction to OpenCVIntroduction to OpenCV
Introduction to OpenCV
 
Functions.docx
Functions.docxFunctions.docx
Functions.docx
 
Function recap
Function recapFunction recap
Function recap
 
Function recap
Function recapFunction recap
Function recap
 
Getting Visual with Ruby Processing
Getting Visual with Ruby ProcessingGetting Visual with Ruby Processing
Getting Visual with Ruby Processing
 
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
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
Enterprise Knowledge
 

Dernier (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

XIX PUG-PE - Pygame game development

  • 2. Schedule  Introduction  What is PyGame?  PyGame essential Elements  Developing games with Pygame
  • 3. What is Pygame?  Set of Python modules for writing games  Compatible with SDL  Free 
  • 4. Best Features  No need to OpenGL setup  Multi-core  C/Assembler Core Functions  Portable  Easy to use  Comunity
  • 5. Problems  Python is slow   But you can do something to turn this out.  You write too much  Isn’t a Game Engine, it’s a library.
  • 6. Essential Elements  Surface  What is surface?  2D and 3D planes.  Eg:  tamanho = ( 640 , 480 )  cor = ( 255 , 0 , 0 ) # v e rme lho  superficie = Surface ( tamanho )  superficie . set_at ( ( 10 , 20 ) , cor )  superficie . fill ( cor , ( 11 , 21 , 50 , 50 ) )  tela = pygame . display . set_mode ( tamanho )
  • 7. Surface – Important Functions  fill( color, area)  Fill a area with the selected color  get_at( position )  Returns the color that was in the setted position  set_at( position, color)  Set the color on that position
  • 8. Surface – Color Depth  256 Colors  24 bpp RGB  3 Bytes per color
  • 9. Surface - Transparency  ColorKey  One color is chosen to be transparent  Image Alpha  Can have his Translucency between 0 and 255  Can be used together with ColorKey  Per-Pixel Alpha  Has a associated Alpha component.  Cannot be used with another transparency
  • 10. What is Blit ?  Convert the current Surface Color Depth to the next Surface Color Depth  It is a very costly function  What is the alternative?
  • 11. Rect  What is it?  Eg:  r = Rect ( ( 10 , 10 , 50 , 100 ) )  print r.top , r. bottom # 1 0 1 1 0  print r.left , r. right # 1 0 6 0  print r.midtop , r. midleft # ( 3 5 , 1 0 ) ( 1 0 , 6 0 )  print r. center # ( 3 5 , 6 0 )  c1 = r. collidepoint ( 30 , 40 )  c2 = r. colliderect ( ( 0 , 0 , 100 , 200 ) )  r2 = r. inflate ( 10 , 10 )  r2. move_ip ( 5 , 5 )
  • 12. Rect – Important Functions  clamp (area)  Returns a new rectangle inside this area  clip(area)  Returns a new rectangle with his area cliped to fill the new area  collidepoint(x, y)  Check if the point is in the rectangle.  colliderect(area)  Check if the area toch the current rectangle
  • 13. Rect – Important Functions  contains(area)  Check if the area is in the rectangle.  inflate(x,y)  Returns a new rectangle with the dimensions of the current rectangle increased according to the passed value  move(x,y)  Returns a new rectangle with the positions of current rectangle driven by passed values ​
  • 14. Display  What is it?  Eg:  modos = pygame . display . list_modes ()  tela = pygame . display . set_mode ( modos [ 0 ] )  rect = pygame . Rect ( 0 , 0 , 10 , 10 )  pygame . display . set_caption ( " Teste do PyGame " )  while tela . get_rect (). contains ( rect ):  tela . fill ( ( 0 , 0 , 0 ) )  tela . fill ( ( 255 , 0 , 0 ) , rect )  rect . move_ip ( 10 , 10 )  pygame . display . flip ()
  • 15. Display – Essential Functions  flip()  Update all the screen content  get_surface()  Return the current surface  list_modes()  List possible resolutions/dimensions  set_caption(title)  Change screen title
  • 16. Display – Essential Functions  set_mode(size)  Setup the screen with the passed size  toggle_fullscreen()  Toggle to fullscreen  update(rect_list)  Update certain areas of the screen depending of the passed list of rectangles
  • 17. Event  What is it?  Thereare two methods to handle the line of events  Event Queued  Direct consultation of devices
  • 18. Event Queued  from pygame . locals import *  for event in pygame . event .get ():  if event . type == QUIT :  sys . exit ()  elif event . type == KEYDOWN :  print event .key
  • 19. Direct Consultation of Devices  from pygame . locals import *  while not ( pygame . mouse . get_pressed ()[ 0 ] or pygame .key . get_pressed ()[ K_SPACE ] ):  pygame . event . pump ()
  • 20. References  Python: http://www.python.org/  PyGame: http://www.pygame.org/  A Newbie Guide to pygame:  http://www.pygame.org/docs/tut/newbieguide.html  Introdução ao Pygame:  http://www.pygame.org/docs/tut/intro/intro.html  Dicas de Performance para Python: http:  //www.python.org/moin/PythonSpeed/Performance Tips  Introdução ao Módulo Sprite do PyGame:  http://www.pygame.org/docs/tut/SpriteIntro.html
  • 21. Contact Details  Matheus Melo  Work mail:  matheus.melo@idealizza.com.br  Personal mail:  matheuscmpm@gmail.com  Twitter:  @matheuscmpm  Facebook  /matheuscmpm