Ziz
Advanced Member
- Joined
- Jan 15, 2006
- Messages
- 3,583
Hi,
Since a long time I wanted to make a network game. For me as game developer it is quite hard to write a game, which people want to play even after a long time. Highscores only work as long until someones makes THE highscore, which is unbeatable. C4A doesn't help much, exactly the same problem - but online (yeah!). These days it is hip to implement some kind of "achievements", but to be honest... This is the same like binary highscore, but plenty of them. And it is nothing special to achieve all. Many people do so. And if you did you are done, will deinstall the game and never touch it again (except some decades later to emulate it somewhere else). So, which games are very popular, even decades after coming out? Right: Starcraft, Diablo, World of Warcraft and all these kind of games. Why? Of course, Blizzard makes great games... But above all they have excellent network support. It doesn't matter, that some player maybe onces scores over 9000, every new game decides again, who is the very best.
[The next chapter gets a bit theoretical, feel free to jump to the read "jumper"]
So some weeks (or meanwhile months) ago I thought about approaches for such a network game. There were some problems blizzard didn't have. First of all, I only develop in my spare time. So the approach should be easily doable. Furthermore I don't own a server farm. In fact I don't even own a server, all I own is a NAS. So my first idea was, that my NAS could be a game server and everybody connects to it. But with this I would write a network application, which runs in background all the time and if I make one fucking sprintf wrong, an attacker could probably easy take over my little machine with a buffer overflow. Short: I was just to inexperienced with networking and furthermore had too few time to make the application save. So my next idea was, that a very simple webserver just shares the IPs of users, who wants to play and these players "just" connect to each other. However because of routers this would only work with UDP/IP packages (for the non IT people: UDP/IP packages are sent without a check, whether they arrived. TCP/IP checks, whether the packages arrived), but I really needed TCP/IP (for reasons I will explain later). Furthermore even the UDP/IP attempt is very fiddling and again I need the experience of Skype and Co to get this to work.
I also have to solve the problem, that the Pandora's Wifi is quite instable. If the connection is gone even for a minute, the show should go on!
So I had these crazy idea, which I implemented later and which works quite well: I use already setup server machines and make only little scripts, which save and give some data in and from a database. I don't have an own server, but ED was so neat to give me some space and bandwidth on his server, so I am able to launch php scripts and to store and load data from a mySQL database. The data itself I transport via HTTP POST.
This approach has of course some benefits and some problems. First of all it is easy to debug, because I just could watch websites, whether something worked or not. Furthermore as I use the HTTP protocol it is easy to add more functionality or to send more data, which needs the server. The server itself does a couple of things. It manages the available games with their meta data (number of players, time per round, players themself, level design and stuff like this). Furthermore it is possible to chat via the server and of course to transmit game data. For this every seconds I send 1,5KB of data with 1000*12Bit, which contains, which 12 buttons were pressed every microsecond from the player. The 12 "buttons" are left, right, up, down, (A), ( B) , (X), (Y), (L), ® and of course (Start) and (Select). As always I want to stay compatible to other consoles, so the keyboard or Nubs are not transferable. You may see now, why I need to know, whether the package arrived. I need every button the player entered to stay synchronous.
But you may have already gotten the problem of the approach: The server is not able to send data to the client spontaneously. To avoid the router problems the clients always open a connection to the server and in this specific moment the server can tell, whatever it wants. If the connection is over, the server can't tell anything anymore. So ingame I ask every second "Did the player X have data submitted?" and the server can say "Nope" or send these data. Furthermore I have to ask the server every 10 seconds, whether new games are created and every 5 seconds, whether a game has changed (new users, new level design, chat message).
So I started with a little test application, which just sends HTTP POST messages and retrieves some answers from the server. The server retrieves these HTTP messages, does some database magic and delivers data. Then I made some kind of lobby and in the end implemented it in the game itself. Sounds easy, sounds fast, but in fact it was a pain in the ass and did take LONG time.
Jumper
Let's start with a video. You will see the game list view, in which all open games are shown. You can join or create a game. In this demonstration I already created a game on the pandora and join this game on the PC. The video is made on the PC, however as said the game runs on the pandora at the same time, too. If you create a game, you can create it online, seeable for everyone, or local. Only as game admin you can add AIs, but every player is able to add even more "human" players on the local machine. So two people could play on the same pandora, a third person on the GCW and furthermore 3 AIs. All this is possible, because of the turns being on after each other.
I made the AI more or less deterministic. With this, the AI movement doesn't have to be submitted. As mentioned before, to use network games, you should have at least 2 KB/s up and down speed (which are not used at the same time, so 2KB/s up OR down speed are fine). You will also see, that you have sometimes to wait quite a long time until game data arrives from another player. However unfortunately I can't change much about that. And with my approach you can't "just" start a dedicated server, you need always php mysql (for now).
https://www.youtube.com/embed/YJF4NufZLlQ?feature=oembed
So what is new at the end of the day?
So, have fun with this! I will release a GCW version soon™, too. But unfortunately I can't test it, so this may take a while.
The application is in the repository: http://repo.openpandora.org/?page=detail&app=hase_prototype-hase_prototype-12345
(GCW Version: http://ziz.gp2x.de/downloads/hase/hase.opk)
Greetings, Ziz
Since a long time I wanted to make a network game. For me as game developer it is quite hard to write a game, which people want to play even after a long time. Highscores only work as long until someones makes THE highscore, which is unbeatable. C4A doesn't help much, exactly the same problem - but online (yeah!). These days it is hip to implement some kind of "achievements", but to be honest... This is the same like binary highscore, but plenty of them. And it is nothing special to achieve all. Many people do so. And if you did you are done, will deinstall the game and never touch it again (except some decades later to emulate it somewhere else). So, which games are very popular, even decades after coming out? Right: Starcraft, Diablo, World of Warcraft and all these kind of games. Why? Of course, Blizzard makes great games... But above all they have excellent network support. It doesn't matter, that some player maybe onces scores over 9000, every new game decides again, who is the very best.
[The next chapter gets a bit theoretical, feel free to jump to the read "jumper"]
So some weeks (or meanwhile months) ago I thought about approaches for such a network game. There were some problems blizzard didn't have. First of all, I only develop in my spare time. So the approach should be easily doable. Furthermore I don't own a server farm. In fact I don't even own a server, all I own is a NAS. So my first idea was, that my NAS could be a game server and everybody connects to it. But with this I would write a network application, which runs in background all the time and if I make one fucking sprintf wrong, an attacker could probably easy take over my little machine with a buffer overflow. Short: I was just to inexperienced with networking and furthermore had too few time to make the application save. So my next idea was, that a very simple webserver just shares the IPs of users, who wants to play and these players "just" connect to each other. However because of routers this would only work with UDP/IP packages (for the non IT people: UDP/IP packages are sent without a check, whether they arrived. TCP/IP checks, whether the packages arrived), but I really needed TCP/IP (for reasons I will explain later). Furthermore even the UDP/IP attempt is very fiddling and again I need the experience of Skype and Co to get this to work.
I also have to solve the problem, that the Pandora's Wifi is quite instable. If the connection is gone even for a minute, the show should go on!
So I had these crazy idea, which I implemented later and which works quite well: I use already setup server machines and make only little scripts, which save and give some data in and from a database. I don't have an own server, but ED was so neat to give me some space and bandwidth on his server, so I am able to launch php scripts and to store and load data from a mySQL database. The data itself I transport via HTTP POST.
This approach has of course some benefits and some problems. First of all it is easy to debug, because I just could watch websites, whether something worked or not. Furthermore as I use the HTTP protocol it is easy to add more functionality or to send more data, which needs the server. The server itself does a couple of things. It manages the available games with their meta data (number of players, time per round, players themself, level design and stuff like this). Furthermore it is possible to chat via the server and of course to transmit game data. For this every seconds I send 1,5KB of data with 1000*12Bit, which contains, which 12 buttons were pressed every microsecond from the player. The 12 "buttons" are left, right, up, down, (A), ( B) , (X), (Y), (L), ® and of course (Start) and (Select). As always I want to stay compatible to other consoles, so the keyboard or Nubs are not transferable. You may see now, why I need to know, whether the package arrived. I need every button the player entered to stay synchronous.
But you may have already gotten the problem of the approach: The server is not able to send data to the client spontaneously. To avoid the router problems the clients always open a connection to the server and in this specific moment the server can tell, whatever it wants. If the connection is over, the server can't tell anything anymore. So ingame I ask every second "Did the player X have data submitted?" and the server can say "Nope" or send these data. Furthermore I have to ask the server every 10 seconds, whether new games are created and every 5 seconds, whether a game has changed (new users, new level design, chat message).
So I started with a little test application, which just sends HTTP POST messages and retrieves some answers from the server. The server retrieves these HTTP messages, does some database magic and delivers data. Then I made some kind of lobby and in the end implemented it in the game itself. Sounds easy, sounds fast, but in fact it was a pain in the ass and did take LONG time.
Jumper
Let's start with a video. You will see the game list view, in which all open games are shown. You can join or create a game. In this demonstration I already created a game on the pandora and join this game on the PC. The video is made on the PC, however as said the game runs on the pandora at the same time, too. If you create a game, you can create it online, seeable for everyone, or local. Only as game admin you can add AIs, but every player is able to add even more "human" players on the local machine. So two people could play on the same pandora, a third person on the GCW and furthermore 3 AIs. All this is possible, because of the turns being on after each other.
I made the AI more or less deterministic. With this, the AI movement doesn't have to be submitted. As mentioned before, to use network games, you should have at least 2 KB/s up and down speed (which are not used at the same time, so 2KB/s up OR down speed are fine). You will also see, that you have sometimes to wait quite a long time until game data arrives from another player. However unfortunately I can't change much about that. And with my approach you can't "just" start a dedicated server, you need always php mysql (for now).
https://www.youtube.com/embed/YJF4NufZLlQ?feature=oembed
So what is new at the end of the day?
- Network play with lobby, chat, adding and removing AIs and stuff like that
- More than two players. In fact you could play with dozens of players, but the map would get quite full
- Colours for the players
- Fixed some glitches in the physics
- The AI is smarter and has fancy international double-barrelled names
So, have fun with this! I will release a GCW version soon™, too. But unfortunately I can't test it, so this may take a while.
The application is in the repository: http://repo.openpandora.org/?page=detail&app=hase_prototype-hase_prototype-12345
(GCW Version: http://ziz.gp2x.de/downloads/hase/hase.opk)
Greetings, Ziz
Last edited by a moderator: