Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Top Down Shooter Multiplayer and Box2D questions  (Read 1053 times)
0 Members and 1 Guest are viewing this topic.
Offline Lucasmontec

Junior Devvie


Medals: 1
Exp: 4 years



« Posted 2013-12-18 17:59:43 »

Hey guys! Its me again, the cockdefenders guy!

I'm so thankful for the help I got here the last time, when I managed to make a multiplayer 'game-prototype' that mimics valve networking protocol...
This time I've got some other questions. Its about a TDS that I'm planning, and I want to make it right. The game will be multiplayer with customizable ships
and Box2D if possible.

hmmm... lets get to the questions then!
  • 1- In my previous networking 'prototype' I synchronized about three events per entity, creation, update, deletion. That was done manually with a individual message for each.
    I thought though that I could automate that probably with an interface and a manager, so that I don't have to code sync code for each new entity. This way I can code only if the
    entity has other atributes that need sync. The question is, has anyone done that before? Any tips or cool desings for those?
    Just to help out understanding, my last design was:
    Client send input changes to server.
    Server simulates everything.
    Each 33ms server sends a snapshot to all clients containing world entities, a timestamp, and removed entities.
  • 2- As I said, I want to use Box2D for nice physics. I've got some questions about that. The first question is how I'm I going to code bullets? Does Box2D support bullets?
  • 3- And ho about laser beams? Do I use Box2D to check intersection between line and poligon? Does Box2D have methods for that (handling rotated poligons)?
Offline marcuiulian13

Senior Devvie


Medals: 5
Exp: 3 years



« Reply #1 - Posted 2013-12-18 18:54:28 »

Hello there! I can't really answer your first question because i'm not an "expert" with networking.

2 - Yes, Box2D supports bullets. All you have tot do is to set a "isBullet" parameter and Box2D will handle it's collision as for a bullet.
3 - Yes, Box2D also supports line-polygon intersection. All you have to do is to call a rayCast method and you can handle what to do when a polygon is "hit".

Getting a project done is by far the most hard thing in game development.
Offline 65K
« Reply #2 - Posted 2013-12-18 18:55:25 »

Using a physics simulation for 2D in a laggy network environment is ... ambitious.
You will need to interpolate movements on the client side anyway, and then run Box2d on client and server and then sync it somehow. Good luck...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline marcuiulian13

Senior Devvie


Medals: 5
Exp: 3 years



« Reply #3 - Posted 2013-12-18 18:57:50 »

@65K, I don't think so...
You can run Box2D only on the server, setting the server to do all the logic, and the client only draw what's happening on server.

Getting a project done is by far the most hard thing in game development.
Offline 65K
« Reply #4 - Posted 2013-12-18 19:03:38 »

@65K, I don't think so...
You can run Box2D only on the server, setting the server to do all the logic, and the client only draw what's happening on server.
Did you already write a game working that way which shows a fluent movement with realistic physics without stuttering when played over the internet ?
If yes, hats off, otherwise: in theory you can do many things... Wink

Offline opiop65

JGO Kernel


Medals: 161
Projects: 7
Exp: 4 years


JumpButton Studios


« Reply #5 - Posted 2013-12-18 19:48:12 »

Exactly, theory is one thing. Actually implementing a heavily physics based networking game would be a pain... Why would you ever need box2D for such a simple game? Use either AABBs for simple collision, or use the SAT on client side to test for simple collisions, and only send a packet containing the collision coordinates when need be. Once you have collision detection set up, bullets become rather trivial.

You could even go higher level if you want a library to handle collisions and use Java2D Rectangles.

Offline Lucasmontec

Junior Devvie


Medals: 1
Exp: 4 years



« Reply #6 - Posted 2013-12-18 20:17:29 »

I could do that, totally... the AABB version... but I think I'm able to get it working with Box2D.
Simulate all physics server side, and on the clients only interpolate.
Using the same principle I'm using now, clients send input and process input locally. Client receive snapshot,
interpolate all entities to their 'server positions' (if they are far from the position).
I just don't get what would be the problem here... everything is simulated on the server. Client only renders and interpolates.

I mean, writing a GRID or QuadTree for broad... that is quite easy.
Collisions would be entirely serverside, handeling and all. The only thing the client do is send input.
I shouldn't even need a collision message. The server handle states of the entities, even simulates their animations.
Offline 65K
« Reply #7 - Posted 2013-12-18 21:13:46 »

Why would you ever need box2D for such a simple game?
Because it is just good ... works like a charm, is stable, gives a realistic movement feeling. It takes a good amount of work to redo that.

