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.

Work in Progress / Space Craft (Multiplayer Space Fighter)

Author
Message
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 24th Jan 2012 03:17 Edited at: 7th May 2012 15:04
Space Craft
(Working title)

Dark GDK + Multisync


Download Space Craft v0.3

Register an account at the web site.

Check web site for server status.

http://nbit.net84.net/SpaceCraft/



This version of DirectX might be needed, especially if you run win 7 or vista and have not installed any older games.

DirectX Aug07












It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 24th Jan 2012 03:20
So, I have not abandoned this, have been hard at work refactoring so not much new except menu's and music. However, all memory leaks have been tracked and eliminated and (at home at least) the server seems rock solid.

Would appreciate you giving it a try, though you will need a mate to shoot.

I'll be in for perhaps another 1/2 hour tonight, and then off for some needed sleep.

I'm leaving the server up though, to give it a thorough stability test.

Enjoy, and please give feedback.

It's not my fault!
Design Runner
13
Years of Service
User Offline
Joined: 16th Oct 2010
Location: In my own little world.
Posted: 25th Jan 2012 03:37
This is back!

I can give this a try in two days, if you would like?

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th Jan 2012 10:13 Edited at: 26th Jan 2012 11:03
Yeah, I tend to only code during the winter, hence it's been a while and the previous WIP thread has now autolocked.

Server should be up more frequently now, so yeah, 2 days is cool.

I'm looking to get feedback on the flight controls, and how the networking performs.

Currently not happy with the slow down caused by many bullets being in existence at once. It's fine with 2-3 players, but I after that, frame rate can really suffer. Not sure how to approach this problem as I want each individual bullet to be collidable.

It's not my fault!
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jan 2012 10:38
Quote: "Not sure how to approach this problem as I want each individual bullet to be collidable."


How do you handle movement and collision of the bullets? Here's how I handle fast projectiles on a network. It can easily handle OVER 9000!!!



Requires some explanation. Clients handle the movement of the projectiles seperately from the server (the server doesn't continually send the positions of all projectiles to the clients). The only network traffic that occurs is

1) client lets server know he's shooting
2) server lets client know someone's shooting
3) server lets client know where and when it collided

There is a slight tolerance, but because the server handles all of the collision, it's fair for everyone. Is that how you do it?

TheComet

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th Jan 2012 12:33 Edited at: 25th Jan 2012 12:46
No, at the moment I've got a very basic starting point:

Client fires
Client creates bullet object
Client sends bullet position, angle and velocity to server
Server propagates bullet to other clients
Other clients create bullet

Basically, every client creates every bullet that was fired by any player, and the server tracks position and facing of each bullet.

Collision detection is done in the clients using DGDK native collision detection (ObjectHit). There are no Objects created in the server, the server just tracks position and angle values. So, using ObjectHit on server is not possible.

