Monday, October 22, 2007

DS Homebrew

Using the PAlib I have begun work on two medium sized game projects. One was developed for a semester project with two other people, Mike Daly and Rick Naik. The other is not in active development yet. There are several, and will be many more DS homebrews cooked up as time passes, since this medium is versatile and quick to develop for.

Physics Simulation




The first project is to be a 2D physics simulation using primitive shapes, player drawn shapes and sprite objects. It will allow the player to draw primitives (circles, rectangles, and triangles) and place sprite based objects then run the physics simulation to play out endless scenarios. It is somewhat similar to games such as The Incredible Machine, but with the ability to draw your own objects and toy with more realistic physics. The source and build of this can be found here. These can be run using an emulator such as No$GBA, or hardware such as a SuperCard.

To accomplish this, I researched game physics (as it has been several years since I took physics as a class, and cannot effectively read my notes any more) and sorted through 3D implementations to work out how to accomplish the same ideas in 2D. I ended up using some simple velocity calculations from the impact vector (splitting into direct and tangential impacts) and then just cheating for rotation (no rotational inertia). For the collision detection, I am simply using circles to test if there may be a collision, then brutishly checking if any vertex of one shape is inside the other. This is straighforward, as each shape is convex. I'm taking the dot product of each edge on shape A, and testing it against each vertex on shape B, so if any of these values is negative, the shapes are not colliding. This way, a collision is our worst case scenario, which may or may not be the best method, it just seemed simple enough to get me going.



Pirate RPG

Although little progress has been made with this project, there are some interesting plans for it. So far, I have an 8 direction ship sprite sheet, a test tiled map, and a stern image for steering hooked into a simple moving ship thing. So, basically right now you can move the ship, while using the stylus to steer on the bottom screen, and run into the land (basic tile checking for wall detection). Nothing fancy, yet.



Small projects





Just for fun, I wrote an obj parser to render 3D models on the DS using openGL calls. As you may notice, the default shaders are not available through the libraries, so I just made up some crappy colorization to differentiate the geometry. If I hadn't lost the code for this, I would chock up some lambertian or phong, but it was lost in some HD changes. Maybe I'll get around to rewriting it and adding these things.


MMOG Development

Not long after getting the Internet in 2001, I found an online MMOG based originally on ALttP ( www.graalonline.com ). Not long after, a built in editor was discovered so I started playing with the proprietary scripting engine. Some of my more notable accomplishments are described below.

A* Pathfinding

One of the things that brought myself fame in the game's community is this A* implementation. While not optimised for large areas, it was well suited for single level traversal. It used the tiles in the game as nodes and several arrays for the F and G costs, aswell as for the Parent relationships. It was built to add cost for water, swamp, and other rough terrrain. In the pictures, the blue Xs are visited nodes and the green Xs are open nodes.

As I grew more knowledgable of abstract data types (binary heaps etc) and dynamic memory management, implementations of A* grew more powerful and useable in more demanding settings.

Mini Games







I built several mini games, some of which allowed you to play other people. As you can see above, I recreated the popular DS game Polarium (although never got around to adding versus play). Also, I scripted a Dots game (drawing squares on paper versus others), Connect Four, and a single player Tic-Tac-Toe (using a Minimax implementation limited by the game engine's script restraints). Since pixel graphics are not my specialty (or most graphics), all of these make heavy use of the polygon drawing functions within the scripting language. This caused me to find many ways to optimise drawing using vectors and arrays.

3D rendering




The second picture here is an early attempt at a simple 3d engine. It uses some complex trigonometric equations to solve for rotating the points (very slow). The first and third are both from the same script (different from first picture) that uses 3d transformation matricies to rotate the points with some very basic culling and lighting (just the cosine between the veiwing angle and face normal).

This is a simulation of rope using relatively simple vector normalisation and inertia calculations. The 3D effect is created by doubling the draw of each segment to perpendicular rectangles (knowledge of 3D rotations was not a part of my toolkit at this point).

Various






The first picture is of a vector drawing script that allows the player to draw lines and shapes with the selected color. This was all done using the aforementioned polygon drawing functions. The second is just an experiment with the built in particle system (adopted from the Torque engine, which the MMOG began to use) as well as a custom built shadow script that would rotate based on time of day. The third is a custom built particle effect that would simulate an exploding spray of sparks. The flag image is actually a procedural animation that would chop up an image and disply vertical portions of it in a way to simulate a wave effect. The version shown is actually using an array of color values instead of an image.

The above is one of a few string/rope simulations made using simple vector calculations based on Euclidian distance. One of the more advanced versions of this calculated the string for 3 dimensions and used screen aligned quads to keep the rope at a consistant width. In this version, the line used simple physics relations for projectile motion to cast and land in the water.




This is a simple fractal algorithm that would take an array of vectors, then extrude the edges of a square using the vectors.