Collisions would be entirely serverside
Then, what would happen during the time a collision is detected by the server until a response travels to the client ?

How would it feel if the player wants to move, but the client has to wait for the server to send its smooth physics acceleration events ?

Offline opiop65

JGO Kernel


Medals: 161
Projects: 7
Exp: 4 years


JumpButton Studios


« Reply #8 - Posted 2013-12-18 21:55:51 »

Don't get me wrong, I realize box2D Is great. But for a simple TD game? I mean the hardest thing you'll have to deal with is maybe SAT collisions. You can implement that by yourself and optimize it for a network based game.

Offline 65K
« Reply #9 - Posted 2013-12-18 22:48:00 »

Don't get me wrong, I realize box2D Is great. But for a simple TD game? I mean the hardest thing you'll have to deal with is maybe SAT collisions. You can implement that by yourself and optimize it for a network based game.
A top down shooter doesn't have to be simple. What is simple anyway ?
A force based physics movement system just gives a more realistic feeling than anything else.
Don't forget that real programming efforts are always way beyond first estimates.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 161
Projects: 7
Exp: 4 years


JumpButton Studios


« Reply #10 - Posted 2013-12-19 01:12:35 »

I didn't mean top down shooters, OP said he wanted to make a TD game right? I've never seen a TD game with any sort of physics, but that's beyond the point. I was just trying to say that using box2D just for some simple collision detection just seems a bit wasteful, but its OP's choice!

Offline Axeman

Senior Devvie


Medals: 7



« Reply #11 - Posted 2013-12-19 01:23:22 »

I didn't mean top down shooters, OP said he wanted to make a TD game right? I've never seen a TD game with any sort of physics, but that's beyond the point. I was just trying to say that using box2D just for some simple collision detection just seems a bit wasteful, but its OP's choice!

The topic says "Top down shooter" so just to be clear about the abbreviations:OP mentions TDS, which I guess is short for "Top down shooter" and not "Tower defence". Just so we┬┤re talking about the same thing here. Smiley
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 years



« Reply #12 - Posted 2013-12-19 01:46:34 »

Uhh, top down shooters still need projectile physics, which are fairly complicated if you want ricochet effects. Additionally if he wants lighting he can use box2dlights which uses box2d anyways.
Offline opiop65

JGO Kernel


Medals: 161
Projects: 7
Exp: 4 years


JumpButton Studios


« Reply #13 - Posted 2013-12-19 01:51:25 »

Uhh, top down shooters still need projectile physics, which are fairly complicated if you want ricochet effects. Additionally if he wants lighting he can use box2dlights which uses box2d anyways.
I was assuming OP meant a simple TD game. Not a top down shooter. Shooters are far different. I think everyone is mistaking what I'm trying to say; box2D is very nice but for a TD game it seems overkill... But I never did think of lighting, oops.

Offline Lucasmontec

Junior Devvie


Medals: 1
Exp: 4 years



« Reply #14 - Posted 2013-12-19 01:52:39 »

TDS = Top Down Shooter.
Isn't meant to be simple, I wont be coding this alone.

As for server side only collisions, 65k is right. An alternative would be doing client box2d as a low priority 'visual' physics while the client waits for the server snapshot. When the snapshot comes, the client then compares the simulations and if necessary, interpolates to server positions.
Offline opiop65

JGO Kernel


Medals: 161
Projects: 7
Exp: 4 years


JumpButton Studios


« Reply #15 - Posted 2013-12-19 01:59:48 »

Damn, I thought TDS meant Tower Defense S... something... sorry!

In that case, yes box2D would be a nice way to go.

Offline Lucasmontec

Junior Devvie


Medals: 1
Exp: 4 years



« Reply #16 - Posted 2013-12-19 02:32:44 »

I'll help you, since you are a nice guy.
It could mean Tower Defence Software... or Tower Defence Super! Even Tower Defence Sexy!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (35 views)
2014-12-15 09:26:44

Mr.CodeIt (26 views)
2014-12-14 19:50:38

BurntPizza (60 views)
2014-12-09 22:41:13

BurntPizza (95 views)
2014-12-08 04:46:31

JscottyBieshaar (55 views)
2014-12-05 12:39:02

SHC (71 views)
2014-12-03 16:27:13

CopyableCougar4 (73 views)
2014-11-29 21:32:03

toopeicgaming1999 (133 views)
2014-11-26 15:22:04

toopeicgaming1999 (124 views)
2014-11-26 15:20:36

toopeicgaming1999 (34 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!