|
-
Senior Member
The rest of the additions (sign up, login, character creation selection, movement of viewable avatars to all users, chat, working on friends list and room list, sloped terrain for them to move on, and finally the swf database to store all user info on my computer) is all client side coding (NICE EH?)!
A few small things? I think you need to rethink your approach to the whole thing. In fact, trying to get a multiplayer game to run at a low latency and get everything running smoothly needs to be integrated right into the core of your engine, and isn't just finishing up a few small things. Plus a battle system? Man, you need to plan out games from the start! From experience, adding in a battle system(or any core feature like that) will mean changing your engine.
Flash multiplayer games aren't single player games with multiplayer slapped on for extra measure!!
P.
WIP-ZOMBIES
I love vegetarians! More meat for the rest of us!
-
"Working with API's is fairly straight forward, and something you're going to have to learn if you want to use Away3D, Papervision, Box2D etc.
All you're doing is importing classes and calling methods and getters / setters. It's no different to how you code with Flash anyway.
As for the second point, get the game working first then worry about that."
I'm personally getting tired of hearing all about needing an already made engine. Isn't there anything on how to do it without one...
"Yeah, I want lots of nice things too.
Writing a MP game is difficult and time consuming, that's why there aren't many out there, it's not due to developers lack of ambition."
You think I don't know that, I have spent over 6 months doing what I've done so far on my multiplayer app so far at least (I think more like 8). And I have pretty much no intentions of stopping with its development.
"Commercial MP servers cost money for a reason, a hell of a lot of time and effort goes into both making them and stress testing them."
I'm not arguing that. I'm just saying that I don't have the money for it.
"Let's say you stick with your way, how does it handle latency for example ? What if one player has a low spec. PC and another has a top of the range one ? How do you plan to sync them up ?"
Well first I want to at least be able to handle over 30 or so connections... Much less syncing every player
-
Senior Member
Syncing is a part of handling the connections. First off, the biggest thing you're doing wrong, is sending player positions. Obviously you need to send a message every single frame if you're doing that!
Only send a message when a user presses a key, and inform all other connections that the user is now moving in a direction, and let their computers handle the math. You can also send a message when a collision has been made, when it's undone, and when the user releases a key.
This should already chop the amount of messages into a nice, low amount.
Second, handling calculations on client computers. There are many calculations that only need to be done once, that can be done on the server. But from this I mean very few calculations. I disagree with everyone else when they say that all the game logic is handled on the server. All this will do is increase the latency. If a clients computer computes the math, and then sends just data, other clients will recieve it in no time. If you were to do logic on the server, you'd send a request to the server, and then the server would need some time in figuring it out, and only then passing it on to the clients. This creates a much bigger (relatively speaking) gap between when the message is sent, and when it's recieved.
Lastly: Don't send something like:
<player xposition="5" yposition="2"/>
Every character you throw in there is more data for you to send. You need to make it a sort of code:
<p p="00050002"/>
From that, you can get the xposition by reading the first 4 characters, and the yposition by reading the 4 last characters. Or, if you limit player positions just to the hundreds, then it makes it even shorter ("005002").
P.
WIP-ZOMBIES
I love vegetarians! More meat for the rest of us!
-
My sending and receiving method in depth
Ok I will go over the method of which I send and receive the data currently
First I have the values prepared nice within the game (x, y, rotation, etc.). And then I make an object and give it an array in which I add all the above values and others.
From there I write the object to a bytearray and compress it. Then I use Base64 to encode the bytearray to a string. Then I send the string over with the server, the string is about 75 to 120 characters long, IDK.
And when I receive the text on the other end I decode the string to a bytearray again, I decompress it, and then I create a new object from the object read off the byte array.
After that I just simply check a few things within the array that was placed on the object by another client with some ifs. Such as finding out which username it belongs to, if its an update to a player, if a player just joined, etc. And then if everything checks out with say it was an update to a player, it sets all the values (such as x, y, rotation) to the child with the name of the players username that is provided in the array
-
 Originally Posted by Pazil
