SlideShare a Scribd company logo
Game Programming
      LCA 2010
     Richard Jones
The Basics
• Displaying something
• Controlling animation
• User input
• Gameplay mechanics
• Playing sound effects and music
• Further stuff
Displaying Something

• Opening a window
• Reading images
• Displaying images
Controlling Animation

• Image position on screen
• Updates over time
• Accounting for frame rate
User Input


• Getting events
• Distinct keyboard events vs. keyboard state
Gameplay Mechanics


• Interaction of game objects
• Detecting important events (game won or
  game over)
Detecting Collisions

• Pixel-Perfect
• Axis-Aligned Bounding Box
• Circle-Circle
• Hash Map
Sound


• Reading sound files
• Playing sounds and background music
Opening a Window

 import pyglet

 w = pyglet.window.Window()

 pyglet.app.run()
Clearing the Window
  import pyglet

  w = pyglet.window.Window()

  @w.event
  def on_draw():
     w.clear()

  pyglet.app.run()
Drawing
import pyglet

w = pyglet.window.Window()

ship_image = pyglet.image.load('data/ship.png')

@w.event
def on_draw():
   w.clear()
   ship_image.blit(100, 100)

pyglet.app.run()
Better Drawing
import pyglet

w = pyglet.window.Window()

ship_image = pyglet.image.load('data/ship.png')
ship = pyglet.sprite.Sprite(ship_image)
ship.position = (100, 100)

@w.event
def on_draw():
   w.clear()
   ship_image.blit(100, 100)
   ship.draw()

pyglet.app.run()
Animation
...
   w.clear()
   ship.draw()

def update(dt):
    ship.x += 1

pyglet.clock.schedule_interval(update, 1./30)

pyglet.app.run()
Better Animation
 ...
    w.clear()
    ship.draw()

 def update(dt):
     ship.x += 1
     ship.x += 100 * dt

 pyglet.clock.schedule_interval(update, 1./30)

 pyglet.app.run()
Adding Asteroids
 import random
 import pyglet

 w = pyglet.window.Window()

 def center_anchor(img):
     img.anchor_x = img.width / 2
     img.anchor_y = img.height / 2

 ...
Adding Asteroids
...
ship_image = pyglet.image.load('data/ship.png')
center_anchor(ship_image)
ship = pyglet.sprite.Sprite(ship_image)
ship.position = (100, 100)

big_asteroid_image = pyglet.image.load('data/big_asteroid.png')
center_anchor(big_asteroid_image)
asteroids = []
for i in range(3):
    x = random.randint(0, w.width)
    y = random.randint(0, w.height)
    s = pyglet.sprite.Sprite(big_asteroid_image, x, y)
    s.dx = random.randint(-100, 100)
    s.dy = random.randint(-100, 100)
    asteroids.append(s)

@w.event
...
Adding Asteroids

   ...
   @w.event
   def on_draw():
       w.clear()
       for asteroid in asteroids:
           asteroid.draw()
       ship.draw()
   ...
Adding Asteroids

  ...
  def update(dt):
      ship.x += 100 * dt
      for asteroid in asteroids:
          asteroid.x += asteroid.dx*dt
          asteroid.y += asteroid.dy*dt
  ...
A Little Refactoring

   ...
   ship = pyglet.sprite.Sprite(ship_image)
   ship.position = (100, 100)
   ship.dx = 100
   ship.dy = 0

   ...
Screen Wrapping
  ...
  def update(dt):
      ship.x += 100 * dt
      for asteroid in asteroids:
          asteroid.x += asteroid.dx*dt
          asteroid.y += asteroid.dy*dt
      for a in asteroids + [ship]:
          a.x += a.dx*dt
          a.y += a.dy*dt
          if a.x - a.width/2 > w.width:
              a.x -= w.width + a.width
          elif a.x + a.width/2 < 0:
              a.x += w.width + a.width
          if a.y - a.height/2 > w.height:
              a.y -= w.height + a.height
          elif a.y + a.height/2 < 0:
              a.y += w.height + a.height
  ...
Control

import math
import random
import pyglet

w = pyglet.window.Window()

...
Control
...
keys = pyglet.window.key.KeyStateHandler()
w.push_handlers(keys)

