collapse collapse

* Who's Online

  • Dot Guests: 133
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Board Stats

  • stats Total Members: 88
  • stats Total Posts: 11164
  • stats Total Topics: 1700
  • stats Total Categories: 4
  • stats Total Boards: 76
  • stats Most Online: 1470

Author Topic: Trying to create a small text based multiplayer game  (Read 4144 times)

0 Members and 1 Guest are viewing this topic.

Acidic

  • Guest
Trying to create a small text based multiplayer game
« on: April 14, 2010, 07:56:13 pm »
Hey, I'm creating a simple text based game for users to play over the internet using a client/server chat.  I was wondering if anyone had any ideas on how to implement this code.  I'm using C# and I have code for the chatclient and chatserver, plus a nice random number generator to simulate rolling dice.  I'm loosing basing this off of Warhammer, though like I said, extremely simplified.  Any help would be awesome!

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: Trying to create a small text based multiplayer game
« Reply #1 on: April 14, 2010, 09:38:25 pm »
Exactly how far in are you?

Normally, online games require 3 components
- Database
- Server
- Client

Have you gotten those figured out yet on how they will work?
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Acidic

  • Guest
Re: Trying to create a small text based multiplayer game
« Reply #2 on: April 15, 2010, 05:23:02 pm »
I got a server client chat program that works pretty well already, but only does text.  I was looking at how to get the server and client make sure they run the game, and make sure they update the game state each time its the next players turn.  I'm extremely new to this and have only been writing code for a little while now.

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: Trying to create a small text based multiplayer game
« Reply #3 on: April 15, 2010, 05:57:08 pm »
The concept in online games in terms of how it works basically is like this.

Server side:
-> Start up Server
-> Initialize all required data

-> Listen for incoming connections (thread)
---> Accept any incoming connections and add them to a connected list

-> Listen for incoming Messages (thread)
---> Process messages and echo them to all connected clients if required

-> Clean up data not required
-> Shut down server


Client Side:
-> Start up game and networking
-> Set initial values
-> Connect to the server
-> request a  ID or a "position" (player 1, player 2, etc...)
-> Send message when needed
-> Accept messages from server(thread)
-> Update game



To send messages, normally people use structures.

A example is
Code: C++
  1. struct gameData{
  2.    int health;
  3.    char name[25];
  4. };
  5. struct messageSize{
  6.    int size;
  7. };

You then fill the information out. Then send the size of the message first, followed by the message itself using code similar to
Code: C++
  1. send(serverSocket, (char*)&messagesize, sizeof(messageSize), NULL);
  2. send(serverSocket, (char*)&gameData, messageSize.size, NULL);
  3.  


On the server side, you then read in the message size first, then read in the message itself.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

Offline Nathan

  • Administrator
  • Hero Member
  • *
  • Posts: 1437
  • Reputation 1768
  • Gender: Male
  • woof woof
    • View Profile
Re: Trying to create a small text based multiplayer game
« Reply #4 on: April 17, 2010, 09:28:55 pm »
I got a server client chat program that works pretty well already, but only does text.  I was looking at how to get the server and client make sure they run the game, and make sure they update the game state each time its the next players turn.  I'm extremely new to this and have only been writing code for a little while now.
Perhaps posting that could let us help you morph that into what you want.
Projects:
[ Axios Engine ] [ sourcehub ]
Compilers: Microsoft Visual Studio 2008, GNU C++, FASM, MASM, VB 6/.Net.
Languages: C++, PHP, ASM, JS, VB6/.Net, BASIC, HTML, MySQL
Please buy me some books: Amazon Wishlist

Offline powerfear

  • - Secret Permissions Level 1 -
  • Jr. Member
  • **
  • Posts: 58
  • Reputation 64
  • Gender: Male
    • View Profile
Re: Trying to create a small text based multiplayer game
« Reply #5 on: April 17, 2010, 10:47:45 pm »
hmm

@Celestialkey

I don't see why you would need to send the packet size it's useless, normally how game work is that a couple of the first byte are a time stamp to prevent packet hacking after that there is a byte that tell the packet ID so server know how to read each part of the packet, usually you make a switch case or something simillar on that byte of the packet and analyse the rest in function of that.

The packet are received inside a buffer with a quite big size usually so there is no need to know the size of the packet.

Those information are based on a 3D MMORPG i was analysing with some other poeple to make an emulator.

Offline Celestialkey

  • Administrator
  • Hero Member
  • *
  • Posts: 3962
  • Reputation 4874
  • Gender: Male
  • Its Alive!!
    • View Profile
    • www.CelestialCoding.com
Re: Trying to create a small text based multiplayer game
« Reply #6 on: April 17, 2010, 11:16:06 pm »
hmm

@Celestialkey

I don't see why you would need to send the packet size it's useless, normally how game work is that a couple of the first byte are a time stamp to prevent packet hacking after that there is a byte that tell the packet ID so server know how to read each part of the packet, usually you make a switch case or something simillar on that byte of the packet and analyse the rest in function of that.

The packet are received inside a buffer with a quite big size usually so there is no need to know the size of the packet.

Those information are based on a 3D MMORPG i was analysing with some other poeple to make an emulator.

That will only work if you have a single message type. There are other ways of doing it. But that is the simplest to implement.
Without knowing the size of the message your receiving, you can corrupt data by reading in too much or not enough. You also need to know the correct size because not ALL messages are sent in one go. Sometimes computers break the packets into 2 different parts.

Also, sending with only message type is a very bad idea for constructing games since it becomes difficult to debug.
Created By: Eczuo
Quote
I have noticed that people who claim that everything is predestined, and we can do nothing to change it, look both ways before they cross the road.
Quote
I'd prefer to die standing, than to live on my knees - Che Guevara
Quote
If you change the way you look at something, does that something change in any way?
- Quantum Theory

Hacking
Quote
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill


Quote from: Revelations 12:4
And his tail drew the third part of the stars of heaven, and did cast them into the earth; and the dragon stood before the woman which was ready to be delivered, for to devour her child as soon as it was born.

Quote
It takes skill to build an empire. It takes an idiot to maintain it.

 

Donate


* Search


* Recent Posts

I miss the chatbox by Shishka
[August 27, 2019, 11:52:39 pm]


Image Comparison by Shishka
[May 15, 2017, 01:18:02 pm]


Re: srchub - free source code hosting by Nathan
[December 14, 2015, 11:37:02 pm]


Re: srchub - free source code hosting by Celestialkey
[November 27, 2015, 08:51:42 am]


Updates by Nathan
[October 30, 2015, 08:27:36 pm]