Firewall

Wednesday, April 14, 2010


Wow! Unity is just amazing. Sean McDonald modeled the sidewinder missile used in this game. Firewall was inspired by Unity's free Detonator Library. I got the metal texture for the blocks from desizntech.info. Which brings me to my next point, Unity makes mip and bump mapping a snap! Drag a texture onto a 3D asset, then click on the image in your library and click generate bump map...done! The UI even has a slider to control mip mapping and shininess of the bump mapping.

Firewall uses a lot of object oriented C# scripting for each gameObject. It's very easy to get things to work once you understand Vector3s and Quaternions. What's the hardest part? Any GUI or HUD work is really just a pain!

The levels in Firewall are XML driven, you can sneak a peak from my levels.xml document.
Each level is made up of a node, where each | represents the end of a line and each number is a stack of cubes.
...........|
...45554...|
...........|
...........|
...........|
...........|
...........|

Functionality:
Getting the missile to shoot at the mouse, but take on the cameras transform:

GameObject rocket = Instantiate(Resources.Load("Rocket")) as GameObject;
rocket.rigidbody.transform.position = camera.transform.position;
rocket.rigidbody.transform.rotation = Quaternion.LookRotation(Camera.main.ScreenPointToRay(Input.mousePosition).direction);
rocket.rigidbody.velocity = transform.TransformDirection(new Vector3(r.direction.x * 50, r.direction.y * 50, r.direction.z * 50));


Getting the 3D object that is under the mouse, to turn red. Also referencing variables in a dynamic prefab's class:

//raycast directly under the mouse for a distance of 100, return the first object that is hit.
Ray r = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;

//if the ray hit an object, parse it as a Cube (Cube is the .cs class for the block prefab) and selected is a public bool.
if(Physics.Raycast(r, out hit, 100))
(hit.collider.gameObject.GetComponent("Cube") as Cube).selected = true;

//inside of Cube.cs on update we have the following:
rigidbody.renderer.material.color = selected ? Color.red : Color.white;

Shark Attack Island

Tuesday, April 6, 2010


My first experiments with Unity3D revealed that it is extremely easy to get a 3D scene set up and running. Texturing 3D objects is as easy as drag and drop. Need a first person shooter control? Just drag and drop the fps walker prefab into your scene and tweak the variables! Sean McDonald did all the 3D modeling for this (except for the palm trees, those were Unity default materials). We found that Unity was able to import .3ds, .dae, and .fbx and even .ma and .mb if you have Maya installed on the same computer that Unity is on.

Current known bugs: Sharks swim through the island.
Please feel free to submit bugs.

I scripted the games animations through C#.
Ocean Movement:


Shark Movement


Player Throws Coconut at Mouse



For the explosions I used http://unity3d.com/support/resources/unity-extensions/explosion-framework

Socket Server/Client Chat

Monday, March 1, 2010


I've written a Socket Server in C# and a Socket Client in Actionscript 3.0
What you see in this picture is a server interface in the middle that logs server start, client connections and disconnections.
It uses TCP traffic to a central server that relays messages to all clients currently connected to it. It acts as a chat program, but can be used to interface Adobe Flash and Microsoft .Net together! Using this concept, one could even make a Flash network game. Although the server app must be run on a Windows platform, the flash chat client works both on Windows and Macintosh. If anyone would like some code samples, please inquire.

Valentines Day

Tuesday, February 2, 2010

I'm a total nerd. I made this for my fiancée as fun way to find out where we are going to Valentines Day.
She has to unscramble four pictures one at a time. The four pictures are a Saint Helmet, Elmo, a plate with 2 steaks on it and House (the Dr. on the TV show). So you put them all together?
St. Elmo's Steak House!

I made all the graphics myself, given that I'm just a programmer I'd say I'm getting a little bit better.

I wrote a cool little class that animates the instructions dynamic text field. (in the top left hand corner)

Hexart

Here's what it looks like.
What is it? I've create a site where you upload any image you want and it goes through one block of pixels at a time, evaluating each blocks median color hex code and prints that value to screen. You can adjust the font size and the font density. Go ahead give it a try!

Here's some code for ya!

