Establishing the Online Components of a Topdown 2-Player RTS

WalrusMansion

  • Posts: 8
I'm designing a 2 player RTS with hidden information (each player controls a team of actors on a battlefield and wages war with them, but the other player can't identify an enemy's actor type until it attacks). For the battlefield I've set up two identical scenes, "Player 1" and "Player 2", and have coded actor behaviors so that only somebody in the Player 1 scene can move Player 1's units and, by showing different animations depending on the scene, actor type can be hidden.

This is an actor behavior sample of the kind of coding I'm doing:


I'm pretty much done with this sort of coding, and I'm not running into too many difficulties on that end. My server side idea is to set the game up so that, when two players connect, one is brought to the "Player 1" scene and the other is brought to the "Player 2" scene. Then, when the game starts, the server will constantly check for movement in Player 1 and Player 2 and send it over to the other scene. I'd also like to randomly position each team's actors within their own respective region of the screen (randomly position Team 1's on the left side and Team 2's on the right side) and, through the server, make sure that both scenes receive the same random placement each round (otherwise, the two scenes wouldn't be identical).

The problem: I have no idea how to do any of that. I don't know precisely what kind of server I need or the best place to get it (my understanding is that I'd want a socket server, but I wonder: is there a better option for something as simple as this?). I don't know how to network.  I don't know any programming languages (I have a partner that does, though; I'll ask him which ones he knows). I ask: what is the best way to do this?

« Last Edit: July 09, 2013, 03:10:04 pm by WalrusMansion »

MeToo

  • Posts: 338
You might try having each player textually enter in a name for themselves when the game starts. Save that name as an attribute and then use various 'if player equals blank' game flow blocks to decide who sees what.

Someone more experienced may have a simpler, or elegant solution. But I think that will set you up. On that part.

WalrusMansion

  • Posts: 8
Something along those lines would probably work. What I'm currently thinking (though I don't know how to do it): Have a server that can only have two people at a time and
1. Randomly assign players as Player 1/2 when they connect, starting the game when a second person connects.
2. Automatically assign the first player to connect as Player 1 and the second as player 2, starting the game when player 2 connects.
3. Waits for two players to connect and then, through a screen with two buttons (Choose your side: "Red" or "Blue"), allow the first person to click to decide if he's player 1 or player 2.

« Last Edit: July 09, 2013, 02:39:31 pm by WalrusMansion »

WalrusMansion

  • Posts: 8
 Update: To simplify this thread a bit, I deleted portions of the OP and my above post that added nothing of value and/or discussed issues I've already resolved. I've made some solid client side progress, but I still have nothing involving a server.

MeToo

  • Posts: 338
Help clarify something for me. You mention having a partner who knows about coding. Does that mean he knows how to program servers that can send and receive HTTP requests?

WalrusMansion

  • Posts: 8
He knows how to set up networking, but he doesn't know how to make his own networking program. He does have a friend that knows a bit more about that, though, and he's currently trying to contact him to see if he could help.

I'm not sure of the exact extent of my partner's networking knowledge. He might know a little bit about how to do that (but if he does, it is "a little bit"). I'll ask him more about it.

« Last Edit: July 09, 2013, 02:51:47 pm by WalrusMansion »

MeToo

  • Posts: 338
I think you'll need to partner with someone who has a full understanding of how to make databases and webpages that can deal with HTTP requests (most likely someone with a good understanding of PHP and MySQL).

I have a friend that fits that description, and a friend that is more like the guy you seem to be describing, someone who can set up servers, but not really program them. In the end I think that friend A fits the bill for this, and friend B does not. The folks here at Stencyl have been very helpful and generous about the understanding of how to use web requests in Stencyl, but I think you'll need someone who legitimately KNOWS how to handle server side webpages and database dealing with HTTP requests.

Maybe you can become that guy, and maybe you're friend can become that guy, but for now it doesn't seem like anything short of that will do.