def update(dt):
    if keys[pyglet.window.key.LEFT]:
        ship.rotation -= 360*dt
    if keys[pyglet.window.key.RIGHT]:
        ship.rotation += 360*dt
    rotation = math.radians(ship.rotation)
    rotation_x = math.cos(-rotation)
    rotation_y = math.sin(-rotation)
    if keys[pyglet.window.key.UP]:
        ship.dx += 200 * rotation_x * dt
        ship.dy += 200 * rotation_y * dt

   for a in asteroids + [ship]:
   ...
Rotation

...
ship = pyglet.sprite.Sprite(ship_image)
ship.position = (100, 100)
ship.dx = 100
ship.dy = 0
ship.position = (w.width/2, w.height/2)
ship.dx = ship.dy = ship.dr = 0

...
Rotation

      ...
      s = pyglet.sprite.Sprite(big_asteroid_image, x, y)
      s.dx = random.randint(-100, 100)
      s.dy = random.randint(-100, 100)
      s.dr = random.randint(-100, 100)
      asteroids.append(s)

...
Rotation
...
def update(dt):
    if keys[pyglet.window.key.LEFT]:
        ship.rotation -= 360*dt
    if keys[pyglet.window.key.RIGHT]:
        ship.rotation += 360*dt
    ship.dr = (keys[pyglet.window.key.RIGHT] - keys[pyglet.window.key.LEFT]) * 360
    rotation = math.pi * ship.rotation / 180.0
    ...
    for a in asteroids + [ship]:
        a.x += a.dx*dt
        a.y += a.dy*dt
        a.rotation += a.dr * dt
        if a.x - a.width/2 > w.width:
            a.x -= w.width + a.width
Collision Detection
Collision Detection
Collision Detection
Collision Detection
Collision Detection

       distance
Collision Detection

  import   sys
  import   math
  import   random
  import   pyglet

  w = pyglet.window.Window()
  ...
Collision Detection

 ...
 w.push_handlers(keys)

 def distance(a, b):
     return math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2)

 def update(dt):
     ...
Collision Detection

       ...
       elif a.y + a.height/2 < 0:
           a.y += w.height + a.height

   for a in asteroids:
       if distance(a, ship) < (a.width/2 + ship.width/2):
           sys.exit('GAME OVER')

pyglet.clock.schedule_interval(update, 1./30)
...
Shooting

ship.position = (w.width/2, w.height/2)
ship.dx = ship.dy = ship.dr = 0
ship.gun_cooldown = 0

bullet_image = pyglet.image.load('data/bullet.png')
center_anchor(bullet_image)
bullets = []

...
...
             Shooting
    ship.dy += 200 * rotation_y * dt

if ship.gun_cooldown:
    ship.gun_cooldown = max(0, ship.gun_cooldown - dt)
elif keys[pyglet.window.key.SPACE] and len(bullets) < 2:
    b = pyglet.sprite.Sprite(bullet_image, ship.x, ship.y)
    b.dx = rotation_x * 500
    b.dy = rotation_y * 500
    b.dr = 0
    b.life = 1
    bullets.append(b)
    ship.gun_cooldown = .5

for b in list(bullets):
    b.life -= dt
    if b.life < 0:
        bullets.remove(b)

for a in asteroids + [ship]:
for a in asteroids + [ship] + bullets:
     a.x += a.dx*dt
     ...
Shooting

...
@w.event
def on_draw():
    w.clear()
    for asteroid in asteroids:
         asteroid.draw()
    for s in asteroids + bullets:
        s.draw()
    ship.draw()
...
Shooting ... and Hitting

   ...
   def distance(a, b):
       return math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2)
   def collide(a, b):
       return distance(a, b) < (a.width/2 + b.width/2)
   ...
Shooting ... and Hitting
        ...
        elif a.y + a.height/2 < 0:
            a.y += w.height + a.height

    for a in asteroids:
        if distance(a, ship) < (a.width/2 + ship.width/2):
            sys.exit('GAME OVER')
    for a in list(asteroids):
        if collide(a, ship):
            sys.exit('GAME OVER')
        for b in list(bullets):
            if collide(a, b):
                bullets.remove(b)
                asteroids.remove(a)

    if not asteroids:
        sys.exit('YOU WIN')

 pyglet.clock.schedule_interval(update, 1./30)
 ...
Chunks

...
center_anchor(bullet_image)
bullets = []

small_asteroid_image = pyglet.image.load('data/small_asteroid.png')
center_anchor(small_asteroid_image)
medium_asteroid_image = pyglet.image.load('data/medium_asteroid.png')
center_anchor(medium_asteroid_image)
big_asteroid_image = pyglet.image.load('data/big_asteroid.png')
center_anchor(big_asteroid_image)
...
...
                          Chunks
   for b in list(bullets):
       if collide(a, b):
           bullets.remove(b)
           asteroids.remove(a)
           if a.image is big_asteroid_image.texture:
               for i in range(2):
                   s = pyglet.sprite.Sprite(medium_asteroid_image, a.x, a.y)
                   s.dx = a.dx + random.randint(-50, 50)
                   s.dy = a.dy + random.randint(-50, 50)
                   s.dr = a.dr + random.randint(-50, 50)
                   asteroids.append(s)
           elif a.image is medium_asteroid_image.texture:
               for i in range(2):
                   s = pyglet.sprite.Sprite(small_asteroid_image, a.x, a.y)
                   s.dx = a.dx + random.randint(-50, 50)
                   s.dy = a.dy + random.randint(-50, 50)
                   s.dr = a.dr + random.randint(-50, 50)
                   asteroids.append(s)

if not asteroids:
    sys.exit('YOU WIN')
...
Sound Effects

...
      asteroids.append(s)

explosion_sound = pyglet.media.load('data/explosion.wav', streaming=False)
bullet_sound = pyglet.media.load('data/bullet.wav', streaming=False)

@w.event
def on_draw():
...
Sound Effects

     ...
     bullets.append(b)
     ship.gun_cooldown = .5
     bullet_sound.play()

  for b in list(bullets):
  ...
Sound Effects

...
bullets.remove(b)
asteroids.remove(a)
explosion_sound.play()
if a.image is big_asteroid_image.texture:
Further Stuff

• Opening screen
• Options menu
• Game won / game over screen
• Special effects
Other screen / menu


• Use libraries like Cocos2d (Scenes, Layers,
  Sprites, Animations)
Special Effects


• Simple image animations
• Use libraries like lepton
Where To From Here?

• http://pyglet.org
• http://pygame.org
• http://los-cocos.org
• http://inventwithpython.com/
• http://pyweek.org

More Related Content

What's hot

The Ring programming language version 1.2 book - Part 35 of 84
The Ring programming language version 1.2 book - Part 35 of 84The Ring programming language version 1.2 book - Part 35 of 84
The Ring programming language version 1.2 book - Part 35 of 84
Mahmoud Samir Fayed
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
Jenchoke Tachagomain
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
Jenchoke Tachagomain
 
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180
Mahmoud Samir Fayed
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
Jussi Pohjolainen
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31
Mahmoud Samir Fayed
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
Jussi Pohjolainen
 
Александр Зимин – Анимация как средство самовыражения
Александр Зимин – Анимация как средство самовыраженияАлександр Зимин – Анимация как средство самовыражения
Александр Зимин – Анимация как средство самовыражения
CocoaHeads
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
Jussi Pohjolainen
 
ES6(ES2015) is beautiful
ES6(ES2015) is beautifulES6(ES2015) is beautiful
ES6(ES2015) is beautiful
monikagupta18jan
 
λ | Lenses
λ | Lensesλ | Lenses
λ | Lenses
Open-IT
 
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84
Mahmoud Samir Fayed
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
Jussi Pohjolainen
 
Expand/Collapse animation on Android
Expand/Collapse animation on AndroidExpand/Collapse animation on Android
Expand/Collapse animation on Android
Pavlo Dudka
 
Beyond Scala Lens
Beyond Scala LensBeyond Scala Lens
Beyond Scala Lens
Julien Truffaut
 
The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181
Mahmoud Samir Fayed
 
Snake report ROHIT MALAV
Snake report ROHIT MALAVSnake report ROHIT MALAV
Snake report ROHIT MALAV
Rohit malav
 

What's hot (20)

The Ring programming language version 1.2 book - Part 35 of 84
The Ring programming language version 1.2 book - Part 35 of 84The Ring programming language version 1.2 book - Part 35 of 84
The Ring programming language version 1.2 book - Part 35 of 84
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180
 
