Contact Info / Websites

3d game... in flash 8!

2008-01-17 19:31:20 by Disarray-yarrasiD

Well, my new game is coming along nicely, I've got the three dodge levels completed (demoed below) and there are only a few glitches left in the class structure.

cool game demo, please tell me how fast it runs on your computer
3d rotations demo

Use the arrow keys to move (up and down only control the camera's focal length, not the actual distance).

Please keep in mind that these are only demos, and the final game will be much more fun (hopefully). Anyway, tell me what you think!


You must be logged in to comment on this post.


2008-01-17 19:39:18

Nice game....kind of reminds me of Star Fox 64...but without enemies...

It runs perfectly fine on my computer.


2008-01-17 19:44:01

Cool. The game ran between 45-60 FPS, and the rotation ran at 65 FPS.

Disarray-yarrasiD responds:

lol, my computer must suck, it only runs at 20 fps.


2008-01-17 19:49:29

you lose depth when you go far left or right so your unsure if your going to hit something,

personally id have the objects move on screen and not the ship.

but its looking good


2008-01-17 20:28:36

i liked it so far!
aprox 25 fps for the game
aprox 35 fps for rotation

windows xp with pentium 4 (2.8 ghz) 512 mb ram and using cable modem

haha.... too much info... whoops :)

Disarray-yarrasiD responds:

No, thanks, the more info the better.
You seem to have the same computer setup as me, only I have a gig of ram (which does not seem to effect flash very much)


2008-01-17 20:34:17

Damn you and your 3D skills. That one aspect I still haven't ventured into in flash.

The rotation thing is really nice. How do you detect if the surface is perpendicular to you? (or, at least, how close the angle is for the lighting.) How do you store the info? Do you store it as connected points or "panels" plus a direction they are facing?

I think I have a rough idea of how you do it... I should make something 3d some time. Perhaps even an AS war =P That could be interesting.

Disarray-yarrasiD responds:

For rotations I use a matrix rotation (I don't like the built matrices, so I don't use them). Rotation around x-axis:

sin = Math.sin(rotate*rotConstant);
cos = Math.cos(rotate*rotConstant);
holder = (yposition+ypo)*cos-(zposition+zp o)*sin-ypo;
zposition = (yposition+ypo)*sin+(zposition+zp o)*cos-zpo;
yposition = holder;

The forms (3d objects) are stored in 5 arrays, one for x coordinates, one for y coordinates, one for z coordinates, one for colors (so I could have every panel a different color if I wanted) and one for the polygons (referencing the order in which the other arrays are accessed. The points must be stored in clockwise order to cull properly). This is the player ship:

var xPlayer = new Array(0, 2, 0, -2, 0, 6, 8, 6, 6, -6, -8, -6, -6);
var yPlayer = new Array(0, 0, 0, 0, -3, 0, 0, 0, -2, 0, 0, 0, -2);
var zPlayer = new Array(5, 0, -10, 0, -2, 15, 0, -5, -2, 15, 0, -5, -2);
var sPlayer = new Array([0, 1, 4, 0], [0, 4, 3, 0], [4, 1, 2, 4], [3, 4, 2, 3], [0, 3, 1, 0], [1, 3, 2, 1], [5, 6, 8, 5], [1, 5, 8, 1], [8, 6, 7, 8], [1, 8, 7, 1], [5, 1, 6, 5], [6, 1, 7, 6], [9, 3, 12, 9], [9, 12, 10, 9], [12, 3, 11, 12], [10, 12, 11, 10], [9, 10, 3, 9], [3, 10, 11, 3]);

To detect if the surface is perpendicular to you (back face culling) you take a vector normalized form the perspective-transformed polygons (before drawing), then take the dot product between the polygon and whatever direction you want the light/view port to be (also a normalised vector) If the cosine resulting from the dot product is greater than 0, it means that the face is facing you and the program draws and shades it (multiplying the color value by the dot product):

v1x = xposit[shape[holderc][0]]*a-xposi t[shape[holderc][1]]*b;
v1z = zposit[shape[holderc][0]]-zposit[
v1y = yposit[shape[holderc][0]]*a-yposi t[shape[holderc][1]]*b;
v2x = xposit[shape[holderc][1]]*b-xposi t[shape[holderc][2]]*c;
v2z = zposit[shape[holderc][1]]-zposit[
v2y = yposit[shape[holderc][1]]*b-yposi t[shape[holderc][2]]*c;
cx = v1y*v2z-v1z*v2y;
cy = v1z*v2x-v1x*v2z;
cz = v1x*v2y-v1y*v2x;
vclength = Math.sqrt((cx*cx)+(cz*cz)+(cy*cy)
cx /= vclength;
cy /= vclength;
cz /= vclength;
dot = (cz*1+cy*0+cx*0);

That's basically how it works. But the program consists of a series of class file that are so highly interchangeable that it should be easy for other people to use (I am thinking about releasing the source files after I finish the game).

Hope that helps :D


2008-01-17 20:42:34

Lol, I thought it was loading =P


2008-01-17 20:56:02

Aww, Combatd beat me, I was gonna say it reminds me of Starfox 64 too...

This is awesome though, can't wait to see the whole thing! 8D


2008-01-17 21:03:40

18 fps for game, 27 fps for 3d rotation. for some reason, i dont believe your game rly needs all this complexity.

Disarray-yarrasiD responds:

its 3d, so it has to be pretty complex :P
anyway, the rotation thing is just a demo. the real game is going to have several dog fighting levels.


2008-01-17 21:50:54

wow, nice!
how many objects can you have before flash really bites it?
haha, you are 2 years younger than me and you already know about dot products and how to calculate a normal vector, shit. I thought i was doing good with my work on a 3d game, but yours looks really nice.
the game runs at 19 fps, or 15 with windows media player running. Your acceleration and deceleration of the ship kinda makes it a pain to control, just warning you, cause when people play it, they will think mainly about gameplay, even if it has the godliness of 3d.

Good luck man, 3d in flash is fun!

Disarray-yarrasiD responds:

thanks :D

the main reason for the acceleration is that I wanted to test how fast it ran in browser so I didn't put a fps cap on the flash (at goes as fast as it can), so it won't be in the final game.


2008-01-17 23:36:00

Ah, with points and connections =/

I'm actually thinking of trying something different then is normally done. I'm thinking of having each shape composed of panels each which have a x coordinate, y coordinate, z coordinate, x,y and z rotation. It would run entirely on relative angles instead of having to re-calculate angles every frame.

Like, you'd group them into the ship and say the ship is rotated (1,6,2) then you'd know the panel is rotated (1+constant,6+constant,2+constant). Might be better, might be worse. I'll make it and see eventually =P

About releasing an engine. If you can, you could make a really efficient one that's really easy to use and has some nice functions to create and a couple generic custom hitTests (circle, square). Then, you release it and demand that if they use it, that you be given 5-10% royalties on any game created. =P Pimp money.


2008-01-18 02:00:06

worked awesomely dude :D


2008-01-18 13:48:38

I swear this is almost exactly the same as a game that was called cube or something but with different grahpics and camaera rotation


2008-01-19 00:52:12

worked around 30-50 on game-kept speeding up
about 60 for the rotation.
I have a graphics card in my computer though so I can't speak foreveryone.
I don't know a whole lot about how 3d games work. Im still a noob at modding games (sideways sad face). In any case the edges came out very smooth and i did not have any lag. I hope to see the final version