View Full Version : Mmo
xLite
04-27-2010, 10:29 PM
Hello,
My name is Calum Scott and I am hoping to find anyone out there that has experience with multiplayer online games in Flash.
I have been trying very hard to understand the theory behind it, specifically in isometric tile based games and no matter how hard I try I will always come to a stump. Most of the time I can find my way but the problem I am having just now (multiplayer walking) is unbelievably difficult. I have tried many different ways of doing it but no luck.
I work with FlashDevelop and am currently using SmartFoxServer. I am a very confident programmer but the theory behind this just seems to be too much. If anyone who would be willing to help me with my quest to understand the theory of multiplayer tile based games, I would greatly appreciate it.
I would like you to know that I am very serious about this. Not just some script kiddie looking to make the next Habbo. I am strictly here for the learning process. I can prove some of my skills by showing you the latest version of my tile engine, named Castiel, here: http://www.calumscott.com/castiel/engine/ Of course, it's not multiplayer. Although it does show that I am very willing to learn.
Thank you very much for taking the time to read my appeal and I look forward to meeting you if you do come forward. My Windows Live Messenger address is calum.scott [@] core-zero.com.
Best Regards,
Calum Scott
djr33
04-27-2010, 10:48 PM
Can you describe this more? I am not familiar with the games you're talking about, but I do know something about how to connect multiple users at one time.
The basic way to think about all of this is like a chatroom-- but instead of messages the game uses moves and other data.
To get this to work, you can't actually send information back and forth between users; instead you need to bounce it off a server.
In most cases this means you need a database.
So flash is like Javascript-- client side programming without access to anything on the server. Use flash to submit the info to a server side script (such as with PHP or CGI) and then store it into a database there.
To retrieve the information from the other users, you need to constantly "ping" the server to check if there is new info from the database (via a PHP script). Due to the way all of this works, just like flash not having access to the server, the server cannot force information to go to the client/flash-- the client's computer must send a request to the server.
So basically you will make an endless loop that checks for new data every second (approx) and then this will be the method to "send" the "messages" to the users. And of course upon an action like making a move, the user will send a "message" to the server. And repeat.
It obviously gets complex, but the basic setup is just figuring out how to do all of these steps: send info, store info and retrieve info.
To summarize:
While client2 patiently waits in an endless loop checking for new info, client1 does this pattern:
client1 Flash > PHP (server) > Database > PHP (server) > client2 Flash
At some level it is also possible to "directly connect" the two machines (two users), but this would involve a different sort of programming and something beyond what flash is designed to do. While it could be theoretically possible, it's probably not worth even trying this. But that's how it would work for desktop/stand alone video games.
xLite
04-27-2010, 10:58 PM
What you described there djr33 is polling. It's a horrible way to run a multiplayer game :P
I am talking about using a socket server. I can connect clients easily, let them login and chat etc. It's just the theory behind walking I do not understand. This is why it would be great if I could meet someone who would be willing to, I guess in a way, mentor me. Just by helping with the essential areas of the theory of which then I can turn into functional code.
Thank you very much for your reply, however. :)
djr33
04-27-2010, 11:53 PM
Ok, so that's the more advanced way I mentioned. Well I'm not sure where you'd go with that since that's not the type of programming I do (I work mostly with PHP).
And honestly you're probably not going to find any/many people here who do that. You'd probably have more luck at a video game programming forum, though I don't know any in particular.
I'm also really not sure how much of this can be handled in flash. For some features you'll need a real programming language not just scripting on top of a graphic setup. But I'm no expert with flash, and I expect that with enough work you could find a way to get around these restrictions. I'm just not sure if it's worth it.
I hope you find some help somewhere. Perhaps someone will stop by who knows about this; it's just that this isn't a normal type of question for this forum, so it is somewhat unlikely (though someone may come across it by search, etc., who isn't a frequent poster).
BLiZZaRD
04-27-2010, 11:54 PM
Well, coding a MMO is not much different than coding an ISO single player game. You still have to code the placement and movement of items, players, baddies, etc.
How you want to detect them depends on the socket server you are using. There is a great one called Electro-Server (http://www.electro-server.com/), but thats really not what this thread is about.
Okay, so you want to know about ISO worlds, tiles and movement on them. Well we must crawl before we walk... TonyPa has a great tutorial on tile based games (http://www.tonypa.pri.ee/tbw/start.html). It is a little outdated, but the info is there and everything works in today's versions of Flash.
TonyPa got his methods from Outside Of Society (http://oos.moxiecode.com/) and their tile tutorials.
Lingo Workshop (http://www.lingoworkshop.com/Articles/Isometric_Game_1.php) also has some good tutorials on ISO and Tiles.
And lastly, if you are looking for a way to build the interactive world with 3rd party help, there is always ISO Interactive (http://www.isointeractive.com/)
Now, all that being said, there are many ways to make the players interact. Collision detection is one way, it is CPU intensive, but its quick and dirty. Then you start moving into highly complicated ones and so on and so forth.
corbo950
04-27-2010, 11:56 PM
Hey.... djr33 is right flash might not be your best option.... I am working with an engine called Panda3D (http://www.panda3d.org/).... might more fit your needs and it has a webplugin...and is scripted in either Python or C++ your choice... is there a specific reason you wanted to work with flash?
BLiZZaRD
04-27-2010, 11:57 PM
Because Flash is AWESOME, and C++ is dumb.
corbo950
04-28-2010, 12:01 AM
I totally understand blizzard... just wanted to give him another option...it is a lot heavier but ... has a lot more abilities... especially since flash can't technically handle 3d objects..... where as Panda3D can
BLiZZaRD
04-28-2010, 12:23 AM
Ahh.. sure it can. You just don't have the add ons. Papervision, Sandy 3D, ND3D, etc etc...
OH! but you say "that's not true 3-D" and I remind you sir, that the human eye does not see in true 3D either.
xLite
04-28-2010, 12:31 AM
Flash is perfectly capable. Check out www.habbo.com and www.bittybay.com they both support it very well.
I am using SmartFoxServer as I mentioned in the article.
My real issue is with the theory in making users walk. I can do connection to servers, login, chat easily etc. It's just walking I find really difficult. I can't find a solid solution to do it properly.
BLiZZaRD
04-28-2010, 12:39 AM
So.. you don't know how to control an MC? Do you want to use the arrow keys?
onClipEvent (load) {
moveSpeed = 3;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += moveSpeed;
} if (Key.isDown(Key.UP)) {
this._y -= moveSpeed;
} if (Key.isDown(Key.DOWN)) {
this._y += moveSpeed;
} if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;
}
}
Mouse?
package com.asgamer.mousecontrolled
{
import flash.display.MovieClip;
import flash.events.*;
import flash.display.Stage;
public class Hero extends MovieClip
{
var stageRef:Stage;
var speed:Number = 7;
public function Hero(stageRef:Stage) : void
{
x = stageRef.stageWidth/2;
y = stageRef.stageHeight/2;
this.stageRef = stageRef;
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
}
private function loop(e:Event) : void
{
var yDistance:Number = stageRef.mouseY - y;
var xDistance:Number = stageRef.mouseX - x;
var radian:Number = Math.atan2(yDistance, xDistance);
rotation = radian * 180 / Math.PI;
x -= (x - stageRef.mouseX) / speed; //easing
y -= (y - stageRef.mouseY) / speed; //easing
}
}
}
xLite
04-28-2010, 01:03 AM
I am pretty much aiming to turn http://www.calumscott.com/castiel/engine/ multiplayer. :)
BLiZZaRD
04-28-2010, 01:20 AM
Okay, I get that. And you use a socket server, and you can log-in, and chat and all of that, you just can't make the characters walk? This is where I lose you. Having a character walk is very simple, as stated before. What exactly are you having problems with?
Perhaps re-word it, because I am probably just not understanding you.
xLite
04-28-2010, 01:34 AM
I'm not sure when to send the target x and y back to the client. For example, if the character is not moving, and you select a tile, the server calculates the path and sends the tiles in the path 1 at a time after a set amount of time. I'm just not sure how to handle it :P
BLiZZaRD
04-28-2010, 01:38 AM
If, I get you right you need to use Flash Objects. ElectroSever uses EsObjects. Objects are Objects though, you will just need to check your socket server readme's for the correct terms.
Now, in simplistic terms you already have cell numbers, used in your path finding. The cells that the character moves over need to be stored in an Object array. This array is then sent to the server, and then on to the other modules and connections so the character appears to move on the other peoples monitors.
Just put it in an if statement, For IF xor y changes then.. store array and send to server.
xLite
04-29-2010, 06:26 PM
I understand how to send data. It was the theory I was stuck on. However, last night I managed to get serverside pathfinding working perfectly with no bugs.
However, I'd still like to meet anyone with a passion for multiplayer game development. I love learning new techniques and approaches to different problems :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.