Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Sunday, August 25, 2013

Match Game Lesson, Lists and Dictionaries


New lesson on a match game with lists and dictionaries.

The code for this lesson is available on bit bucket here.


Saturday, March 30, 2013

Lesson #4: Mouse and Touchscreen Control (taught by middle school student)



Middle school student, age 13, teaches you how to get mouse control working on the moving square.
  • Goes through event queue to check for the mouse button. event.type == MOUSEBUTTONDOWN:
  • Checks for point collision with a rectangle: collidepoint(mouse_pos)

Monday, March 18, 2013

Lesson #3 - The Moving Square





Lesson number three teaches movement in the Y axis.

The main concepts:
  • Add 1 to the y axis to move down;
  • Subtract 1 to the y axis to move up;
  • Bounds checking to detect when the square reaches the edge of the screen;
  • Conditional to change direction;
  • Clock to set the maximum Frames Per Second (FPS) that the game runs at


Lesson #2 - The Stationary Square


This lesson focuses on drawing a stationary red square.  

Main concepts:
  • Colors are set by a three number tuple (red, green, blue).  Each value ranges from 0 to 255
  • Each point on the phone screen has two numbers associated with it, the x and the y coordinate.  A single point is a pixel.  The phone screen is 480 pixels wide and 320 pixels high.
  • The rectangle is initially set by the upper left corner.  The example uses (0, 0).
  • The width and height of the rectangle are measured in pixels, 64 pixels wide and 64 pixels tall.

Bonus concepts:
  • Graphics such as a cartoon girl are loaded with image.load("filename");
  • The graphic is displayed on the phone screen with blit;
  • The position of the graphic on the screen is established with a rectangle.


Lesson #1 - The Blank Screen



This is the first lesson in the Python and Pygame series.   It teaches the blank screen.   It is the basic foundation of all games.  This requires Python, Pygame, and a text editor.

This lesson was designed for middle school students.

Main concepts:

  1. Load and initialize the Pygame library;
  2. Set the size of the main screen;
  3. Create an infinite loop that runs the game until the player quits the game;
  4. Process the event queue;
  5. Handle the QUIT event;
  6. Update the screen.