Archive for Game

SpecOps

Posted in game programming with tags , , , on February 1, 2008 by brandonman

I started on a platformer today. The player is a special operations person. There are currently 5 levels I’ve designed on paper. I now have to implement them. I have the walking animation done, jumping, walking, and drawing all set up in the game. Now I need to move onto the pesky AI….

specops

Advertisements

planetary gravity demo

Posted in game programming with tags , , , , , , , on January 20, 2008 by brandonman

I played around with some planetary gravity. One of my game ideas I’ve had sitting around is a space based Galaxy that is online. I decided to play around and do some work with gravity. I have a small planet orbiting a sun. There are no textures, but  the orbit is nice. I start by initializing some different variables.

float r;
float dx;
float dy;
float sunx=0;
float sunz=0;
float F;
float M1;
float M2;
float ax;
float ay;
float G=-5;
GLfloat z=-500.0f;   // Depth Into The Screen
GLfloat xpos = -20.0f;
GLfloat zpos = -20.0f;
float vx=.35;
float vy=-.22;

Now I set my masses.

   M1=1; //planet
   M2=332946; //sun

Then I do some math calculations and draw.

 glTranslatef(0,0,z);
dx = xpos-sunx; 
dy = zpos-sunz;
r = sqrt(dx*dx + dy*dy);
F = G*M1*M2/(r*r);
ax = G*M1*dx/(r*r*r);
ay = G*M1*dy/(r*r*r);
vx+=ax;
vy+=ay;
   glColor3f(1.0f,1.0f,0.0f);
   auxSolidSphere(5.0f);
   xpos+=vx;
   zpos+=vy;
   glTranslatef(xpos,zpos,0.0f);
   glColor3f(0.0f,0.4f,1.0f);
   auxSolidSphere(1.0f);
dx is the distance on the x axis, and dy is the distance on the y axis (2D). The other equations are kepler’s law. This is the law of planetary motion created by Johanas? Kepler in the 15 or 1600’s. Then, I move the planet by the velocity and draw. The files I’m linking too are the EXE, the devC++ project file, and the C++ source. This is made in opengl. Just extract these files with Winrar, Winzip, etc and either run the exe or open the project and look at the source and play with it. If you use it in a game, I won’t care, but I’d be honored for you to tell me my source was used.

 http://myfreefilehosting.com/f/47d4a9a79e_0.02MB

NOTE: my source may not be very optimized, but it works. I can’t be held responsible for any problems it may cause. Don’t use it as a guide to learn a programming style! Mine might not be that great.

Potential Fields

Posted in Uncategorized with tags , , , , , , on January 13, 2008 by brandonman

I am going to write about potential fields for AI in game programming to give everyone an understanding of it. Basically, you have a starting point (The place your AI Agent is at), and a goal, say, the location of the player. You start by creating a 2D array split into tiles. Then, you assign the location of the goal as 0. You then loop through the other locations, and make the value of them equal to the distance from the goal. Then, you loop through, and if a tile has an object on it, such as a wall, you make that tile have a value that is very high, higher than any other values in the array.

Now, each frame, you have your agent evaluate all its bordering tiles, and move to the one with the lowest value.

Wow, it’s that easy!

Note: To anyone who may have done this before, if I misunderstood or explained it wrong, leave me a comment or email me at brandonmanrulesATgmail.com. I didn’t put it in the email format just in case of spammers. replace AT with @.

Also, if anyone would want to do a link exchange for sites or blogs, that’d be great. I could make a post with your blog/site and you could make a post with mine.

First!

Posted in game programming with tags , , , , , , , on December 28, 2007 by brandonman

OK, this is my first blog post. I’m new to this whole blog thing, so shoot me a comment if I’m doing something in the wrong way. OK, this blog will be about stuff I find interesting, which means mostly gaming and my game programming adventures, along with me working on marketing my first commercial game. Here are the latest screens of that commercial game, Alien Invasion, showing the first 2 levels.

alien invasion 1

Alien Invasion 2