I spent a LOT of time looking into visual programming, code generating software for PHP/MySQL databases, so that a person like me could set up a server. I found a number of options that would work very well IF I were setting the servers and pages up for a web browser, but to deal with the simple HTTP GET and POST requests, without anything else? I didn't find software that did that. Someone with a good understanding of these things may know a clever work around to make that software usable for this, but that path was not visible to me. If I didn't have my PHP/MySQL guy, online multiplayer would be a no go in Stencyl for me. I think you're likely to face the same scenario.

I don't want to sound pessimistic, just sharing what I've learned. Heck, maybe you'll find something I didn't. :-D.

A. Find a sufficiently experienced MySQL/PHP guy
B. BECOME one
C. Find a visual programming code generator software that will allow you to do it (I sure couldn't).

I think those are your options.

Cheers.

DiabloTM

  • Posts: 10
Sorry to hijack this thread but I've a couple of related questions, would a php script hosted on an apache server and using stencyl's own built in http Get and Post, be fast enough to handle the communications an rts game needs?

I'm in the process of making something of the like for my game as well so would like a heads up.
Thanks!

MeToo

  • Posts: 338
It is my understanding that real time multiplayer usually needs to use sockets instead of HTTP requests, but I'm not sure that's always the case.

over here (http://community.stencyl.com/index.php/topic,22675.30.html) you can see CaptainComic telling me a bit about how Haxe can handle sockets. But you'd need to know a bit about HaXe to set that up.

DiabloTM

  • Posts: 10
Ah, looks complicated! I'll give it a shot soon. Thanks!

WalrusMansion

  • Posts: 8
I'm okay with becoming that person. If I find somebody else who is that person, I want to learn whatever it is that he does to make this work.

I just got myself a smartfox 2x server. Don't know how to use it yet, though. In the case of this game, it seems that all I need is HTTP GET and POST requests. I've set up some scene behavior logic:

This piece in particular is meant to deal with ensuring that both scenes have the same random distribution of units. The Scene "Player 1" would, when created, generate its actors in random positions and then POST the positions to an online text document. The Scene "Player 2" would GET the positions and then create the actors.

I'll also need to set up the POST logic, but all I care about right now: making the GET part work.

Sample List:
Code: [Select]
red scissors,3,4
red scissors,11,1
red paper, 7,9
red rock, 10, 15

The stencylpedia Web Requests article (http://www.stencyl.com/help/view/web-requests/) gets its list data from a dropbox file, but I'm thinking that I'd probably want my file to be connected to my server somehow. How do I do that? There has to be a way to do that with my smartfox server, but I don't completely understand what a bunch of the options for my smartfox server administrative tools mean.

 

« Last Edit: July 10, 2013, 07:47:13 am by WalrusMansion »

MeToo

  • Posts: 338
I don't know much about smartfox, (I went through and dismissed so many options for one reason or another it's hard to remember the reason for each one) but if you should in your research find that it is a good way for non-coders to set up server side logic, please let us know.

DiabloTM

  • Posts: 10
@MeToo cheers for the previous link you gave, I got my game to send out the actor's x coordinates to my java server running locally, and get a reply from it. Not much, but it's definitely a start!

« Last Edit: July 10, 2013, 03:33:42 pm by DiabloTM »

MeToo

  • Posts: 338
Very glad to help. Indeed I only linked you to the help that Captain (among others like Dripple and FutureFreak) was giving me  on the subject. This is a very good community. I'm glad you're here.

These Stencyl blocks are so beautiful in their ability to empower a non-coder to make a game, how dearly I wish I could find something just like it for setting up the server side. I'm lucky I have a good buddy, who can do that half for my current project, but what a thing it would be to be a fully functional multi-player game maker, in the way that familiarizing myself with Stencyl has made me one for single player.

Edit: Naming names.

« Last Edit: July 10, 2013, 12:00:31 pm by MeToo »

WalrusMansion

  • Posts: 8
I'm still working on this. No longer even contemplating using HTTP. I've made progress with the stencyl code blocks but nothing with the online-side of it. I'm thinking that I'd probably be better off finding some sort of networking forum.

I'll post an update and probably clean the OP a bit soonish.

« Last Edit: July 28, 2013, 08:45:03 pm by WalrusMansion »