Welcome to the second of a multi-part series:  
Creating Animation and Games: Chapter 2 Game Controllers

This series will dive into using Propeller microcontroller based systems to create your own graphics, animation, and video games.  I'll assume that you only have a very basic knowledge of microcontroller programming and take you step-by-step from beginning with a single dot to the creation of several video games which will provide you great examples for getting started with your own ideas.

If you haven't read the previous chapter, go back and review it first with the link above then continue with this Chapter.

In the last chapter we introduced you to a few hardware options, introduced you to the Spin programming language, the Propeller Tool, and got you started working with the basics of the SLUG video driver for the Propeller.

This time we are going to take a look at game controllers and how to implement them into your game creation.   Specifically, we'll be using the Wii controller connection (found on Propellerpowered VGAplus, VGAplus256, and Quickplayer Extreme products) and the PS/2 Keyboard. (found on VGAplus, Parallax Demoboard, and Human Interface Board)   The game controller driver we are using actually supports several other possible controllers including NES, Parallax C3 NES, and N64 controllers without changing more than a single line of code, 

By the end of this chapter, you should have a better understand of several Spin programming concepts as well establish the beginning of a simple game.

Let's jump right in!

First download the source code for this Chapter and extract it to a new empty folder.   We'll be working from that folder.

Step 1: Introducing MIGS: Multi Interface Game-control Standard

The Propeller has a very well developed collection of controller possibilities when considering a controller to control your video game.  Over the years several different board designs have surfaced which incorporate NES, Mouse, Keyboard, Wii Controller, and more.   Object possibilities literally span from everything from IR based control to SNES control depending on which software you wish to incorporate in your hardware/software design.  

Writing video games is fun.  Sharing them with others increases the fun ten fold!
The problem is how to do you share a game that you wrote to use a NES controller when someone else is using a Wii Classic controller?

Introducing M.I.G.S.  Multi Interface Game control Standard.

MIGS is a collection of several common game controller object which have been minimized to work interchangeably in your video game.
If you have only have a keyboard to work with, someone else with only an NES controller can still give your program a whirl by changing only two lines of code in your program.   

MIGS supports:
  • Nintendo NES Controllers
  • Nintendo NES Controllers for the C3
  • Nintendo 64 Controllers
  • PS/2 Keyboard
  • Nintendo Wii Classic/Pro & Nunchuck
Several of the files you extracted from this Chapter's archive include all of the drivers for MIGS.   Simply include the files in your program when you distribute your video game.

Files to include in your game archive:
  • migs_nes.spin
  • migs_nesc3.spin
  • migs_n64.spin
  • migs_keyboard.spin
  • migs_wiiclassic.spin
  • i2cObject.spin
I'll get into how to implement these in the next pages.

About This Instructable




More by Propellerpowered:Sprites & Graphics On the Micromite Companion Using the ESP8266 module Building your own Micromite Companion Minicomputer 
Add instructable to: