Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Theoretical AJAX and C# project question

$
0
0

This is just a theroretical question and I hope I will explain it nicely, and get some valuable feedback, so before you continue, I must warn you that there may be some stupid stuff and stuff that are not nicely explained, so pls dont bash on me as I just want to find the best way to do something:

I wish to make a multiplayer game that will use jq/js to move around the pieces (to simplify, lets say its a chess game), AJAX for comunication and C# in the back, and finally either a database or xml file to connect all the info between the players. This means the following:

Player 1 moves a piece (moveable div and js/jq), AJAX sends this change to the xml file, meaning a certain shape got a new posiiton (ex whitePawn1.position= "A4" (Where A is row 4 is column). 

A Player 2 AJAX script keeps checking if P1 made his move, and if so, sees what move it was, and moves whitePawn1 to the new position.

This is repeated with roles switched (I know I am missing some stuff but this is a simple example just so you understand the basic logic).

I wish to write a "proper" OOP code - in my game there will be multiple types of 'pieces', such as whales, mines, ships... and multiple types of ships, so there will be inheritance involved.

Now, to my questions:

Will most of the code have to be in jq/js, or is it possible to write the OOP code that describes the game in C#, meaning all the classes will be defined in the back end, and the game progression will go through C# logic instead of the jq and ajax (JQ simply moves images across the board, calls AJAX to say a piece is moved, and AJAX calls a C# method). I know it could be C#, but if the page is refreshed after each move, which is not what I want. I want there to be only 1 page load when the game starts, and jq moves images, and ajax tells the server that the images are moved, and C# variables and objects have their values changed.

Since this is a 2 player game, stuff get a bit complicated with all the communicating, and if I use the C# for the main game logic, would it be possible to use only 1 session instead of 2? Meaning for example only player 1 backend will follow the game progress for both players. Or is there a better way of doing all this? I feel that maybe only 1 side can do all this work, so there is no need for the other one to also.

When I say "backend will follow game progression", this means that the C# defines all classes, and keeps track of all objects and changes, and constantly checks if all ships from 1 fleet are dead - if yes, a variable is set, for example "gameOver = p1" meaning player 1 won the game, and through ajax both sides are notified... (these are just examples I am throwing, hoping you will understand better).

As I said, this is a project I gave some thought and would soon like to start developing, but I am not sure of the possibilities and what is the best way. I pretty much know how to deal with the logic and I did develop the concept and flow of the game on paper, its just that I do not have any experience with something similar. 

Sorry if this was exausting to read!


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>