One of our members Marie made a beautiful painting of Lightning from Final Fantasy XIII. Sadly when Marie moved away from Philly to pursue her programming career her painting got lost in the abyss that is the Hive76 utility closet. Luckily her painting resurface and is now on display for everyone to appreciate.
Early in my gameplay in Minecraft I began making redstone contraptions. For those that don’t know Minecraft, you can use resources in the game to make analog electronics. People have extended this feature to build entire working computers all in redstone logic in Minecraft.
I only used redstone to make traps and novel machines, but the strong connection between redstone and electronics led me to imagine extending these machines out into the real world. I figured the easiest thing to make was the Redstone Lamp, pictured to the right. The redstone lamp is a block that will provide light when powered. My real life replica redstone lamp does the same thing. It lights up when a redstone lamp ingame is lit up. Here is a video of how it works:
I’ll describe how I got to a working replica in a few stages.
I am not the best getting started with software projects, so I enlisted the help of Vince who was hanging out a bunch at Hive76. We made a quick prototype with a python Minecraft client called pyCraft, an Arduino, and transistor, and a papercraft redstone lamp. You can see that first success here.
While I worked on the physical stuff, Vince moved away and Kyle Yankanich stepped in to help me finalize some stuff. PyCraft connects to any server as a simple chat client, in our case as the user LAMPBOT. Kyle wrote a plugin for pyCraft that listens for a whisper of “on” or “off” and sets pin 16 on the Raspberry Pi’s GPIO high or low respectively. You can download my fork of pyCraft here with Kyle’s plugin and my shell script to start the client. I set my home server to Offline mode so that I wouldn’t need to purchase another Minecraft account.
For the replica, I did my best to turn pixels into straight lines. I designed a laser-cuttable box in six parts with finger joints on the edges. I used 16 finger joints because the a block is 16 pixels wide. The material is MDF with a zebra wood veneer laminated on top. I laser cut six sides and glued all but one together. I acquired some amber cathedral glass from Warner Stained Glass, cut, and glued it in place with silicone adhesive. The RPi is attached to a MDF board sitting diagonally in the cube. The LEDs were torn from inside a failbot and glued around the RPi to light up the inside as much as possible.
In order to turn the LEDs on and off, we use the signal from the RPi GPIO to control an NPN transistor and turn the lights on and off. There is a fritzing wiring diagram of the electronics here. On the NPN transistor, the Collector is the negative lead from the LEDs, the Base is connected to a 100KΩ resistor and then pin 16, and the Emitter goes to the ground on the LED power supply.
There’s no room for a power regulator, so there are two power sources and ethernet running through a hole in the back.
To trigger the lamp, command blocks are used ingame as you can see to the left. When a lever is thrown powering a specific redstone lamp, we also power a command block that sends the server command: /tell LAMPBOT on
We also send the inverted signal to a different command block that outputs: /tell LAMPBOT off
This can be used on any server with no mods. You would need a Minecraft account for the lamp so you don’t expose your server to cracked clients. The server this was designed for runs Minecraft 1.6.4 now, but in 1.7.2 the /testforblock command and a clock could also trigger the lamp.
I really hope you take what we have done here and continue to connect your Minecraft creations to the real world. Enjoy!
It didn’t take me and Robert long to find an RGB LED pushbutton. I composed a short part number using the NKK data sheet and found a KP0215ASBKG03RGB-2SJB. I made a simple perf board shield with the proper resistors for my Arduino Mega 1280 and re-learned Arduino to light it up.
It’s a vidya game but not! A completely audio-based game, the objective is to use sonar to find the hidden submarine and destroy it with depth charges. But be careful! If you are not close enough to hit the submarine, it will get away and you must hunt it down again.
Got an Arduino Mega2560 on the innards side. Got the joystick and arcade buttons from Ada Fruit! Very nice quality, shipped very quickly, and not too expensive to boot. Box was just a little, prefab wooden deal from a craft store somewhere in the middle of nowhere. And the speakers, I think I pried them out of a few alarm clocks.
Okay, so I’m going to switch over to a very simple format, with very short examples of how you do certain things. The long article format is just too much for everyone to digest and takes too much time for me to write, so I tend to put it off forever.
Types of Games
Most games fall into two patterns: turn-driven or time-driven.
Turn-driven games have distinct periods where user input is taken, then periods where game updates are made, and the two do not overlap in anyway. The user-input section waits for the user to make their choice, and the user then waits for the update section to finish before they take their next turn. Many puzzle games and most board games are going to be of this type. For example, in chess with an AI player, the game waits for the player to move a white piece. Once the player moves, the AI takes over and calculates a move for a black piece, during which time the player is stuck and cannot make any moves. Once the AI has moved the a black piece, it’s up to the player to make a move decision again, and the AI cannot progress until the user has decided.
Time-driven games work completely differently. They are constantly updating the game, never waiting for the user to first make a selection or hit a button or waggle their joystick. If a user does perform some kind of input, the input is not processed separately, it is taken into account for the next update. Think of a game of Asteroids, in which the big, giant rocks float around the screen all on their own until the user decides to turn her ship and blast them.
There is actually a third class of game called alternate-reality games (ARG) that do not really update and do not really take user input–not in the same way these other games do–but they are way outside of the scope of this project. ARGs are more literature projects than programming projects.
Turn-driven games are relatively simple to create, as the user drives everything and performance issues do not cause noticeable artifacts like frame-rate stutter or audio clipping and buzzing. When we get into handling user input, you’ll learn all you need to make turn-driven games. Actually, time-driven games turn out to have many of the same features as turn-driven games, just with the additional features of not waiting around for the user first, having its own pump to drive the game forward.
We will be focusing on time-driven games, as they are the most technically challenging.
I know I certainly had a really fun time last night with everyone.
To recap, we did a walk through the Pong example (play it here, or read the code here) and saw a lot of things that are common to games programming. We looked at some ways that simple changes to specific values can have a huge impact on the look and feel of the game. We discussed the discovery process of programming and how integral the act of testing is to finding good gameplay elements. And we discussed some tools and habits that are good to learn to be a more effective programmer.
I want to get everyone started with playing with code as quickly as possible now. The more you do, the more you will learn. There have been tons of times in my career that I’ve pontificated on how to do something with no good result coming from mere speculation, only to be able to figure it out within minutes by just trying it. So with that in mind:
Wow, these things are selling a lot faster than I expected. There is still a week left and most of the tickets are gone. If you’re still interested, you should hurry and buy one to secure your place. If you are interested but can’t make it to Monday, August 6th, leave a comment on what dates would work better as I’m looking to have an alternate class schedule as well.
A few questions came up in the last post, so here are some answers summarized for anyone who doesn’t read blog-post comments.
What time is the class? The class starts at 7pm on Monday, August 6th, 2012.
Is there anything we should have/know before the class? You’ll need your own laptop computer, we don’t have enough public computers to go around at Hive. I will briefly cover some options for text editors in a blog post or at the beginning of the class, but if you already have a favorite text editor like Notepad++, Gvim, or TextMate, then by all means use that. Also, it would be advantageous for you to setup some sort of webspace. There are some free places like 110mb.com, or you could even use the Public folder if you have a Dropbox account, which is quite convenient.
Why not do <insert language> instead? That’s a really big question…