Learning to Program with Pyglet
How do we learn?
This talk focuses on two major ways people learn to program:
Building-Block Learning and Explorative Learning
print("Hello World")
Learning from Building Blocks
What I think of for traditional class-room/tutorial type teaching. The student learns the basics of:
- variables
- data structures
- control structures
- design patterns
And along the way students build
cool stuff and become programming gurus
Explorative Learning
(main take-away for this talk)
Explorative learning is what I think of when a student gets something functioning and tinkers to learn how it works
Explorative Learning
My love of programming grew out of exploration
case: I started really programming by
modifying SPECTRE (Fortan77), software used for astronomy
case: I also learned by taking html/css and modifying pieces until it looked how I wanted
case: How about you?
(queue audience interaction)
Explorative Learning
Benefits of this type of learning include:
- seeing a working example
- the ability can focus on structure
- different way to learn relationships of the building-blocks
- learn about another developer's thought process and creativity
With Explorative Learning in mind
let's talk about Pyglet
What is Pyglet?
Pyglet is a python interface for creating games across Microsoft Windows, Mac OS X, and Linux using OpenGL
- renders graphics
- plays sounds
- controls game update loop
- handles sprite/object interactions
- handles signals from keyboard/mouse
Why Pyglet?
Library choices for making games in python:
I chose pyglet for this tutorial because it is easy to get running and I wanted to increase the number of examples for it
I started a git repo of simple games using pyglet
It contains working projects which can be explored and also spun off into their own repos
|- pyglet_projects/
|- README.md
|- spinoff_projects.md
|- projects/
|- asteroids/
|- mind_sweeper_basic/
|- snake_with_basic/
Pyglet Projects: Snake
I implemented a version of the classic game: snake
cd projects/snake_basic
python3 run.py
Step 1 of exploration is to just see what it does and how it behaves
Step 2 is to open it up and tinker
(show and tell time)
Pyglet Projects: Snake
Step 1 of exploration is to just see what it does and how it behaves
Step 2 is to open it up and tinker
Modification examples:
- changing colors
- change game speed
- change board size
- make snake invincible
- can I make the snake go diagonal?
Pyglet Projects: Mine-sweeper
Step 1 of exploration is to just see what it does and how it behaves
Step 2 is to open it up and tinker
Modification examples:
- changing colors
- show all bombs
Pyglet Projects: Asteroids
Step 1 of exploration is to just see what it does and how it behaves
Step 2 is to open it up and tinker
Modification examples:
- Rapid fire mode
- Asteroid rotation speed
- Add sounds
Take Aways
Explorative learning should accompany building-blocks learning for when teaching programming
Pyglet projects is an explorative learning resource for both students and teachers
Thank You!
Explorative learning should accompany building-blocks learning for when teaching programming
Pyglet projects is an explorative learning resource for both students and teachers
Dylan Gregersen
Learning to Program with Pyglet
By astrodsg
Learning to Program with Pyglet
Explorative learning is a key method people learn to program. This talk show cases projects developed with the python package pyglet and how they can be used for exploration.
- 1,003