5 Replies - 3512 Views - Last Post: 14 March 2011 - 09:22 AM Rate Topic: -----

#1 Masterakos  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 20-November 10

C# online game

Posted 14 March 2011 - 08:37 AM

Hello everyone..

I am trying to make a chess game in C#
The game looks like this :


Attached Image


And the whole idea is that every rectangle is a particular object inside an array.

Now i would like to ask you IF and if yes then HOW i can make this work online..by meaning "play with a friend" ... I don't have any teacher or anyone else to ask, i learn alone so any info would help.
(I know that maybe this is really complicated so if you could only show me from where to start would be nice)

thanks in advance :rolleyes2:


Is This A Good Question/Topic? 0
  • +

Replies To: C# online game

#2 Robin19  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 206
  • View blog
  • Posts: 436
  • Joined: 07-July 10

Re: C# online game

Posted 14 March 2011 - 08:44 AM

You need a program to "host" or serve the game. This host(server) can run on a dedicated machine to host these games. Or one of the users machines can act as both the host(server) and a consumer(client) and the other user acts as a guest(client).

The host does all of the logic. It knows what pieces are allowed to move to what spaces. It knows when the game is won or lost. The client computers simply pass user input info to the host and pass the host game information to the user.

Try to research into the server/client model. The method of passing information and which information to pass becomes agnostic once you understand the server/client model.
Was This Post Helpful? 1
  • +
  • -

#3 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4928
  • View blog
  • Posts: 10,465
  • Joined: 02-June 10

Re: C# online game

Posted 14 March 2011 - 08:50 AM

Assuming your code has methods for the moves, for example:

MakeMove(TileObj from, TileObj to)
{
   // Code here checks the piece type
   // Is the move legal?
   // Is there a piece on the 'to' tile?
   // etc.
}


Then you could send the move as "a3, a4" to indicate moving from tile at grid location 'A3' to the tile at grid location 'a4'. Write a method to get the TileObj's at those locations, then send it to your existing MakeMove method.

You would only have to write the telecommunication and a couple method to wire in the send and receive to your existing handlers.

In its simplest form of one player against another the communication is little more than a IM chat protocol. Player1 to Player2 and all the messages are
Player1:"a3,b5"
Player2:"d2,d4"
Player1:"g7,b03"
There are plenty of tutorials on making a simple chat program. If you can make a chess program, then you should have no problem adapting that communication to your game.

Of course this is all a LOT of speculation assuming your code is written in a reasonably organized well compartimentalized manner.

This post has been edited by tlhIn`toq: 14 March 2011 - 08:54 AM

Was This Post Helpful? 1
  • +
  • -

#4 Masterakos  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 20-November 10

Re: C# online game

Posted 14 March 2011 - 09:05 AM

tlhIn`toq i fully understand what you mean ... I think if i explain better you will be able to help me more.

There are 8x8 rectangle to an array called sectors...
In my form there are 8x8 pictureBoxes inside an array called pixels...Everytime the users clicks many methods called to check if its legal and if it is legal then it does all the stuff (change icon,change sector.set_side('Black' or 'White) etc..) So having the knowledge of a sector[i,j] i can change a picture_Box[i,j] . Now if i make a chat protocol which will translate a "string" to a movement(as the mouse_click does) and the oposite you think the whole thing will work ? That's what you made me imagine.


I can send you my code if you want and you think you can help more i have no problem with that ...

sorry if its illegal to change font size ...

This post has been edited by Masterakos: 14 March 2011 - 09:06 AM

Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4928
  • View blog
  • Posts: 10,465
  • Joined: 02-June 10

Re: C# online game

Posted 14 March 2011 - 09:12 AM

Changing the font is perfectly find: that's why the tools are there.
I don't want your code. I'm not looking to become part of a shared project. I already code 10 hours a day, 5 days a work for a living.

It sounds like you have 2 click events, one 'from' and one 'to'.
From sector (i, j)
To sector (i, j)

So yes, it sounds like if you fed those same coordinates to some form of communication it shouldn't take a lot to make it work between two players.
Was This Post Helpful? 1
  • +
  • -

#6 Masterakos  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 20-November 10

Re: C# online game

Posted 14 March 2011 - 09:22 AM

Ok i got it.
I will find out about the chat protocol and make it work.. :tooth:

Thank you a lot, I wish you the best

Thanks to robin as well

P.S.
I didnt propose you to become part of my project :P (joking)
I wish to do the same job for a living one day :gunsmilie:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1