Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
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  
  Client/Server source-code somewhere?  (Read 1722 times)
0 Members and 1 Guest are viewing this topic.
Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Posted 2005-12-28 22:21:16 »

Hey,

I'm making a 4K game, and it's gonna be multiplayer. I need a very simple, effecient and very slim code doing the client/server functionality.
Since I've never done any game networking, I'm wondering if it was a good way to start by looking at some existing games doing the same?

My idea is somewhat like this:

A# Joining a game
1. Client connects to server > Server accepts
2. Client requests map ID -> Server sends map ID -> Client generates map
3. Client requests current game state status (list of players and their score, gametime etc.) -> Server sends state

B# When done joining the game, the following is repeated continiously
1. Client tells server where he is located (x,y) -> Server mediates to all clients
2. Server sends info on state of all players.
3. Repeat B#1

C# In case of some events performed by either the client or server.
1. Server sends end-game-signal to all players after X time -> Client displays scores list for few seconds and Server resets itself and finds a new map ID -> Client can reconnect again, if he does -> Start A#1
2. Player fires his rocket -> Client sends rocket location to server -> Server sends location of rocket to all clients -> Enemy clients determine if they are hit, if so -> Enemy client subtracts health from himself (or destroys himself if low on health) -> Notify server of change -> Server updates game state info.

Something like that.

Smiley Thank you.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2005-12-28 22:46:52 »

Are you really going to have a seperate server machien or is this  more of a game host/joiner type thing?

How many players?  If its a small number (a dozen or less) Id write it with the host throwing off a Thred that serves a java,net.ServerSocket and then a thread for each connecting user.  Clients Id just create onm thread running a java.net.Socket

This is pretty easy code...

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 noblemaster

« JGO Spiffy Duke »


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #2 - Posted 2005-12-28 23:45:28 »

Check out Apache MINA: http://directory.apache.org/subprojects/network/.

All you need. It uses NIO, but you won't need to deal with all the details getting NIO to work!
I switched from low-level NIO programming to MINA and it works like a dream!!!

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

« JGO Spiffy Duke »


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #3 - Posted 2005-12-28 23:46:04 »

Check out the "MINA Examples" - Source code link!

Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #4 - Posted 2005-12-29 04:17:24 »

Check out the "MINA Examples" - Source code link!

I must use the standard java api, so no third-party libraries, as I said, it's for the 4k competition.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #5 - Posted 2005-12-29 04:18:50 »

Are you really going to have a seperate server machien or is this  more of a game host/joiner type thing?

How many players?  If its a small number (a dozen or less) Id write it with the host throwing off a Thred that serves a java,net.ServerSocket and then a thread for each connecting user.  Clients Id just create onm thread running a java.net.Socket

This is pretty easy code...

As easy as like there is tons of available source code demonstrating this functionality? Smiley

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #6 - Posted 2005-12-29 19:30:41 »

For those interested, this article helped me a lot:
http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets-p2.html

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2005-12-29 23:23:06 »

Are you really going to have a seperate server machien or is this  more of a game host/joiner type thing?

How many players?  If its a small number (a dozen or less) Id write it with the host throwing off a Thred that serves a java,net.ServerSocket and then a thread for each connecting user.  Clients Id just create onm thread running a java.net.Socket

This is pretty easy code...

As easy as like there is tons of available source code demonstrating this functionality? Smiley

As easy as nobody tends to bother publishing source.  But I have a  chapter showing the fundamentals of the parts that tend to confuse newbs the most, such as how to do multicast discovery,  in Shawn's book "Practical Java Game Programming."

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

PocketCrafter7 (14 views)
2014-11-28 16:25:35

PocketCrafter7 (9 views)
2014-11-28 16:25:09

PocketCrafter7 (10 views)
2014-11-28 16:24:29

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

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

toopeicgaming1999 (16 views)
2014-11-26 15:20:08

SHC (30 views)
2014-11-25 12:00:59

SHC (28 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!