Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  Network in games  (Read 1770 times)
0 Members and 1 Guest are viewing this topic.
Offline Kova

Senior Member





« Posted 2006-02-20 13:17:12 »

Hello.
I'm making a simple football game for 2 players over internet. Can you point me to some good network tutorial? Dosen't have to be pro or something, just enough to do it right (and when I say right, I mean in that way as you would do it for a game, not some technuiqe that is simple but nobody really uses it so I can forget about it after I'm done).
Thanks.
Offline sunsett

Senior Member




ribbit!


« Reply #1 - Posted 2006-02-20 15:14:18 »

There are several game networking APIs out there, but I'm biased to the one I wrote:

http://javagamenetworking.dev.java.net

I think it is by far the easiest to use since there's almost no learning curve to using it at all.  There are other APIs by people on this board as well that you can find by searching if you want some more variety.

-Matt Hicks
Offline Kova

Senior Member





« Reply #2 - Posted 2006-02-20 15:28:15 »

if I were to use this I wouldn't learn anything myself... and, well, that's the main point behind all this
Plus I think every game should have it's own network traffic control optimized for it, since generic solutions can't be best for all games right? Thank you anyway.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2006-02-20 18:18:37 »

I don't think there are any tutorials at the level you asking for (at least not for java). If you're intending to make the game real time transmitting all the players all the time, I'd suggest implementing something similar to the Quake3 networking system using the standard Java APIs for networking.

This page gives a good overview of the system: http://www.bookofhook.com/Article/GameDevelopment/TheQuake3NetworkingModel.html

However, if you haven't used the standard Java APIs at all I'd suggest looking at the standard Java trails for a starter at least: http://java.sun.com/docs/books/tutorial/networking/  and then you could use the JGN source mentioned in the previous post as examples of how to do stuff.

Finally, you might want to sit back and think about how the networking should work for a soccer game. I guess its quite a difficult problem if you want to keep synchronisation perfect. However, you could design your game based on accepting non-perfect syncing between players.

Kev

PS. It might be worth dropping a post in the Networking area. I'm sure there are a few (Herk, BlahBlahBlah, Jeff) who would also give you advice here.

Offline sunsett

Senior Member




ribbit!


« Reply #4 - Posted 2006-02-20 18:31:49 »

I would disagree that a generic API can not be optimized as much as a custom solution.  In fact, I would say it's more likely that a generic solution would provide more optimization since it's not a solution built for one case, but a solution designed to be useful in any situation with various features and bug testing.  Whether you decide to use JGN or not is your choice, but I believe your premise is flawed.  I hold nothing against the idea of wanting to learn this for yourself though, it's great to understand the principles even if you are using an API that simplifies the process.

BTW, I'm developing a soccer game myself (a little bit different from a normal soccer game, but the concept is still the same) and I'm using JGN with my PhysicsNetworking API wrapped around that.

You would need to have some sort of dead-reckoning implementation to do this well I should think.

-Matt Hicks
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2006-02-20 20:51:38 »

Basic networking is fairly easy.  Just look at  java.net.Socket and the  related classes.

Now thats just moving the data.  How you handle thimngs liek internet latencies to keep your game playable and fair is a very compelx topic...

But I doubt you are going to a spoprts sim to play over the internet anyway unless its very high level.  (eg pick your plays and then all control is elft to the computer...)

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline sunsett

Senior Member




ribbit!


« Reply #6 - Posted 2006-02-20 22:46:05 »

Jeff, can you repeat that last sentence in a legible format. Shocked

-Matt Hicks
Offline Kova

Senior Member





« Reply #7 - Posted 2006-02-21 02:38:51 »

@Kev
Thanks, I'll read official Java tutorial I guess. About me thinking how should be done, well that's basicly the thing I wanted to learn properly, didn't ever do networking game (or any more serius game then dos-like console game) so I don't know what exactly are problems with networking or where to start. I was hoping there was a book or something that covers exactly that.

@sunsett
I belive your JGN is very good, but how can it be best solution for every game? Surely networking for FPS, MMORPG, strategic games and others is different. I'm not going much into this since I don't have a clue about networking in games but still if you think my premise is wrong tell me why this is wrong. Your explanation how it's better since is not built for one case dosen't make sense to me from reasons I told above.
You would need to have some sort of dead-reckoning implementation to do this well I should think.
..sorry, don't know what dead-reckoning means

@Jeff
Socekts? OK, as long sockets are used for all networking...  What I'm really trying to avoid is spending weeks / months learning something that would be no use later... like when I started with game programming, got a book Java Game Programming and learned and learned... about using threads for animation, active rendering and loading images, making start menues in swing... and then I came here and found out that using threads, swing or more listeners is one of most stupidest things you can do for a non-turn based game. I feel like I lost a year of my life. Angry There's also a networking part in there... but guess what  Tongue
Offline aldacron

Senior Member


Medals: 9
Exp: 16 years


Java games rock!


« Reply #8 - Posted 2006-02-21 02:56:53 »

What I'm really trying to avoid is spending weeks / months learning something that would be no use later... like when I started with game programming, got a book Java Game Programming and learned and learned... about using threads for animation, active rendering and loading images, making start menues in swing... and then I came here and found out that using threads, swing or more listeners is one of most stupidest things you can do for a non-turn based game. I feel like I lost a year of my life. Angry There's also a networking part in there... but guess what  Tongue

Ultimately the fundamentals are the important thing. APIs (Swing, Java2D, OpenGL) are a means to an end. You can carry the fundamentals across any API that comes around and, in fact, need to be able to. The same thing applies to networking. Common architectures and algorithms can be adapted to almost any networking API, be it java.nio or Berkeley Sockets. So when you are learning this stuff, you need to make sure you aren't just learning API calls. That will get you no where fast.
Offline sunsett

Senior Member




ribbit!


« Reply #9 - Posted 2006-02-21 05:14:14 »

Kova,

Definitely there are distinctions for each type of game implementation, but that doesn't mean an higher level API makes it any less efficient.  For example, you aren't writing games in ASM are you? :-p  C/C++ are higher level languages abstracting the fundamental instruction sets that directly compile to machine code.  Even higher level is Java which compiles to byte-code and then has a VM that interprets that bytecode dynamically.  In some ways you can definitely do more efficient calls with ASM than you ever could with Java.  However, as someone that has done more than his share with assembly I'll just say that going so low level you'll often get so bogged down with just getting the code in there that after all is said and done it's less efficient than higher level languages because they've been tweaked over time to get the best performance in the majority of scenarios.

Sure, if you're doing direct TCP/UDP packet sending there is a definite potential to have a faster, more streamlined networking aspect to your game, but I would venture that rarely would you spend the time to add features like packet compression, time synchronization, packet encryption, null value handling, etc.  Further, your code is typically far more complicated to maintain if you're trying to manage the networking code inline as well.  I would say the majority of game writers on this forum have written their own networking implementation, but my goal in writing JGN was to put that to an end.  I would much rather have an API that has all the features I could need in an easy to use API so I don't have to re-design the networking wheel for every game I develop and can spend the majority of my time developing games.

My networking API is designed to be a very short learning curve as it is all about basic beans....if you know Java, you know the fundamentals of my API.

Finally, I guess you could say a choice to use something like JGN is the same type of decision you have to make whether to use jME, Xith, or Java3D above going directly OpenGL and using LWJGL or JOGL.  Sure, you can gain some advantages using straight LWJGL above jME, but jME has shadow support, Swing integration, cloth, BSP, model loading, and MANY other features that it would take years to write those features into my own game.  That's my purpose behind JGN is to provide that level of features in networking and be able to re-use them in any scenario.

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

JGO Coder




Got any cats?


« Reply #10 - Posted 2006-02-21 10:09:29 »



@Jeff
Socekts? OK, as long sockets are used for all networking...  What I'm really trying to avoid is spending weeks / months learning something that would be no use later...

Cant get more basic then an understanding of Sockets.

There are more sophisticated ways of using them then just the java.nio.Socket classes, but they are a great place to start.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Kova

Senior Member





« Reply #11 - Posted 2006-02-21 11:48:47 »

ok thanks all  Wink

@sunsett
very good explained, but I think your parallel to ASM isn't very adequate. ASM took huge amount of time to have 30% faster (?) program, but since computers really speed up we sacrificed that. Situation with network today is different, network is still bottleneck of good, syncronized gameplay. Look at most popular game, WoW, ... I surely can say it isn't written in ASM and that their network system is optimized as it can be, Blizzard surely wouldn't go with anything else.
To conclude, I'll use or at least try JGN, but first I think I'm compeled to write some of my own networking to understand it.

btw. I actually hate WoW, not the game, but it's price  Grin
Offline sunsett

Senior Member




ribbit!


« Reply #12 - Posted 2006-02-21 15:23:08 »

hehe, I can definitely appreciate that.  I would recommend doing some examples on TCP and UDP.  TCP is by far easier, but UDP offers the advantage of "fire-and-forget" where you don't care if it ever reaches its destination.  Most fast-paced games are done with UDP (although some are not) in addition to TCP for guaranteed delivery of necessary messages.  JGN is pretty stream-lined.  It's taken an awful lot of coding to make it easy to use but powerful at the same time, but that's my concern, not yours. :-p

I'm sure Blizzard probably designed their own networking API that they use for the majority of the networked games they develop.  Most games have just a couple types of messages they send: Messages that need to get there immediately or be discarded and messages that MUST arrive no matter how late they might be.  In most cases the networking aspects are usually not that varied from game to game.  In cases that they are JGN is highly customizable.

I would recommend going through the examples for NIO on the JavaDocs as NIO is really what you'll want for game development.

-Matt Hicks
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.

xsi3rr4x (59 views)
2014-04-15 18:08:23

BurntPizza (57 views)
2014-04-15 03:46:01

UprightPath (70 views)
2014-04-14 17:39:50

UprightPath (53 views)
2014-04-14 17:35:47

Porlus (70 views)
2014-04-14 15:48:38

tom_mai78101 (96 views)
2014-04-10 04:04:31

BurntPizza (156 views)
2014-04-08 23:06:04

tom_mai78101 (251 views)
2014-04-05 13:34:39

trollwarrior1 (206 views)
2014-04-04 12:06:45

CJLetsGame (213 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!