Introduction: Fun Game With Arduino and Processing

This tutorial will show you how to make a first person FPS-shooter in Processing with the help of an arduino. This project was handed to us as a final exam in a technical specialization course, (upper secondary school).

Video of the project! :) (Hard to play with one hand)

The purpose of this project was to make a game in processing, and make it able to talk to arduino and make a handheld controller out of it.

link codes and files :)

Step 1: Step 1: Components Needed

1. An Arduino of your choice, in this case an Ardiuino UNO
2. A momentary button
3. An analog thumbstick usable with arduino

Step 2: Step 2: Wire the Hardware and Initiate Serial Communication

First we plug our thumbstick in to the analog ports on the arduino, since a thumbstick consists out of transistors we will recieve analog values. The plug in your push button in a digital port. We will then be able to send these values from arduino to processing via the serial port with the following code.

http://pastebin.com/3TEYnn97

To use this code you have to have the Arduino IDE installed to initiate the communication

Step 3: Step 3: Writing the Game

Okay, now its time to write the code for the game:

The game is written in processing, and you will therefore have to download the Processing IDE for it to work.

To make it easy for us we divide the game in to three different classes: Main, Menu, and Game. We write the code this way to make it simpler for us to switch between the menu and the game. And to not terrorize you with a bunch of code; here are links to the different classes.

Main: http://pastebin.com/YW7kE91A
Menu: http://pastebin.com/t7x6dfxR
Game: http://pastebin.com/4zJSgjmd

To use the code we will have to import some libraries.
- gifAnimation: for the gifs to work
- ddf.minim: to play sounds (this is usually included in processing)
- processing.serial: to make processing able to use the serial port.

We used some self made sprites for the game, except for the bird, which is taken from the game "Flappy Bird".

*Copyright infringement not intended, all rights to the rightful owners of Flappy Bird*

Step 4: Step 4: Building the Project

After making sure that the game works with the arduino, it's time to build the projects body.
We used ourself of a cardbord box with the dimensions 20cm x 10cm x 3cm (approximately).

We made sure that all of our components fitted, and then we stuck them in place using tape. Unfortunantly we didnt photograph the process of building it, so I'm trying to explain with these images.

The 2nd picture is a ghostimage of how we fitted the arduino in the box.

After we stuck the components in place, we closed our cardbord box with some hot glue, then taped the box shut with some electrical tape to make the box sturdier and feel more authentic.

Step 5: Step 5: Play the Game and Brag to Your Friends

Now you're done! It's time to invite some friends over to try to beat eachothers' highscores! Congratulations and have fun! :)

Comments

author
body_pixel (author)2015-04-13

did everything but there are no graphics anymore on this link link codes and files :)

Please, could you share it again. Thanks, best

author
craftclarity (author)2014-05-27

Looks like fun!

About This Instructable

4,292views

17favorites

More by 95dape52:Fun game with arduino and processing
Add instructable to: