SpaceMadness

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
freegadgets
Posts: 10
Joined: Sat Dec 04, 2004 6:37 pm
Location: Canada

SpaceMadness

Post by freegadgets »

Here's a little demo version of SpaceMadness. This game was made as a school project. I originally planned to have a boss ship come down once you dispatch of the three little ones, but I ran out of time. I might continue working on it next semester.

Controls:
Move the mouse to rotate the ship, left chick to thrust, right click to shoot.

A.I.:
SpaceMadness is mainly an experiment in artificial intelligence. I’ve made games before but the A.I. was always 2D. This was my first attempt at A.I. in 3D and I think it turned out well. Here are some of the features:

-Enemy ships avoid collisions with the level and their A.I. is not level-specific.
-Enemies retreat temporarily when hit.
-Enemies avoid collisions with each other and even move out of the way to make room for one of their friends.

Graphics:
The ships, textures, and level are made by me, you can use them if you want but do not use the player’s ship in anything commercial. I might use it in a real game and I wouldn’t want to have to sue ya ;) The sky cube, particles, and sounds are not mine, use them at your own risk.

I’d like to thank my group members Scott and Mark. Scott took care of the sound and helped with some of the research. Mark wrote the code to load in the settings from an external file.

Note: If the game runs a little slow, there is a text file in the media2 folder called settings. If you edit the file in notepad it will look something like this:
1024 16 1
The first number is the screen resolution, you can lower it to 800 or 640 to speed up the game. The last number represents the sky-cube and is either 0 or 1. If you set it to 0 you will have a black background instead of a sky but the game will run faster.

Brent Cowan

http://dkf.zapto.org/SpaceMadness.zip
schick
Posts: 230
Joined: Tue Oct 07, 2003 3:55 pm
Location: Germany
Contact:

Post by schick »

How did you calculate the AI?

Nice "game",

Schick
Please send me an e-mail instead of a private message.
Mr_Bloodworth
Posts: 11
Joined: Thu Nov 04, 2004 4:26 am

Post by Mr_Bloodworth »

Image

Threw one of myown models in to check it out.

Very spiffey project.

Dont worry not claming it as mine.Just wanted to see if it could handle the poly count.
*if I stare at you Blankley its because I don't know hat you just said...im no coder*
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

Wow, this is really one of the first games that made me say: "Is this really Irrlicht :) ?"
Very nice job.
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
Ronin
Posts: 116
Joined: Wed Mar 03, 2004 6:23 pm
Location: Germany

Post by Ronin »

This game is really fun, keep up the good work!
YASS - Yet Another Space Shooter - www.yass-engine.de
Munku
Posts: 66
Joined: Tue Nov 30, 2004 4:04 pm

i liked it!

Post by Munku »

Controls were a little odd in the beginng, but I got used to them

Great job! Hopefully I can get a tech demo out soonish.
Umm, don't look at me that way. I'M not the dead one here.

--The One True Marshmellow
freegadgets
Posts: 10
Joined: Sat Dec 04, 2004 6:37 pm
Location: Canada

Thanks guys

Post by freegadgets »

schick, the code to make enemies follow or flee the player is pretty basic, your probably wondering about the collision avoidance though... First I calculate a line starting at the enemy's position and ending where the enemy would be about 2 or 3 seconds later based on it's speed and direction. If there is a collision with the line, I need to calculate the angle the enemy should move in order to avoid the impact. I do this by getting the face normal of the triangle that the line intersects with and converting it to a direction. So the enemy can now thrust away from the surface it is heading toward. But we're not done yet, the enemy ship can't just turn instantly, instead it should rotate just a little each step. Often the danger of an impact is gone long before the enemy ship turns all the way around. When it is no longer at risk of hitting the terrain, the enemy returns to chasing the player or running away.

Code: Select all

		//**********  Enemy Collision Avoidance  ***********
		core::vector3df calc2Vector;
		calc2Vector.X = speed.X /(GameSpeed*0.02001f);
		calc2Vector.Y = speed.Z /(GameSpeed*0.02001f);
		calc2Vector.Z = speed.Y /(GameSpeed*0.02001f);

		//Enemy collision check ground
		core::vector3df start = pos;     //Enemy position
		core::vector3df end = start + calc2Vector*80.1f; //Enemy1 vector
		core::triangle3df triangle;         //holds information about the triangle hit
		core::line3d<f32> line(start, end); //line to test for collision


		// check for collision with terrain
		if (smgr->getSceneCollisionManager()->getCollisionPoint(
		line, selector, end, triangle))
		{
			collision = true;

			// angle of impact
			core::vector3df out = triangle.getNormal();
			out.setLength(1.0f);

			//rotate enemy ship to face away from impact
			calcVector.Y = atan2 (out.X, out.Z); 
			calcVector.Y *= RadToDeg;
			calc = sqrt(pow(out.X,2)+pow(out.Z,2));
			calcVector.X = atan2 (calc, out.Y); 
			calcVector.X = calcVector.X * RadToDeg - 90; 
		}
		//**********  End Enemy Collision Avoidance  **********
		
		//rotate model smoothly based on game speed
		dir = int(calcVector.X-Drot.X)%360;
		if(dir<0){dir+=360;}
		if(dir>180)
			Drot.X = Drot.X - 25.0f/GameSpeed;
		else
			Drot.X = Drot.X + 25.0f/GameSpeed;

		dir = int(calcVector.Y-Drot.Y)%360;
		if(dir<0){dir+=360;}
		if(dir>180)
			Drot.Y = Drot.Y - 25.0f/GameSpeed;
		else
			Drot.Y = Drot.Y + 25.0f/GameSpeed;

		rot = (rot*smoothing+Drot)/(smoothing+1.0f); //Rotate the ship

Above is a snippet of code to do what I just described, hope it makes some sense to you, feel free to ask.


Thanks to everyone who tested it provided feedback, maybe I'll upload some more stuff soon. Hey, does anyone have 3D glasses? I've been experimenting with making a game is real popping out of the screen at you 3D using the old red/blue 3D glasses. So far it sort of works but the screen flickers a lot, a work in progress...
Post Reply