I've always loved Battleships Forever.
http://www.wyrdysm.com/games.php
However, the game lacked muliplayer. I spent about eight hours today and developed a working multiplayer prototype of the game. So far I can make full physiced ships from small parts and have them fly around. The host does all the simulation.
Considering how much demand there was for a multiplayer version and how easy it was to get this far I'm really surprised no one has created a BSF multiplayer version using something after all these years.
Here's a screenshot I took today.
Multiplayer Component Based Space Combat
Multiplayer Component Based Space Combat
Last edited by Lap on Fri May 21, 2010 8:12 pm, edited 1 time in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Multiplayer Battleships Forever
So, is there like.. something we can play?
Re: Multiplayer Component Based Space Combat
At the moment all you can do is fly around with your friends as I haven't actually made any working weapons. I'm focusing on the ship editor right now.
I was initially planning on just making a multiplayer port of the freeware game Battleships Forever, but he doesn't seem very keen on that idea so I'll probably just be making my own separate game. For the immediate future I won't actually release anything until I get my own sprites to use. On the positive note though, not making a straight port means I have the design freedom to do whatever I want and add different game mechanics.
I was initially planning on just making a multiplayer port of the freeware game Battleships Forever, but he doesn't seem very keen on that idea so I'll probably just be making my own separate game. For the immediate future I won't actually release anything until I get my own sprites to use. On the positive note though, not making a straight port means I have the design freedom to do whatever I want and add different game mechanics.
Re: Multiplayer Component Based Space Combat
Well.. actually.. I thought of doing something like this too, but have been too afraid of all the work that has to be done for properly synchronizing physical stuff. (same for Lords of Space :p)
Wishing you a lot of fun with your project, am already eager to finally play BSF with friends.
Wishing you a lot of fun with your project, am already eager to finally play BSF with friends.
Re: Multiplayer Component Based Space Combat
I'm definitely looking forward to seeing where this ends up
Even if theres not much of a game yet, I'm sure we'd all still like to take a peek, and if nothing else we can see out the networking code holds holds up.
Even if theres not much of a game yet, I'm sure we'd all still like to take a peek, and if nothing else we can see out the networking code holds holds up.
"We could make a program for doing this for you, but that is for the LÖVE IDE, planned to be released in March 2142." ~mike
Networking with UDP uLove Proposal CCG: Gangrene
Networking with UDP uLove Proposal CCG: Gangrene
Re: Multiplayer Component Based Space Combat
Networking code is all LUBE so there's not too much left untested there.
I've worked with Lua before on a very similar game to this one and it kind of makes me scared. Lua isn't the fastest code and a game like this needs to do a lot of line of sight checks for automated weapons. That combined with all the effects and physics this will likely need kind of has me hesitant to go much further. I don't want to put in tons of work just to find out that the game ends up lagging when everything gets put together.
Has anyone done any physics related benchmarks?
My hands are also kind of full and I don't know if I really want to juggle another full project solo so if anyone is interested in helping out with the code let me know. Most of the hard stuff is already done.
I've worked with Lua before on a very similar game to this one and it kind of makes me scared. Lua isn't the fastest code and a game like this needs to do a lot of line of sight checks for automated weapons. That combined with all the effects and physics this will likely need kind of has me hesitant to go much further. I don't want to put in tons of work just to find out that the game ends up lagging when everything gets put together.
Has anyone done any physics related benchmarks?
My hands are also kind of full and I don't know if I really want to juggle another full project solo so if anyone is interested in helping out with the code let me know. Most of the hard stuff is already done.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Multiplayer Component Based Space Combat
Actually, Lua is blazing fast. It helps, of course if your algorithms are, say, O(n log(n)) or even O(log(n)) rather than O(n²) or O(2^n).Lap wrote:Lua isn't the fastest code
Help us help you: attach a .love.
Re: Multiplayer Component Based Space Combat
Well I remember doing this same process in Garry's mod and it got pretty laggy. I can blame most of it on the physics, but the line of sight checks seemed to actually cause quite a bit of lag when I benchmarked them.
I'm just going to throw out the blueprints of the code and hopefully someone can point out any problems and help me conquer some hurdles.
Pieces-
-Ships are made of pieces. Each piece is individually defined.
-Each piece will become it's own shape.
Ships-
-contain one core piece on which all other pieces most somehow indirectly or directly connect to.
-are a table of pieces.
-will correspond to one body, with one shape per piece.
Serverside -
1. A physics world is created.
2. Ships are created
---a. Add a body to represent each ship
---b. Go through each piece in the ship file and add the corresponding shape to this body.
3. Send created ships to new joining players as well as a table of which pieces are destroyed.
4. Simulate physics
5. Send updated ship positions.
5. Accept client input
Clientside-
1.Create a dummy physics world.
2.Draw the ships the server sends us from simple data (i.e. {ShipType, xpos, ypos, angle}). No physics will be simulated.
3.Send client commands.
Weapon Checks- Here's the tricky part
0. If it's time to find a new target....
1. Loop through all shapes throwing out shapes that are too far away.
---a. How do we determine the distance between two shapes? There is no shape:getPos() or equivalent that I know of.
---b. If we get the center of a piece it's kind of inaccurate because the center might not be in range, but an edge might.
2. Check to see if the targeted shape is in the firing arc of the weapon
3. Loop through all remaining shapes and use shape:testLineSegment() to make sure there is nothing between the weapons and the target. If there is, try the next shape.
4. Fire
This last part could derail the whole project or at least drastically change all the guns to manual instead of auto-targetting, which makes this an entirely different game.
The only way I can think of doing this is to store the position of every single shape in the game (as in hundreds of them) in a big table that gets updated every time physics update. Each time I have to
1. Lookup the shape's body
2. Get the bodies position
3. Lookup the piece's relative offsets
4. Add that to the body postion
5. do rotation...
local finalx = (xoffset * math.cos(rotation) - yoffset * math.sin(rotation)) + centerx
local finaly = (xoffset * math.sin(rotation) + yoffset * math.cos(rotation)) + centery
to find the final position
Now if I have to do that for every single physics.update that seems awful, especially considering box2d has to have the x,y of each shape stored somewhere.
I'm just going to throw out the blueprints of the code and hopefully someone can point out any problems and help me conquer some hurdles.
Pieces-
-Ships are made of pieces. Each piece is individually defined.
-Each piece will become it's own shape.
Code: Select all
-- {image, { polygon coords} }
Pieces = {}
Pieces['wond_sec'] = {love.graphics.newImage('gfx/pieces/wond_sec01.png'), {0,30,17,0 ,55,0,72,30}}
Pieces['kae_sec47'] = { love.graphics.newImage('gfx/pieces/kae_sec47.png'), {0,0,15,0,32,17,32,25}}
Pieces['old_ce60'] = { love.graphics.newImage('gfx/pieces/Old_CE60.png'), {15,0,72,21,15,42,0,33,3,21,0,9}}
-contain one core piece on which all other pieces most somehow indirectly or directly connect to.
-are a table of pieces.
-will correspond to one body, with one shape per piece.
Code: Select all
Ship1 = {}
Ship1['Core'] = 'old_ce60'
Ship1['Pieces'] = {}
Ship1['Weapons'] = {}
-- {Parent #, X Offset, Y Offset, Flip x, Flip y, Rotation, type}
Ship1['Pieces'][1] = {0, 0, 20, true, true, 0, 'wond_sec'}
Ship1['Pieces'][2] = {0, 0, -20, false, false, 0, 'wond_sec'}
Ship1['Pieces'][3] = {1, 0, 40, false, true, 0, 'kae_sec47'}
Ship1['Pieces'][4] = {2, 0, -40, false, false, 0, 'kae_sec47'}
1. A physics world is created.
2. Ships are created
---a. Add a body to represent each ship
---b. Go through each piece in the ship file and add the corresponding shape to this body.
3. Send created ships to new joining players as well as a table of which pieces are destroyed.
4. Simulate physics
5. Send updated ship positions.
5. Accept client input
Clientside-
1.Create a dummy physics world.
2.Draw the ships the server sends us from simple data (i.e. {ShipType, xpos, ypos, angle}). No physics will be simulated.
3.Send client commands.
Weapon Checks- Here's the tricky part
0. If it's time to find a new target....
1. Loop through all shapes throwing out shapes that are too far away.
---a. How do we determine the distance between two shapes? There is no shape:getPos() or equivalent that I know of.
---b. If we get the center of a piece it's kind of inaccurate because the center might not be in range, but an edge might.
2. Check to see if the targeted shape is in the firing arc of the weapon
3. Loop through all remaining shapes and use shape:testLineSegment() to make sure there is nothing between the weapons and the target. If there is, try the next shape.
4. Fire
This last part could derail the whole project or at least drastically change all the guns to manual instead of auto-targetting, which makes this an entirely different game.
The only way I can think of doing this is to store the position of every single shape in the game (as in hundreds of them) in a big table that gets updated every time physics update. Each time I have to
1. Lookup the shape's body
2. Get the bodies position
3. Lookup the piece's relative offsets
4. Add that to the body postion
5. do rotation...
local finalx = (xoffset * math.cos(rotation) - yoffset * math.sin(rotation)) + centerx
local finaly = (xoffset * math.sin(rotation) + yoffset * math.cos(rotation)) + centery
to find the final position
Now if I have to do that for every single physics.update that seems awful, especially considering box2d has to have the x,y of each shape stored somewhere.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Multiplayer Component Based Space Combat
This seems overly complicated. I'm sure there is a much simpler way to deal with this, I just can't think of one right now.
Help us help you: attach a .love.
Who is online
Users browsing this forum: Amazon [Bot] and 4 guests