pptuni1
pptuni1pptuni1
pptuni1
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
Александр Зимин – Анимация как средство самовыражения
Александр Зимин – Анимация как средство самовыраженияАлександр Зимин – Анимация как средство самовыражения
Александр Зимин – Анимация как средство самовыражения
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
ES6(ES2015) is beautiful
ES6(ES2015) is beautifulES6(ES2015) is beautiful
ES6(ES2015) is beautiful
 
λ | Lenses
λ | Lensesλ | Lenses
λ | Lenses
 
Proga 0622
Proga 0622Proga 0622
Proga 0622
 
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Expand/Collapse animation on Android
Expand/Collapse animation on AndroidExpand/Collapse animation on Android
Expand/Collapse animation on Android
 
Beyond Scala Lens
Beyond Scala LensBeyond Scala Lens
Beyond Scala Lens
 
The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.8 book - Part 56 of 202
 
The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181
 
Snake report ROHIT MALAV
Snake report ROHIT MALAVSnake report ROHIT MALAV
Snake report ROHIT MALAV
 

Similar to Introduction to Game Programming Tutorial

You are task to add a yawning detection to the programme below;i.pdf
You are task to add a yawning detection to the programme below;i.pdfYou are task to add a yawning detection to the programme below;i.pdf
You are task to add a yawning detection to the programme below;i.pdf
sales223546
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..
Dr. Volkan OBAN
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3
Jay Coskey
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
Baruch Sadogursky
 
Creating an Uber Clone - Part IV.pdf
Creating an Uber Clone - Part IV.pdfCreating an Uber Clone - Part IV.pdf
Creating an Uber Clone - Part IV.pdf
ShaiAlmog1
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docxcirc.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
christinemaritza
 
Python From Scratch (1).pdf
Python From Scratch  (1).pdfPython From Scratch  (1).pdf
Python From Scratch (1).pdf
NeerajChauhan697157
 
Class Customization and Better Code
Class Customization and Better CodeClass Customization and Better Code
Class Customization and Better CodeStronnics
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
arihantmobileselepun
 
Game dev 101 part 3
Game dev 101 part 3Game dev 101 part 3
Game dev 101 part 3
Christoffer Noring
 
Creating an Uber Clone - Part XXII.pdf
Creating an Uber Clone - Part XXII.pdfCreating an Uber Clone - Part XXII.pdf
Creating an Uber Clone - Part XXII.pdf
ShaiAlmog1
 
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...Revolution Analytics
 
The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.10 book - Part 64 of 212The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.10 book - Part 64 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.7 book - Part 57 of 196The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.7 book - Part 57 of 196
Mahmoud Samir Fayed
 
Supstat nyc subway
Supstat nyc subwaySupstat nyc subway
Supstat nyc subway
Vivian S. Zhang
 
xy2.5 3.0 3.5-1.0 6 7 81.0 0 1 23.0 -6 -5 .docx
xy2.5 3.0 3.5-1.0 6 7 81.0 0 1 23.0 -6 -5 .docxxy2.5 3.0 3.5-1.0 6 7 81.0 0 1 23.0 -6 -5 .docx
xy2.5 3.0 3.5-1.0 6 7 81.0 0 1 23.0 -6 -5 .docx
ericbrooks84875
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
Dr. Volkan OBAN
 

Similar to Introduction to Game Programming Tutorial (20)

My favorite slides
My favorite slidesMy favorite slides
My favorite slides
 
You are task to add a yawning detection to the programme below;i.pdf
You are task to add a yawning detection to the programme below;i.pdfYou are task to add a yawning detection to the programme below;i.pdf
You are task to add a yawning detection to the programme below;i.pdf
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 
Creating an Uber Clone - Part IV.pdf
Creating an Uber Clone - Part IV.pdfCreating an Uber Clone - Part IV.pdf
Creating an Uber Clone - Part IV.pdf
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docxcirc.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
 
Python From Scratch (1).pdf
Python From Scratch  (1).pdfPython From Scratch  (1).pdf
Python From Scratch (1).pdf
 
Class Customization and Better Code
Class Customization and Better CodeClass Customization and Better Code
Class Customization and Better Code
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
 
Game dev 101 part 3
Game dev 101 part 3Game dev 101 part 3
Game dev 101 part 3
 
Creating an Uber Clone - Part XXII.pdf
Creating an Uber Clone - Part XXII.pdfCreating an Uber Clone - Part XXII.pdf
Creating an Uber Clone - Part XXII.pdf
 
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
 
The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.10 book - Part 64 of 212The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.10 book - Part 64 of 212
 
The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.7 book - Part 57 of 196The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.7 book - Part 57 of 196
 
Supstat nyc subway
Supstat nyc subwaySupstat nyc subway
Supstat nyc subway
 
xy2.5 3.0 3.5-1.0 6 7 81.0 0 1 23.0 -6 -5 .docx
xy2.5 3.0 3.5-1.0 6 7 81.0 0 1 23.0 -6 -5 .docxxy2.5 3.0 3.5-1.0 6 7 81.0 0 1 23.0 -6 -5 .docx
xy2.5 3.0 3.5-1.0 6 7 81.0 0 1 23.0 -6 -5 .docx
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 

More from Richard Jones

Angboard
AngboardAngboard
Angboard
Richard Jones
 
Don't do this
Don't do thisDon't do this
Don't do this
Richard Jones
 
Introduction to Game Programming
Introduction to Game ProgrammingIntroduction to Game Programming
Introduction to Game Programming
Richard Jones
 
Message Queueing - by an MQ noob
Message Queueing - by an MQ noobMessage Queueing - by an MQ noob
Message Queueing - by an MQ noob
Richard Jones
 
Web micro-framework BATTLE!
Web micro-framework BATTLE!Web micro-framework BATTLE!
Web micro-framework BATTLE!
Richard Jones
 
State of Python (2010)
State of Python (2010)State of Python (2010)
State of Python (2010)
Richard Jones
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6
Richard Jones
 
What's New In Python 2.5
What's New In Python 2.5What's New In Python 2.5
What's New In Python 2.5
Richard Jones
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4
Richard Jones
 
Tkinter Does Not Suck
Tkinter Does Not SuckTkinter Does Not Suck
Tkinter Does Not Suck
Richard Jones
 

More from Richard Jones (11)

Angboard
AngboardAngboard
Angboard
 
Don't do this
Don't do thisDon't do this
Don't do this
 
Introduction to Game Programming
Introduction to Game ProgrammingIntroduction to Game Programming
Introduction to Game Programming
 
Message Queueing - by an MQ noob
Message Queueing - by an MQ noobMessage Queueing - by an MQ noob
Message Queueing - by an MQ noob
 
Message queueing
Message queueingMessage queueing
Message queueing
 
Web micro-framework BATTLE!
Web micro-framework BATTLE!Web micro-framework BATTLE!
Web micro-framework BATTLE!
 
State of Python (2010)
State of Python (2010)State of Python (2010)
State of Python (2010)
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6
 
What's New In Python 2.5
What's New In Python 2.5What's New In Python 2.5
What's New In Python 2.5
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4
 
Tkinter Does Not Suck
Tkinter Does Not SuckTkinter Does Not Suck
Tkinter Does Not Suck
 

Recently uploaded

UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 

Recently uploaded (20)

UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 