Syncing is a part of handling the connections. First off, the biggest thing you're doing wrong, is sending player positions. Obviously you need to send a message every single frame if you're doing that!
Only send a message when a user presses a key, and inform all other connections that the user is now moving in a direction, and let their computers handle the math. You can also send a message when a collision has been made, when it's undone, and when the user releases a key.
This should already chop the amount of messages into a nice, low amount.
Second, handling calculations on client computers. There are many calculations that only need to be done once, that can be done on the server. But from this I mean very few calculations. I disagree with everyone else when they say that all the game logic is handled on the server. All this will do is increase the latency. If a clients computer computes the math, and then sends just data, other clients will recieve it in no time. If you were to do logic on the server, you'd send a request to the server, and then the server would need some time in figuring it out, and only then passing it on to the clients. This creates a much bigger (relatively speaking) gap between when the message is sent, and when it's recieved.
Lastly: Don't send something like:
<player xposition="5" yposition="2"/>
Every character you throw in there is more data for you to send. You need to make it a sort of code:
<p p="00050002"/>
From that, you can get the xposition by reading the first 4 characters, and the yposition by reading the 4 last characters. Or, if you limit player positions just to the hundreds, then it makes it even shorter ("005002").
P.
Thanks I have been considering the method already but haven't tried it because I'm not sure how smooth it would run. I guess I will give it a shot Basically like making a value = true when the press a movement key and then make it false when they let go? And while its true the other users do the stuff on its own?
Edit: As a quote to "<p p="00050002"/>" I have no idea what code that is, I'm doing all real data handling client side in actionscript 3. As I said before, the server is just a relaying device in this case.
Last edited by cody112; 06-15-2009 at 10:24 PM.
-
Hype over content...
"Well first I want to at least be able to handle over 30 or so connections... Much less syncing every player "
My last post in this thread, as it's pretty pointless.
It's not the number of connections which affects syncing.
Say it's just me and you playing the game. You have your quad core mean bitc'h of a machine, and I'm playing on a 486.
My machine is going to run slower than yours. So the game on my machine is going to run slower than yours. That gives you a huge advantage.
That's what syncing is, making sure that the game copes with everyone getting updates at the same time. It's all time based rather than frame based, and that has to be done at one central point, ie the server.
Actually, this is all a waste of time typing this isn't it. There's a great presentation that Jobe / Electrotank did about how to do a MP tank game which explains all this, I'd recommend you google it.
Squize.
-
it seems like you're having an issue with your java server, maybe you're looking for help in the wrong place?
-
 Originally Posted by Squize
"Well first I want to at least be able to handle over 30 or so connections... Much less syncing every player "
My last post in this thread, as it's pretty pointless.
It's not the number of connections which affects syncing.
Say it's just me and you playing the game. You have your quad core mean bitc'h of a machine, and I'm playing on a 486.
My machine is going to run slower than yours. So the game on my machine is going to run slower than yours. That gives you a huge advantage.
That's what syncing is, making sure that the game copes with everyone getting updates at the same time. It's all time based rather than frame based, and that has to be done at one central point, ie the server.
Actually, this is all a waste of time typing this isn't it. There's a great presentation that Jobe / Electrotank did about how to do a MP tank game which explains all this, I'd recommend you google it.
Squize.
Well the reason I'm not targeting syncing is because I'm doing all the connections on my computer. I start running like about 5 or more swf that runs the client side and connect with em all and everything goes on the fritz. Its not a trouble with syncing every player because I'm connecting all the clients I'm connecting to it with my own computer anyways.
The real problem entails not having the data get backed up. Its not that the server or anything is slowing down, but I'm trying to squeeze a bunch of people through the same door at too fast of a rate. So basically it lets a few in and the rest all start getting backed up and crowding up in the ever growing barrage of sent strings.
I think the best answer now is to try sending out notifiers on when to start and stop something. Rather than all the time. I'm going to check it out for a while.
-
Can't anyone at least give me some props on getting as far as I have? I mean I managed to get all the things done that a person expects from a good multi-player game except fix up this speed problem and good graphics.
Even if all client-side data handling is flawed, can't you admit that doing all that in actionscript is pretty good? I got rid of the need for a mysql database using sharedobjects that store all the user data to my computer for crying out loud XD. And I tell you it wasn't easy to code that, more than half the code I put into making all this went to the swf database
-
Senior Member
Well props to you. Here, have a cookie.
You say you don't want to use pre-made servers and stuff, yet:
- Youre going to launch this on Newgrounds, a "pre made" game website
- Newgrounds or whatever web host you use is using "pre made" services like Apache, Windows, PHP, etc. Why not code your own operating system?
- You're using Flash instead of coding your own graphics and sprite engine from the ground up in C++
- Screw C++, that's also cheating, why aren't you coding everything from scratch using Assembler machine byte code?
Get my point?
(You probably learned a heck of a lot coding your own server, so great. But obviously it's not good enough. Learn and move on to the next challenge. No harm in that. You've still accomplished more than I ever could. But if it's not fixable, it's not fixable.)
-
 Originally Posted by Ray Beez
