SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examplesmua99
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfixSelf-Employed
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions Dr. Volkan OBAN
 
Bayesian learning
Bayesian learning Bayesian learning
Bayesian learning EngReads
 
My lecture infix-to-postfix
My lecture infix-to-postfixMy lecture infix-to-postfix
My lecture infix-to-postfixSenthil Kumar
 
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 ggplot2Rupak Roy
 
Geo Spatial Plot using R
Geo Spatial Plot using R Geo Spatial Plot using R
Geo Spatial Plot using R Rupak Roy
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegressionDaniel K
 
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 graphicsRupak Roy
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics FunctionsSHAKOOR AB
 
Butterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite NetworksButterfly Counting in Bipartite Networks
Butterfly Counting in Bipartite NetworksSeyed-Vahid Sanei-Mehri
 
Array using recursion
Array using recursionArray using recursion
Array using recursionSwarup Boro
 
Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHSukhdeep Bisht
 

La actualidad más candente (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
 

Destacado

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?Guilherme Medeiros
 
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
 
[2012] XIX PUGPE - Projeto Amadeus
[2012] XIX PUGPE -  Projeto Amadeus[2012] XIX PUGPE -  Projeto Amadeus
[2012] XIX PUGPE - Projeto AmadeusThiago
 
Lp script pug-pe
Lp script pug-peLp script pug-pe
Lp script pug-pehugoesb
 
Palestra Institucional PUG-PE
Palestra Institucional PUG-PEPalestra Institucional PUG-PE
Palestra Institucional PUG-PEMarcel Caraciolo
 
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/UFPEMarcel Caraciolo
 
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 PowerShellIgor Abade
 
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ápidosIgor Abade
 
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 developingRenato Oliveira
 
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/ Pythontdc-globalcode
 
TDC2016SP - Flask para Web
TDC2016SP - Flask para WebTDC2016SP - Flask para Web
TDC2016SP - Flask para Webtdc-globalcode
 
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)Igor Abade
 
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çãoMarcel Caraciolo
 
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...André Fatala
 
Python e Cadeias de Markov GHMM
Python e Cadeias de Markov GHMMPython e Cadeias de Markov GHMM
Python e Cadeias de Markov GHMMpugpe
 
NoSQL com Cassandra e Python
NoSQL com Cassandra e PythonNoSQL com Cassandra e Python
NoSQL com Cassandra e Pythonpugpe
 
Python Debugger - PUG-PE
Python Debugger - PUG-PE Python Debugger - PUG-PE
Python Debugger - PUG-PE Arthur Alvim
 
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 WebNielson Santana
 

Destacado (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
 

Similar a XIX PUG-PE - Pygame game development

Hive function-cheat-sheet
Hive function-cheat-sheetHive function-cheat-sheet
Hive function-cheat-sheetDr. Volkan OBAN
 
Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxTseChris
 
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 1bPhilip Schwarz
 
Go Programming Patterns
Go Programming PatternsGo Programming Patterns
Go Programming PatternsHao Chen
 
Basic_analysis.ppt
Basic_analysis.pptBasic_analysis.ppt
Basic_analysis.pptSoumyaJ3
 
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 Mahmoud Samir Fayed
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONvikram mahendra
 
Scala+swing
Scala+swingScala+swing
Scala+swingperneto
 
Function recap
Function recapFunction recap
Function recapalish sha
 
Function recap
Function recapFunction recap
Function recapalish sha
 
Getting Visual with Ruby Processing
Getting Visual with Ruby ProcessingGetting Visual with Ruby Processing
Getting Visual with Ruby ProcessingRichard LeBer
 
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 202Mahmoud Samir Fayed
 

Similar a 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
 

Último

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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.pdfsudhanshuwaghmare1
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 

Último (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

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