Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / FPS mini game

Author
Message
29 games
14
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 8th Oct 2010 01:29
This is a little FPS game I wrote. Ok it's 1600 lines long but then I did program my own models and animations.

It's a relatively straight forward FPS game. Shoot the guards before they kill you.

The guards wander around the map, if they see you they'll shoot you but you can dodge out the way pretty easily.

Controls are shown on the screen when you play the game.

Here's a screeny and then the code:

For those who have stumbled on to this but don't have access to DBC, I've attached an exe.








You might get some slow down if there is more than three enemies on screen at the same time (I'm on a 1.5 GHz, 1 Gig ram laptop). I'm currently seeing if I can sort out the shooting code to make it quicker but this is more an experiment at the moment so I thought I'd post it as is.

Comments welcome. Enjoy.

Attachments

Login to view attachments
TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 11th Oct 2010 23:17
Nice! I found it quite hard to jump out of the way of the bullets, and the reload system needs a little more work, but otherwise awesome work here!

The next step could be to replace the current generated objects with high-poly external objects, and voila, you'd have an awesome game.

TheComet

29 games
14
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 12th Oct 2010 01:35
Thanks for the comments.

I probably should have put in a delay for when a guard spots you and when they start shooting. Also the life of the guards bullets is reset when the bullet hits something so you get shot at a faster rate the closer you are to a guard.

As for reloading, I wanted something that meant the reload wouldn't be instant but without some kind of graphic (i.e. changing a magazine in a gun or a status bar) the delay would've come across as just unresponsive contols. Pressing and holding the right mouse button was just a crude way of achieving this.

I could replace the models, I could also use sparky's collision dll (I expect that'll make a lot of things easier), but I'm experimenting with how far a game can be made using nothing but DBC code. I'll probably do the textures and sound effects seperately though.
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 19th Oct 2010 03:17
Quote: "but I'm experimenting with how far a game can be made using nothing but DBC code."

It can go quite far indeed. A complete game is totally "within bounds."

This is a good demonstration. It's fun! A little hard to try and not get killed once the enemy starts shooting.

I noticed a couple of things here and there that may be of some value to you.

You might be wasting a bit of processing with your ARC_TAN() function. I think you could get the same results if you use the built in function atanfull():



And you may want to adjust your normal calculations. Right now it seems that you are using flat shading which means that you are using face normals. That is, each normal is pointing 90 degrees away from it's face.

To create a smoother or graduated shading method, use vertex normals. These are pretty easy to calculate for primatives or objects with vertices that are based around a center of 0,0,0, and are generally circum-distant from that. So what follows doesn't apply to a terrain.

Once you have your vertex values, calculate the normal by normalizing each vert coordinate. For example:

vertex 1 = (10,134,-2)
normalize = sqrt(10^2+134^2+-2^2) = 134.387
normalx = 10/134.387 = ~.074
normaly = 134/134.387 = ~.997
normalz = -2/134.387 = ~ -.015

normal 1 = (.074,.997,-.015)

This method is pretty good, especially for things like spheres and cubes and will give you smooth shading. For more complex objects (like a terrain or intricate shape where the faces aren't all eqaully angled) the vertex normals can be calculated by averaging the shared face normals of the point. This will account for the different slopes of the shared faces.

Code wise it gets a little meaty because you first have to solve for the normal of each face which is done using the cross product. But if you are experimenting with how far a game can be created in DBC alone, then you might want to add this to your arsenal.

Enjoy your day.
29 games
14
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 4th Nov 2010 01:57
Thanks for the comments, Latch.

I can't quite remember why I didn't use the inbuilt atanfull command.

As for the normals on the models, I've been lazy. I'm not even calculating anything, all the normals are just parallel to the mesh's local XYZ axis. I'll give your suggestion a go and see how it looks.

I think if I take this further, I'll put a little bit more effort into the enemy AI, make it a bit fairer when they start to shoot, especially at close range.

Login to post a reply

Server time is: 2020-08-12 02:24:13
Your offset time is: 2020-08-12 02:24:13