Well props to you. Here, have a cookie.
You say you don't want to use pre-made servers and stuff, yet:
- Youre going to launch this on Newgrounds, a "pre made" game website
- Newgrounds or whatever web host you use is using "pre made" services like Apache, Windows, PHP, etc. Why not code your own operating system?
- You're using Flash instead of coding your own graphics and sprite engine from the ground up in C++
- Screw C++, that's also cheating, why aren't you coding everything from scratch using Assembler machine byte code?
Get my point?
(You probably learned a heck of a lot coding your own server, so great. But obviously it's not good enough. Learn and move on to the next challenge. No harm in that. You've still accomplished more than I ever could. But if it's not fixable, it's not fixable.)
For one, I just want to put it on newgrounds for the purpose of just having it there. Just so all the NG folks can go on the online game I'm making.
For two, I have no idea what your talking about, basically what I'm saying is I don't want to use separate .as files that others created because it causes the code to be more work for me to do because that means I got to learn every function that they coded.
For three, code my own operating system and graphics engine? I have no idea what your getting at. I'm fine with using Flash, but I don't want to use anymore than Flash and my own .as files or w/e. In fact I barely ever use .as files. Normally I code all in one .fla.
All I'm saying when I say I don't want to use side-engines is that I don't wanna use away3d, box2d, smartfox, electroserver, papervision3d, etc...
I simply don't have the patients for learning all the aspects of a side-engine I didn't make for now. I will use them when I don't feel as rushed as I do now. Idk why I feel rushed. I just do...
Edit: I feel better when using something I made because I already know all the aspects of how its used. But side-engines like away3d, I didn't make it so I can't know it all in a minute. I feel much better making a function on my own because I will know how to use it from then on.
Last edited by cody112; 06-16-2009 at 03:05 PM.
-
Check out this screenshot, sorry it is my whole screen so its big 
-
Senior Member
I'll spell it out for you: What I am saying is that there is no shame in admitting "ok, I accomplished a lot but it's not good enough" and then switching to SmartFox, or ElectroTank, or other server that WOULD workd.
-
 Originally Posted by Ray Beez
I'll spell it out for you: What I am saying is that there is no shame in admitting "ok, I accomplished a lot but it's not good enough" and then switching to SmartFox, or ElectroTank, or other server that WOULD workd.
Why do you guys insist its hopeless, I still haven't quite done what Pazil suggested, I'm about to start now.
I'll tell if it works when I'm done XD...
Tyvm Pazil, thanks for nothing everyone else. All you guys did is put down my wish to do this with nothing but Flash and my own server (sort of)
-
Senior Member
Dude, we're not saying don't go for it, totally go for it. But what you wanted was advice, so that's what we gave you! You hopefully didn't post this whole thread so people start telling you you're a hero and you've done a great job and everything. I'm sure it's a fine game.
By the way, also about your problem, I found amazing resources that talk about exactly your problem the other day here.
P.
WIP-ZOMBIES
I love vegetarians! More meat for the rest of us!
-
 Originally Posted by Pazil
Dude, we're not saying don't go for it, totally go for it. But what you wanted was advice, so that's what we gave you! You hopefully didn't post this whole thread so people start telling you you're a hero and you've done a great job and everything. I'm sure it's a fine game.
By the way, also about your problem, I found amazing resources that talk about exactly your problem the other day here.
P.
I didn't start it for that. I really did need help, but I didn't really enjoy the fact that everyone kept on saying that the whole base behind what I was doing was flawed. And ha ha ha "here" very funny... Can you at least tell me what you searched? That is if you really searched anything.
Edit: And because I feel like saying this. So far I don't know the differences yet but I am trying the non-constant sending method now. I still the to add rotation in. And I do have one little problem. I added
if (keyDownA&&! player.hitTestObject(pillar1)) {
userAccess.x+=10;
}
if (keyDownD&&! player.hitTestObject(pillar2)) {
userAccess.x-=10;
}
to the AI user thing's enterFrame loop and it doesn't work right. I think it still moves a small bit right after it collides and it causes it to continue moving or something. The AI is basically the other users.
Basically when the user stops moving I want all the other users to stop moving, after all I move left they move right and I move right they move left. It ain't working too good apparently.
Last edited by cody112; 06-18-2009 at 10:46 PM.
-
well, whatever the direction, you've got a looooooong way to go
-
 Originally Posted by Pazil
Dude, we're not saying don't go for it, totally go for it. But what you wanted was advice, so that's what we gave you! You hopefully didn't post this whole thread so people start telling you you're a hero and you've done a great job and everything. I'm sure it's a fine game.
By the way, also about your problem, I found amazing resources that talk about exactly your problem the other day here.
P.
You might consider this an extremely late reply, but you were the only one who actually said something that helped me and have my thanks for it.
You told me to don't send constantly, send when they perform an action.
I haven't finished it yet, mainly because I started feeling a lil off about doing it for quite a while. Then something else caught my eye and decided to work on that.
I'm considering making my own 3d modeler in flash (well its actually not going to be real 3d, its gonna be using the stuff off of that kirupa tutorial on 3d).
It doesn't sound very impressive, but I think I figured out a way to make this 3d modeler allow me to make complex bodies within 20 minutes. And the models I'm thinking about, I don't think I could even manage to do in the current modelers since I'm poor at 3d modeling.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|