![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
My first assignment for my software engineering degree is to make a game in C++. I would like to make a Civilization style turn based game that can be played over the internet. However, for this I need two machines to be able to communicate the game data between them.
The programming language I know is PHP. I know that if I were making this in PHP I would use a MySQL database to hold the game data so that each instance of the game could access it from a web browser. I have been told that I cannot use c++ on the actual server (not sure if my host would allow it anyway) so I'm just wondering if there is anyway that the two programmes running on different machines could share the data as I believe for C++ to be able to communicate with an online database there will need to be C++ running on the actual server?? Any suggestions would be greatly appreciated. Ta Ade
__________________
Don't wound what you can't kill |
|
|
|
|
|
#2 | |
|
Professional Programmer
|
I couldn't see a first assignment being a game... isn't that usually the project which either passes you or fails you, at the end of your course? I'm guessing you're only talking about a 2d game though since you want to make it in php I assume?
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Presuming you wish to communicate with the normal http protocol, you address the server with that protocol, however you wish to do that, and with whatever language. The server has no inkling of that; it only knows that it got a request for a resource. You may provide that resource with whatever facilities the server has available. Presuming that you have access to the server for purposes of putting the matching software there, you may mix and match to your heart's content. That's why there's a protocol.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
Jayme this assignment is basically 100% of my programming module for my first year so that's why it's a big one. It doesn't have to be as complicated as what I'm looking at but I want a first! It has to be in C++, I only mentioned PHP as that is the language I have knowledge in working with Databases.
So Dawei, if I have a hosting account with a company that lists "PHP / Perl / C / SSI" under the details of the hosting account could I put some software written in C on there that would be able to communicate with the C++ programme on any computer and allow the exchange of data between it and the database?
__________________
Don't wound what you can't kill |
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You missed my point, maybe. The server code doesn't have to be in the same language as the client code. Unless your assignment requires it, you can use PHP or whatever. Your first step is to design your app. What goes on the client? What goes on the server? What will be passed between the two? On the server, what is passed between the server-local tiers (server code and DB)? You can't possibly make an effective and timely application without doing these things first. You'll wind up with a sow's ear sometime next year.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
Sorry for all the stupid questions, you'll have to forgive my ignorance.
So what you are saying is that I would be able to write a PHP programme for the server and a C++ programme for the client and they would be able to communicate with each other to place data into and extract data from a database, say MySQL? Client's computer Server Database c++ prog. >> php prog. >> MySql and c++ prog. << php prog. << MySql << / >> is meant to equal data flow. I might be being really retarded and have missed the point again completly. Basically what I need is to get data about the game such as where one of the player's units are and share it with all the clients running the game via (I assume the internet and as far as I can see a database). Thanks a lot for your help man.
__________________
Don't wound what you can't kill |
|
|
|
|
|
#7 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You have the picture right as far as the data flow, now. To conduct business with two clients in the same game, you might want to go to a non-typical transaction, such as chat clients might use. Keeping track of more than a couple players with the standard request/response thangy could get a tad hairy. I'm not denigrating you here, but you have a lot to get your head around other than C/C++, if you're starting essentially from scratch.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#8 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
Yeh I totally understand that, I may have to scale down and think about using the same machine as it is a turn based game. Having said that I am a very quick learner and I do have six weeks to do this, the support of my lecturers and no other work at all.
Last question I promise..... If I were getting the clients to talk directly to each other (I assume that's how a chat client works) what should I research? Thank you so much Ade
__________________
Don't wound what you can't kill |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 214
Rep Power: 3
![]() |
what uni are you at? sounds like a harsh assignment for the 1st year! I'm doing software engineering at swansea, and I didnt have to do anything that tough until i got to my second year (where i am now), which only involved making a sudoku program.
|
|
|
|
|
|
#10 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Actually, chat clients typically talk to each other through a common server, which handles the traffic. Nothing says you can't rig up two machines to talk to each other, though, just about any way you like. You need to research sockets. Here's a link to Beej. Even though it's Unix specific, it's highly applicable to Windows machines, also, with just a little effort.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|