Showing posts with label Download. Show all posts
Showing posts with label Download. Show all posts

Friday, October 30, 2009

PONG Clone Completed!!!

It is with great pleasure that I announce I have finally completed a game of my own! There are some obvious improvements that could be made (adding sound, better art, etc.) but it is a fully working game with Artificial Intelligence (AI) for the computer opponent, basic menus, scoring, and clear winning conditions. I'm particularly proud of the ball's motion blur, a subtle effect that makes the game look more polished.

The left paddle is controlled with the W (up) and S (down) keys. Likewise, the right paddle is controlled with the O and L keys.

Download the Game Now!

I would be very appreciative of any feedback; just leave me a comment here on the blog to let me know what you think. I will provide a breakdown of the effort spent on this simple game (done in 24 hours!) in an upcoming post.

Sunday, August 30, 2009

Sine Language Lesson, Part 1

I've had this idea ruminating in my mind for some time now. Math is a big part of graphics development and I'm certainly no expert, but I wanted to show off some cool things that can be done with sine waves. This part introduces the concept and shows some fun demo programs you can play with; part two will delve into the inner workings of the demos, which have been adapted from Frank Luna's Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach.

You may remember from your high school Trigonometry class (don't worry if not, it was a long time ago for me too!) those two periodic functions, sine (pronounced "sign") and cosine ("co-sign"). They're essentially the same function and you could map one to the other with a slight shift. Cosine has some unique applications of its own, such as determining light intensity based on viewing angle, but the demos below will focus primarily on sine waves.


Notice a few interesting properties from the graph above. One is that a sine wave repeats itself every 2π (π ≈ 3.14159) or 360 degrees along the X-axis. Another is that it oscillates between the Y values -1 and 1. We write the function y = sin(x) to indicate the Y value as a function of X; see from the graph above that Y = 0 when X is any multiple of π and Y is either 1 or -1 (the peaks and valleys) when X is an odd multiple of π/2.

Point Light Demo - Download Program!

This demo shows how sine waves can be used to animate a light source. Use the specified keys to combine waves, creating a variety of unique horizontal and vertical motion paths.

Before learning this elegant method, my approach to animating an object that sways back and forth, or moves repeatedly up and down along a pole, was to use code like this in my update loop:
    static bool moveUp = true;
    if (moveUp) 
    { if (shipPos.y < 100) shipPos.y += value; else moveUp = false; }
    else 
    { if (shipPos.y > -100) shipPos.y -= value; else moveUp = true; }
With sine waves, this code reduces simply to shipPos.y = 100 * sin(x)! Notice that I multiplied by 100 to get the desired range instead of the standard oscillation from -1 to 1.

Ocean Waves Demo - Download Program!

This demo illustrates the effects of adding sine waves and two different wave types, circular and directional. Use the specified keys to play with parameters and change the wave patterns.

As with the Point Light demo, you will need to have DirectX (from Windows Update) installed in order to run the program.

These are just a couple applications of the sine function. Because of its periodic repetition, it could have many potential uses; some fellow GCG forum members cited their implementations of a 3D carousel and a wavy spaceship flight path as additional examples.

I hope you enjoy the demo programs of this post, though I admit I still need to learn better methods of input handling. Part two will describe wave alterations, based on the Ocean Waves demo, in greater detail. Until then, feel free to let us know: What's the coolest thing you've done with sine/cosine waves?

Saturday, July 4, 2009

The Problem with the Mythical Black Box

In programming, we occasionally make use of something known as a "black box." This Mythical Black Box is any library or chunk of code written by someone else that allows us to abstract a problem so we don't have to understand the details of solving it. For example, if we pass the values 3 and 4 to a "calculator black box", which might be a class library written by another developer, we would expect it to return the value 12 for multiplication. We don't care how it works internally, whether it computes 3+3+3+3 or 4+4+4; all we care is that it returns the correct value. A black box diagram for an encryption algorithm might look something like the following.

Password => { Encryption Black Box } => Encrypted Password

Jeff Atwood of Coding Horror has recently expressed seemingly contrasting views on this topic, both touting and refuting the benefits of abstraction. And for good reason, because it can be a good thing or a bad thing depending on whose library you choose. For one thing, you should never introduce code into your project if you aren't 100% certain it will fulfill its promise. Many developers (myself included) prefer the "roll your own" method for most tasks simply because you know you can trust your own code (not that it will be error-free, just that it won't be malicious). But sometimes it makes sense to use a well-tested library from another developer, such as the ever-popular JQuery library for Javascript development. In such cases I suggest ensuring you trust the developer (e.g. they're well known, such as Microsoft, and would be ridiculed if the library failed) or that you have full access to the source code. Many open source projects are reviewed by large numbers of people such that bugs are caught and fixed quickly.

Unfortunately, even if you take my suggestions your black box may someday fail. The whole reason I bring this up is that I faced this exact problem with my SkyCop demo. I developed it using the Common Files Framework presented in Engel's Beginning Direct3D Game Programming, 2nd Edition and provided in a specific version of the Microsoft DirectX SDK. When I ugraded to the most recent build of the SDK, my demo suddently stopped working and I started getting reports of others not being able to run it either. I ran into numerous problems trying to get it to work with the latest DirectX SDK and believe the Common Files Framework was removed altogether in the latest version. Having relied too heavily on that framework, I wasn't sure how to resolve the compilation errors and feared I would have to scrap the project altogether.

Fortunately, in his Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach, Frank Luna fully describes a working game framework instead of glossing over it and providing another black box. I was able to essentially rip out the core of my SkyCop demo, converting it to use the new framework, and am pleased to have an updated demo below that should work on any DirectX 9 (or newer) version, but let me know if you still have any trouble running it.

SkyCop v1.1 Demo Download

Black boxes can be a good thing when they're well-written by a trusted developer, but it's also a good idea to review the code (if possible) and at least have a basic understanding of how it works. In my case, as a learning newbie, I was happy to avoid the initial complexity and that later bit me from behind. One thing to keep in mind, though, is that black boxes come in many shapes and sizes. My black box was a game framework but the concept could also apply to a game engine, a single portion (Renderer, Physics, Sound, etc.) of a game engine, or some other game components I'm not even aware of yet.

Do you know what's going on under the hood of your game framework/engine? What black boxes are you relying on to develop your games?

Friday, April 17, 2009

Play the SkyCop v1.0 Demo!

I haven't been posting as frequently lately, but for good reason. I've been hard at work on SkyCop, which I introduced about a month ago. Keep in mind this is nowhere near a full-featured game, which is why I'm calling it a demo. But it is playable and can be "won" by destroying all red enemy ships, which is pretty fun for at least a couple minutes! :)

Features include:
  • 3D Movement/Rotation
  • Speed Boost (multi-texturing)
  • Energy Shield (alpha blending)
  • Basic Collision Detection
  • Enemy Target Indicator
  • 3 Backgrounds
  • 2 Camera Modes
Some obvious enhancements include the addition of music, sound effects, more guns, explosions, and artificial intelligence so the enemy ships can fight back! Alas, these will come in time as I continue to learn. Click the link below to try it out (press number 1 in the program for controls) and let me know what you think. Thanks for checking it out!

Download SkyCop v1.0 Demo

System Requirements: Windows OS, DirectX 9.0 runtime (available from Windows Update or searching online)

Important Disclaimer: I did NOT create the background images in the program. I used brightday1, brightday2, and grandcanyon located here, where they are listed as coming from free or (L)GPL sources.

Thursday, March 19, 2009

Introducing SkyCop v0.7

I think it's about time I introduce my pet project. You'll be happy to note the screenshot to the left is not all there is to it, though it represents the base from which I started. The project shown to the left comes directly from Engel's Beginning Direct3D Game Programming book. It features two ships, both capable of turning left/right, rolling left/right, pitching up/down, and moving forward and backward in three-dimensional space. Even though Engel discusses basic texturing early on, I find it odd that he didn't include any simple textures for the ship objects, just coloring one yellow and the other red. Leaving various enhancements to the reader is, of course, a challenge I willingly took head-on!

Part of why I never get to the later chapters in the book is because I very much enjoy enhancing this basic project. I don't expect it to become a full-fledged game; it's primarily a demo project for my own experimentation, but only time will tell if it becomes something more. The screenshot below displays my updated project, tentatively named SkyCop.

You'll notice from the screenshot the first thing I added was some fancy textures, not only for the ships but also to create a background (more on textures in another post). Additional enhancements include: multiple camera modes, dynamic background switching, multiple enemy ships, a pyramid-shaped target indicator (lower left), speed boost for the primary ship, and custom key configuration.

I plan to provide the code and running executable so you can download and play with it soon. I'm open to constructive criticism, just try not to be too harsh. I am still learning, after all ;)

Next up: Guns, Collisions, Explosions, oh my!