Introduction to Game Programming Tutorial

  • 1. Game Programming LCA 2010 Richard Jones
  • 2. The Basics • Displaying something • Controlling animation • User input • Gameplay mechanics • Playing sound effects and music • Further stuff
  • 3. Displaying Something • Opening a window • Reading images • Displaying images
  • 4. Controlling Animation • Image position on screen • Updates over time • Accounting for frame rate
  • 5. User Input • Getting events • Distinct keyboard events vs. keyboard state
  • 6. Gameplay Mechanics • Interaction of game objects • Detecting important events (game won or game over)
  • 7. Detecting Collisions • Pixel-Perfect • Axis-Aligned Bounding Box • Circle-Circle • Hash Map
  • 8. Sound • Reading sound files • Playing sounds and background music
  • 9. Opening a Window import pyglet w = pyglet.window.Window() pyglet.app.run()
  • 10. Clearing the Window import pyglet w = pyglet.window.Window() @w.event def on_draw(): w.clear() pyglet.app.run()
  • 11. Drawing import pyglet w = pyglet.window.Window() ship_image = pyglet.image.load('data/ship.png') @w.event def on_draw(): w.clear() ship_image.blit(100, 100) pyglet.app.run()
  • 12. Better Drawing import pyglet w = pyglet.window.Window() ship_image = pyglet.image.load('data/ship.png') ship = pyglet.sprite.Sprite(ship_image) ship.position = (100, 100) @w.event def on_draw(): w.clear() ship_image.blit(100, 100) ship.draw() pyglet.app.run()
  • 13. Animation ... w.clear() ship.draw() def update(dt): ship.x += 1 pyglet.clock.schedule_interval(update, 1./30) pyglet.app.run()
  • 14. Better Animation ... w.clear() ship.draw() def update(dt): ship.x += 1 ship.x += 100 * dt pyglet.clock.schedule_interval(update, 1./30) pyglet.app.run()
  • 15. Adding Asteroids import random import pyglet w = pyglet.window.Window() def center_anchor(img): img.anchor_x = img.width / 2 img.anchor_y = img.height / 2 ...
  • 16. Adding Asteroids ... ship_image = pyglet.image.load('data/ship.png') center_anchor(ship_image) ship = pyglet.sprite.Sprite(ship_image) ship.position = (100, 100) big_asteroid_image = pyglet.image.load('data/big_asteroid.png') center_anchor(big_asteroid_image) asteroids = [] for i in range(3): x = random.randint(0, w.width) y = random.randint(0, w.height) s = pyglet.sprite.Sprite(big_asteroid_image, x, y) s.dx = random.randint(-100, 100) s.dy = random.randint(-100, 100) asteroids.append(s) @w.event ...
  • 17. Adding Asteroids ... @w.event def on_draw(): w.clear() for asteroid in asteroids: asteroid.draw() ship.draw() ...
  • 18. Adding Asteroids ... def update(dt): ship.x += 100 * dt for asteroid in asteroids: asteroid.x += asteroid.dx*dt asteroid.y += asteroid.dy*dt ...
  • 19. A Little Refactoring ... ship = pyglet.sprite.Sprite(ship_image) ship.position = (100, 100) ship.dx = 100 ship.dy = 0 ...
  • 20. Screen Wrapping ... def update(dt): ship.x += 100 * dt for asteroid in asteroids: asteroid.x += asteroid.dx*dt asteroid.y += asteroid.dy*dt for a in asteroids + [ship]: a.x += a.dx*dt a.y += a.dy*dt if a.x - a.width/2 > w.width: a.x -= w.width + a.width elif a.x + a.width/2 < 0: a.x += w.width + a.width if a.y - a.height/2 > w.height: a.y -= w.height + a.height elif a.y + a.height/2 < 0: a.y += w.height + a.height ...
  • 21. Control import math import random import pyglet w = pyglet.window.Window() ...
  • 22. Control ... keys = pyglet.window.key.KeyStateHandler() w.push_handlers(keys) def update(dt): if keys[pyglet.window.key.LEFT]: ship.rotation -= 360*dt if keys[pyglet.window.key.RIGHT]: ship.rotation += 360*dt rotation = math.radians(ship.rotation) rotation_x = math.cos(-rotation) rotation_y = math.sin(-rotation) if keys[pyglet.window.key.UP]: ship.dx += 200 * rotation_x * dt ship.dy += 200 * rotation_y * dt for a in asteroids + [ship]: ...
  • 23. Rotation ... ship = pyglet.sprite.Sprite(ship_image) ship.position = (100, 100) ship.dx = 100 ship.dy = 0 ship.position = (w.width/2, w.height/2) ship.dx = ship.dy = ship.dr = 0 ...
  • 24. Rotation ... s = pyglet.sprite.Sprite(big_asteroid_image, x, y) s.dx = random.randint(-100, 100) s.dy = random.randint(-100, 100) s.dr = random.randint(-100, 100) asteroids.append(s) ...
  • 25. Rotation ... def update(dt): if keys[pyglet.window.key.LEFT]: ship.rotation -= 360*dt if keys[pyglet.window.key.RIGHT]: ship.rotation += 360*dt ship.dr = (keys[pyglet.window.key.RIGHT] - keys[pyglet.window.key.LEFT]) * 360 rotation = math.pi * ship.rotation / 180.0 ... for a in asteroids + [ship]: a.x += a.dx*dt a.y += a.dy*dt a.rotation += a.dr * dt if a.x - a.width/2 > w.width: a.x -= w.width + a.width
  • 31. Collision Detection import sys import math import random import pyglet w = pyglet.window.Window() ...
  • 32. Collision Detection ... w.push_handlers(keys) def distance(a, b): return math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2) def update(dt): ...
  • 33. Collision Detection ... elif a.y + a.height/2 < 0: a.y += w.height + a.height for a in asteroids: if distance(a, ship) < (a.width/2 + ship.width/2): sys.exit('GAME OVER') pyglet.clock.schedule_interval(update, 1./30) ...
  • 34. Shooting ship.position = (w.width/2, w.height/2) ship.dx = ship.dy = ship.dr = 0 ship.gun_cooldown = 0 bullet_image = pyglet.image.load('data/bullet.png') center_anchor(bullet_image) bullets = [] ...
  • 35. ... Shooting ship.dy += 200 * rotation_y * dt if ship.gun_cooldown: ship.gun_cooldown = max(0, ship.gun_cooldown - dt) elif keys[pyglet.window.key.SPACE] and len(bullets) < 2: b = pyglet.sprite.Sprite(bullet_image, ship.x, ship.y) b.dx = rotation_x * 500 b.dy = rotation_y * 500 b.dr = 0 b.life = 1 bullets.append(b) ship.gun_cooldown = .5 for b in list(bullets): b.life -= dt if b.life < 0: bullets.remove(b) for a in asteroids + [ship]: for a in asteroids + [ship] + bullets: a.x += a.dx*dt ...
  • 36. Shooting ... @w.event def on_draw(): w.clear() for asteroid in asteroids: asteroid.draw() for s in asteroids + bullets: s.draw() ship.draw() ...
  • 37. Shooting ... and Hitting ... def distance(a, b): return math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2) def collide(a, b): return distance(a, b) < (a.width/2 + b.width/2) ...
  • 38. Shooting ... and Hitting ... elif a.y + a.height/2 < 0: a.y += w.height + a.height for a in asteroids: if distance(a, ship) < (a.width/2 + ship.width/2): sys.exit('GAME OVER') for a in list(asteroids): if collide(a, ship): sys.exit('GAME OVER') for b in list(bullets): if collide(a, b): bullets.remove(b) asteroids.remove(a) if not asteroids: sys.exit('YOU WIN') pyglet.clock.schedule_interval(update, 1./30) ...
  • 39. Chunks ... center_anchor(bullet_image) bullets = [] small_asteroid_image = pyglet.image.load('data/small_asteroid.png') center_anchor(small_asteroid_image) medium_asteroid_image = pyglet.image.load('data/medium_asteroid.png') center_anchor(medium_asteroid_image) big_asteroid_image = pyglet.image.load('data/big_asteroid.png') center_anchor(big_asteroid_image) ...
  • 40. ... Chunks for b in list(bullets): if collide(a, b): bullets.remove(b) asteroids.remove(a) if a.image is big_asteroid_image.texture: for i in range(2): s = pyglet.sprite.Sprite(medium_asteroid_image, a.x, a.y) s.dx = a.dx + random.randint(-50, 50) s.dy = a.dy + random.randint(-50, 50) s.dr = a.dr + random.randint(-50, 50) asteroids.append(s) elif a.image is medium_asteroid_image.texture: for i in range(2): s = pyglet.sprite.Sprite(small_asteroid_image, a.x, a.y) s.dx = a.dx + random.randint(-50, 50) s.dy = a.dy + random.randint(-50, 50) s.dr = a.dr + random.randint(-50, 50) asteroids.append(s) if not asteroids: sys.exit('YOU WIN') ...
  • 41. Sound Effects ... asteroids.append(s) explosion_sound = pyglet.media.load('data/explosion.wav', streaming=False) bullet_sound = pyglet.media.load('data/bullet.wav', streaming=False) @w.event def on_draw(): ...
  • 42. Sound Effects ... bullets.append(b) ship.gun_cooldown = .5 bullet_sound.play() for b in list(bullets): ...
  • 44. Further Stuff • Opening screen • Options menu • Game won / game over screen • Special effects
  • 45. Other screen / menu • Use libraries like Cocos2d (Scenes, Layers, Sprites, Animations)
  • 46. Special Effects • Simple image animations • Use libraries like lepton
  • 47. Where To From Here? • http://pyglet.org • http://pygame.org • http://los-cocos.org • http://inventwithpython.com/ • http://pyweek.org

Editor's Notes

  1. r1
  2. r2
  3. r3
  4. r4
  5. r5
  6. r6
  7. r7
  8. r8
  9. r9
  10. r10
  11. r11
  12. r12
  13. r13
  14. r15
  15. asteroids-cocos.py