• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Gazu

2D Multiplayer approach

4 posts in this topic

Hey there, I've been trying to establish a client/server architecture for a 2D Multiplayer application for like, 1-2 weeks now.
I've been using ruby (becuse I'm comfortable with it's syntax) and rubygame.

I have some problems now, it's kinda getting too complex to just find things out myself or via google. (still helps here and there, but problems seem too specific to get the right answers, which is funny because these should be common problems for EVERY newbie at networking)

My "[b]current[/b] final" goal is just having 2 clients connected to the server, each one of them being able to see the movement of the other player.
The "game" itself isn't anything more than that just yet, just a moveable character on a random-colored background.

What I achieved so far is, getting all the logic behind player movement to the server, the client just sends the key inputs to the server.
I'm sending strings with a header part and the appropiate player's values to the server, which then knows how to change player positions accordingly, then sends those positions to all currently connected clients. Well at least in theory.

Now this is where my confusion starts. The commnication and processing of the data itself works just fine.
The problem is, waiting to receive messages on client and server. Because, as long as my client for example, waits for a message from the server, the game itself freezes of course, because the loop for updating the screen "pauses" there. At the same time, the Server waits for incoming input from the client, but since the client is in a frozen state, there will be none, and the server won't send any data.

So naturally (I think) my first thought was, letting one extra thread handle as well the client's and the server's receiving data, and let the main loop just send the current information all the time.
That way, the main loops won't be blocked by waiting for data.
I am well aware that this is a very basic approach and that there is much, much more behind managing data transfer between clients and server, but with a small application on localhost and without any experience in that matter whatsoever, I thought this should do the job for now.
But I was wrong, as the threads somehow just stop working as soon as I have the first input sent to the server.
Or in other words, as soon as they actually would have something to do.

So with that information, can anyone give me any pointers on how to approach my current goal? I will give out any information thats needed but I didn't want to create a too large wall of text for now, so thank you in advance.
0

Share this post


Link to post
Share on other sites
For interactive (not turn-based) games, using a web server or web server framework is almost always the wrong tool for the job.
No matter what, the client needs to be able to receive asynchronous notifications from the network, while handling user input and animation display at the same time. This is common to all interactive games.
If you really want to be using a browser, look into "comet," or "AJAX polling."
0

Share this post


Link to post
Share on other sites
I'm not using any browser/webserver/framework, it's all just plain .rb files containing ruby code.
The server I'm speaking about is just a bunch of local ruby code, just as anything else =)
I have the .rb files online at gist.github, but I'd want to refresh them since they are now outdated, and then polish them up a bit before posting it here. It's quite a mess now (many outcommented lines and puts statements for testing)

[quote name='hplus0603' timestamp='1340233039' post='4951148']
No matter what, the client needs to be able to receive asynchronous notifications from the network, while handling user input and animation display at the same time.
[/quote]
Yea, that's what I'm trying to figure out how to achieve :)
0

Share this post


Link to post
Share on other sites
The browser has many ways of doing asynchronous communication. The most common one is to use XMLHttpRequest with an onReadyStateChange callback.
Also, you might want to look into socket.io, which has some good examples and support for this. Not Ruby-based on the server, though.
0

Share this post


Link to post
Share on other sites
Excuse me, obviously I really suck at explaining myself.
The whole thing is not supposed to be web based.
No browsers.

Imagine it like an MMO. Most of them are not played in Browerse (though some are).
Or Like, Diablo. Again, no browsers.
Just a game, featuring multiplayer, be it via LAN or internet.
The only difference is, at the moment is, it's not designed so that one client is the host. Instead, there's a seperate program I wrote, which handles inputs from the clients via UDP sockets: that is the server.

But I will look into what you suggested, maybe I will get some hints about how to approach the logic behind handling the data traffic in my approach, so thank you.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0