I wrote this bitmap slicer class. It works really well, just pass it a bitmap and how many slices you want to slice it into. Each slice is the same aspect ratio of the original image. The parameter "pieces" is the square root of the total squares that there will be. The more square, the more memory is use.

public static function Slice(origBitmap:Bitmap, pieces:int):Array{
var BitmapArray:Array = new Array();

var recX:Number = 0;
var recY:Number = 0;
var recW:Number;
var recH:Number;
var aspctRatio:Number;
var destBitmap:Bitmap;
var totalSquares:Number;

if(origBitmap.height > origBitmap.width){
aspctRatio = origBitmap.width/origBitmap.height;
recH = Math.floor(origBitmap.height/pieces);
recW = Math.floor((origBitmap.height/pieces)*aspctRatio);
totalSquares = Math.floor(pieces * (origBitmap.width/recW));
}
else if(origBitmap.height < origBitmap.width){
aspctRatio = origBitmap.height/origBitmap.width;
recW = Math.floor(origBitmap.width/pieces);
recH = Math.floor((origBitmap.width/pieces)*aspctRatio);
totalSquares = pieces * Math.floor(origBitmap.height/recH);
}
else{
aspctRatio = 1;
recW = (origBitmap.width/pieces);
recH = recW;
totalSquares = pieces * (origBitmap.height/recH);
}


var xPos:Number;
var yPos:Number;
var colCounter:Number = 0;
var rowCounter:Number = 0;
for(var i:int = 0; i < totalSquares; i++){
destBitmap = new Bitmap(new BitmapData(recW, recH),PixelSnapping.NEVER, true);
destBitmap.bitmapData.copyPixels(origBitmap.bitmapData, new Rectangle(recX+(recW*colCounter), recY+(recH*rowCounter), recW, recH), new Point(0, 0));
BitmapArray.push(destBitmap);
destBitmap = null;
colCounter++;
if(colCounter >= pieces){
colCounter = 0;
rowCounter++;
}
}

return BitmapArray;
}


This finds the median color of each bitmap slice

//this finds the mean color for a bitmap data
public static function get_median_hex(bd:BitmapData):uint{
var pixelValue:uint;
var red:Number = 0;
var green:Number = 0;
var blue:Number = 0;
var count:Number = 0;

for (var i:int = 0; i < bd.height; i++){
for (var j:int = 0; j < bd.width; j++) {
pixelValue = bd.getPixel(j, i);

red += pixelValue >> 16 & 0xFF;
green += pixelValue >> 8 & 0xFF;
blue += pixelValue & 0xFF;
count++;

}
}
red /= count;
green /= count;
blue /= count;
return red << 16 | green << 8 | blue;
}

Xml Namespace

I've loaded various xmlns through Url Loaders and sometimes you just can't parse them because you have to first import the namespace. Here's an example (cause I keep forgetting)

namespace media= "http://search.yahoo.com/mrss/"; //for flickr
use namespace media;
namespace media= "http://www.w3.org/2005/Atom"; //for Atom
use namespace media;

FlashWars

Tuesday, January 19, 2010

I finally wrote my own collision detection engine from scratch. This game may or may not mimic another game for a certain unnamed console. Earth is being attacked and it's up to you to save the world! There are two bosses you'll have to face before the earth can be set free of impending Armageddon via meteor attack! Get as many points as you can in order to reach them! High score is also implemented into the game(although I think my server is currently down, so you can play, but no high score).
I've implemented a few new ideas into the game. Time bombs, lasers, bosses and background graphics to name a few. A mouse is pretty much required to play this game, because you click and hold to shoot. Moving the mouse will move the direction of fire. You can toggle special weapons with "1", "2", and "3", while "W", "A", "S", and "D", move the player around the screen. Give it a try, just click on the picture!

The game actually ended up being a lot more work than I had originally planned. A lot of trig went into the enemy chase movements, as well as the firing direction.
It just needs music now....

The enemy graphics were created in flash, while the background images and some boss graphics were created in Blender
The Earth is from my Papervision Phong Shader demo. I found an Earth cloud map and warped it to the earth in Photoshop.

26 Actionscript classes, 1598 lines of code. I tried really hard to keep it as efficient as possible.

If anyone has any questions about the game or its collision detection engine, feel free to contact me.