I understand that native collision detection isn't going to be the fastest. I'd be happy to use a 3rd party dll, but only if it was free. (Is sparky's free and does it come in a Dark GDK flavour?)

As far as I can tell though, it's not the network traffic that is the bottle neck. It's the creation and movement of the bullets in the client.

When there are 1000 bullets in the air, the loop to move the bullets must go through 1000 iterations every main game loop.

I started out using CloneObject, with a master bullet object. Now I've moved to instanced objects which improves things slightly.

There is definately a lot of optimisation to be had. Pretty much everything has been coded 'just to get it working' at the moment. Now I want to get it all slick before moving on with the next phase.

It's not my fault!
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 25th Jan 2012 12:46
You should really be using sparkys, it is free and there is a GDK version.

As I understand it, the native collision detection checks every object against all other objects no matter where they are. Sparkys splits the world space up and only checks objects against objects in the same block of space.

Therefore, native collision will not scale up well at all.

You can also try Dark DynamiX, that's even faster than sparkys due to the fact it is multi-threaded.

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th Jan 2012 13:25
Cheers Matty.

So, there'll be a speed gain there from using Sparky's or Dark Dynamix, but what about any optimisations in the actual code structure.

For instance, one game I play, the bullets are all just graphical dressing.
The hit detection is done at the moment of firing meaning it's done just once per bullet, rather than every game loop for the life of the bullet as in my current structure. Disadvantage to this is you can't 'dodge' incoming bullets and I want this game to be all about twitch skills rather than stats.

Do any of you know of any other techniques?

It's not my fault!
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 25th Jan 2012 13:54
I like what TheComet recommended, doing all collision on the server sounds fair and since the server is not drawing anything it will be able to handle it better.

I would add to that, if a ship fires then you should do a quick distance check before sending it to the client. If the firing ship is a certain distance away then the client does not need to know about the bullet. Remember to use distance squared to avoid a square root operation.

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th Jan 2012 14:26
Only issue with doing collision on the server is it would all have to be math based. There are no polygons with which to test against. Not impossible, but a route I'd like to avoid if poss.

Regarding the sqrt problem. I'm rusty, but not that rusty!

The culling calcs by distance would improve things a little, but only when the clients are spread out. With it being a space fighter, most often all players are in close proximity, certainly within bullet range of each other.

It's not my fault!
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 25th Jan 2012 14:59
I'm assuming collisions are in 3D world space:

The way that I would approach this would be to partition the space. Typically, this is referring to octree's; but octrees are expensive with dynamic objects so I would opt for a lesser grained approach...

I would partition the space (world-space) into say, 27-equally sized quadrants (if you will), and track the bullets/players movement in and out of those quadrants...

Collision checks (done on the client, right?) only have to occur for the quadrants that are visible on screen! Using this approach, if you can't see it, it won't be tested...

To represent the players/bullets in world-space for this approach, I would use an array of link-lists where each element of the array represents a quadrant and each item in the link list represents an entity contained within that quadrant...

Of course, you would have to determine which quadrants are visible each frame, but 27 tests to eliminate at least have of the quadrants (and the entities that they contain) seem reasonable to me...

Hope this helps in giving you ideas...

JTK
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 25th Jan 2012 15:14
Can the server not run DGDK too, without calling sync? This would open up more possibilities to you.


A bullet limit might be a good idea, the question is how do you determine what bullets are not needed.

One approach might be to have a limit of 100 bullets, once the limit is reached then any new bullet must pass an extra test before it is spawned on the client. Any bullet which has no chance of hitting the player is a good candidate to be ignored I would think.

You could have a large sphere object, perhaps 10 to 100 times the size of the ship, position it at the ships coordinates and do a raycast against it from the firing ships position. If it hits then it passes the test, if not, it is ignored.

Other ships in the distance may be destroyed by bullets you did not see but this would only happen above the bullet limit and you would not notice.

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th Jan 2012 16:01
Server is written in DGDK, it just doesn't create any 3d objects. It manages everything with lists of structs. It does have a console outputing some messages so Sync is needed, but I'd still be interested to hear what these other possibilities are if Sync is ommited.

Trouble with eliminateing bullets is that it's going to be hard to predict that no clients will get hit.

The bullets have a life duration of 10 seconds. I could fire at target A and miss, but the bullet could carry on and hit target B. This could happen even if Targt B is not 'hittable' when bullet is fired, as B could move in that 10 seconds to a path that collides with the bullet.

It's not my fault!
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 25th Jan 2012 16:11 Edited at: 25th Jan 2012 16:16
Quote: "Server is written in DGDK, it just doesn't create any 3d objects. It manages everything with lists of structs. It does have a console outputing some messages so Sync is needed, but I'd still be interested to hear what these other possibilities are if Sync is ommited."


Any server side collision code would be easier to write, that's all I meant. Not calling sync() would just let it run a lot faster, you could also hide/exclude all objects if you need to call sync().

For the bullets, all bullets are created and the server knows about them all but it only sends the client the message to spawn a new bullet if it is necessary. So the client only knows about bullets it needs to know about(after its personal limit is reached). In your example, target A would not know about that bullet but target B would, as target B would have passed the raycast test.

EDIT: I see your problem, 10 seconds is a long time, although I think the theory is still sound, you would need to increase the size of the test sphere the further away the ship is.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jan 2012 16:25
Ah, so your server acts as a "portal" between all of the clients? In that case you should make the first client that joins the "game host", and he should do all of the collision detection. If he leaves the game, pass on that promotion to the next client etc.

Sparky's is for free and supports DGDK. That will certainly give you a boost in performance

TheComet

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th Jan 2012 16:32
Nah Comet. The server is the host. All Clients connect to the host/server. There is no direct client to client communication. All communication goes through or is generated by the host/server.

I'm begining to see the thrust of your suggestions though, both of you. Thanks for your time and input and feel free to keep it coming.

It's not my fault!
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jan 2012 16:50
Maybe game host wasn't the correct word there. I fully understand your situation I believe. You have a server which all clients connect to. The server doesn't run the actual game on it, all it does is pass on the information from one client to every other client.

What I'm saying is that you should promote one of the clients so they do all of the collision checks so you have one centralised place where all of the data is.

Before you do that though, check if sparky's speeds things up I'm addressing a completely different issue.

TheComet

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th Jan 2012 17:19
Yeah, the intention was for the server to be the authority so that all clients are getting the same decisions. This is the best way to go for a mmo as if you allow the client the authority it can be hacked.

Doing it in the client at the moment was a matter of expediency only and hence me asking for better ways, so thanks again for input.

I think I've just realised part of the issue....

EVERY client is updating EVERY bullet, and then sending the new positions to the server which in turn sends out new bullet positions to the clients. Effectively the workload is increasing exponentially with number of clients and bullets.

Will have a crack at fixing that tonight and see what gains are made.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th Jan 2012 20:23
Made some minor tweaks to the bullets.

Limited speed to 300m/s

Reduced sensitivity of pitch/yaw/roll

Package updated in top post, have fun!

It's not my fault!
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jan 2012 21:05 Edited at: 25th Jan 2012 21:05
Quote: "EVERY client is updating EVERY bullet, and then sending the new positions to the server which in turn sends out new bullet positions to the clients. Effectively the workload is increasing exponentially with number of clients and bullets."


That's exactly my point It should be EVERY client updates every bullet on their OWN without sending ANYTHING to the server except for the spawn coordinates.

I'll have to wait until the weekend to play this, looking forward to it

TheComet

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 26th Jan 2012 00:48
A client generates the bullet(s) and sends the info to the server (position and direction).
The server checks each bullet's lifetime and destroys if too old.
The server sends out an update of any bullets created/destroyed within the bullet update time frame.
Each client checks collision with any nearby bullets (can be done mathematically or by Sparky's) and reports any hits to the server.
The server sends update info about player position, orientation, speed and damage during the player update time frame.

That's how I would do the server-client relationship.

The fastest code is the code never written.
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 26th Jan 2012 01:43
I noticed you mentioned a sqrt thing above. This is one I use:


Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 26th Jan 2012 10:51
No Dude,

Hawkblood was refering to the fact that you don't need to do the sqrt.

Using Pythagorus, you can work out the length of the hypotenuse of a triangle. This is often useful as it can give us the straight line distance between two points.

Pythag goes like this, where x and y are the lengths of the two shorter sides of the triangle:

h = sqrt( (x^2) + (y^2) )

However, when we are doing distance calculations, we are often comparing one distance to another, and we can leave out the sqrt part of both equations while still getting a valid answer.

sqrt is one of the most time intensive math calcs on a computer, and so there is some speed gain, especially when you are doing lots of these calcs.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 26th Jan 2012 15:38
Server is up by the way.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 26th Jan 2012 22:16 Edited at: 29th Jan 2012 18:11
Well, seems that instancing objects stops collision detection, so switching back to cloning until I can write the maths collision detection.

Here's the new SCClient.exe only and I've linked it in the top post

[edit] Cleared this download to avoid confusion. Latest package and client in top post.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 27th Jan 2012 19:19 Edited at: 29th Jan 2012 18:11
Another minor update of just the client.

Linked in the top post.

[edit] Cleared this download to avoid confusion. Latest package and client in top post.

It's not my fault!
Noley
13
Years of Service
User Offline
Joined: 13th Dec 2010
Location:
Posted: 27th Jan 2012 22:03 Edited at: 27th Jan 2012 22:43
Oooo, I'm gonna log in and check it out ;o

EDIT:

Haha I love it!!

Nice job so far, it's really amusing and somewhat addictive lol :o
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 27th Jan 2012 22:47 Edited at: 27th Jan 2012 22:49
Yeah? Cool!

And this is currently without ANY client side prediction. I'm working on that at the moment and when done it'll be smooth as a baby's bottom!

Thanks for trying dude!



It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 29th Jan 2012 18:10 Edited at: 29th Jan 2012 18:10
Planets now orbit and rotate.

Atmospheres rotate.

Ship Judder when hit.

Shield improved.

Tweaked controls.

This is the updated client only. You need the main package if you've not downloaded before.

This update linked in the top post also.

It's not my fault!
Noley
13
Years of Service
User Offline
Joined: 13th Dec 2010
Location:
Posted: 30th Jan 2012 04:59 Edited at: 30th Jan 2012 04:59
Ahh sorry about the delay,

Yeah I really doo love it and I didn't want to stop playing with ya haha.

No problem, it was my pleasure!



Oooo I am definitely looking forward to trying out the new version!!
Inflictive
14
Years of Service
User Offline
Joined: 16th Jun 2009
Location: Altis
Posted: 27th Feb 2012 05:15
You should make a hax version of the client just for yourself, then you could pwn everybody!

no u
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 29th Feb 2012 01:54
I'm still on it.

Been getting some help from Green Gandalf with shaders, and I've done a lot of refactoring.

Still more to do though as I'm putting in a choice of different ships next, and getting the solar system objects to be a bit more dynamic.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 22nd Mar 2012 14:16
Getting database connectivity in atm. Trying to find a good C++ to MySQL tut. I seem to be getting linker issues atm, despite ensuring the libs and dlls are in the project dependencies and such.

Also, adding Octree techniques to reduce the ammount of collision detection needed each frame. Determined to keep the capacity for a massive number of bullets.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 28th Apr 2012 21:46 Edited at: 28th Apr 2012 21:47
Well, a lot of tidying up and tightening up.

Got database connectivity sorted, just not doing anything with it as yet.

Tweaked flight model.

Added planet glows.

Bullets now using intersect object .... much faster moving and more accurate bullets!

Latest download is now at

http://nbit.net84.net/SpaceCraft/

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 3rd May 2012 04:31 Edited at: 3rd May 2012 13:49
Got the files hosted on Dropbox now for ease.

Done a bit of work on the web pages.

http://nbit.net84.net/SpaceCraft/

Server is Rock Solid and up quite a lot in the UK evenings.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 5th May 2012 17:10
Web site now reports live server status.

Create an account at the web site to use in game.

http://nbit.net84.net/SpaceCraft/

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 7th May 2012 15:07
You can now register for an account at the web site and this is required to log in to game.

http://nbit.net84.net/SpaceCraft/


I shall be leaving the server up all day today. Download the latest files from the web site and give it a try. Leave feedback on flight controls and any bugs.

It's not my fault!
ChrisGDK
14
Years of Service
User Offline
Joined: 18th Dec 2009
Location:
Posted: 8th May 2012 04:28
I can't create an account, I click "Account" and it goes to an error page that says
Quote: "Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on '82.31.63.138' (4) in /home/a7914812/public_html/SpaceCraft/Connections/SpaceCraft.php on line 15"
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 9th May 2012 14:20
Hi Chris,

Yeah ... that used to happen when the database was not running. I didn't really do any error trapping in the first draft of the web pages.

I did sort this out yesterday though. You should now be informed if the database is available, independent of whether the game is available. If the database is not available, you'll neither be able to register or login.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 16th May 2012 01:27
Game is up as we speak.

You need to make an account at the web site (Only a username and password).

http://nbit.net84.net/SpaceCraft/

Come see how it's going.



It's not my fault!
Design Runner
13
Years of Service
User Offline
Joined: 16th Oct 2010
Location: In my own little world.
Posted: 16th May 2012 01:51
I can't access the account page of your site to get on. Says it does not exist, any suggestions?

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 16th May 2012 03:25
I have fixed that now.

Changed some table names in the db, forgot to update web pages.

Doh!

It's not my fault!
Design Runner
13
Years of Service
User Offline
Joined: 16th Oct 2010
Location: In my own little world.
Posted: 16th May 2012 03:28
Ok, now I can acess the page, but I can't create an account because the .user table doesn't exist. I think you missed one

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 16th May 2012 03:48
Fixed that too.

Sorry.

It's not my fault!
Design Runner
13
Years of Service
User Offline
Joined: 16th Oct 2010
Location: In my own little world.
Posted: 16th May 2012 03:50 Edited at: 16th May 2012 03:58
Works now, thanks a lot. I loved this game before, lets see how much it improved. I think I still have a space fighter laying around somewhere for this.

EDIT: This game does not want me to play. My screen looks like this (attached) and I cannot find any way to access a menu...

Attachments

Login to view attachments
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 16th May 2012 22:32
Make sure you have the latest client update too, I'm allways updating that.

The full install gives the base files and assets which rarely change, but the client.exe is in continual development.

I've fixed a couple of other issues between the database and web site, all should be well on that score now.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 17th May 2012 16:50
Server is up as we speak.

I've fixed a prob in the message loop.

Not sure what caused the white screen in the above linked screen shot Design Runner. I've had several players in and none have reported that.

Perhaps you could try it again, and if yo still have issues leave your system specs.

It's not my fault!
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 18th May 2012 03:07
Yup, 1:05am in the UK and I'm up with the server running.

I've basically been working to tighten everything up, need to stress test it and I've got 4 of us in so far.

It's not my fault!

Login to post a reply

Server time is: 2024-04-20 04:47:39
Your offset time is: 2024-04-20 04:47:39