Jump to content


2d multiplayer C++


11 replies to this topic

#1 akiosabt

    New Member

  • Members
  • Pip
  • 5 posts

Posted 13 May 2006 - 06:03 AM

hello everyone

after searching alot in the forum and getting some beginners tutorial about game programming in c++. i did not find one that will help me do what i need. Im a Professional php programmer but willing to go into c++ programming. Since c++ is oop i need to learn new things. Im not wishing to build the ultimate 3d mmo games yet. im willing to build a mini 2d "space invader" multiplayer style game. (to touch every face of game programmming) what i just learn getting the tuto was that i need a couple of thing:

1: a library to generate 2d graphic (or i could do that but will be too long)

2: a library that generate connection for a client-server network

3: alot of tutos on how to assemble that to create a game (tuto about c++ programming)

i have a question about number 2. since i program in php, there is no real time needed. but was looking on how the networking will work.. Im doing a space invader style game so my little space shuttle will have coordinate in the map. how does that coordinate are tranferate in my server, is it by a couple (x,y) and like the name of the map that will be stored in a database like sql ?? or its other things that i dont know about..

thanks for helping..

akiosabt

#2 Josh1billion

    Member

  • Members
  • PipPip
  • 76 posts

Posted 13 May 2006 - 07:02 AM

Are you trying to incorporate a C++ application into a PHP (+MySQL) script? It sounds like that's what you're trying to do, and I'm not sure if that's even possible.
Website :: Blog

Latest game release: Super Orbulite World
Current project: Stealth Prankster 2

#3 Almos

    Member

  • Members
  • PipPip
  • 99 posts

Posted 13 May 2006 - 08:25 AM

Since I'm new to these forums, I've still got a kind heart and am eager to help total C++ programming newbies. As to the resources: first and foremost, a programming book "C++ language" by Bjorne Stroustrup, the guy who made C++. It examines the vital concepts of C++ in depth. For easy start in the language, visit www.cplusplus.com and read their tutorials. They will teach you how, while Stroustrup's book will teach you why. When it comes to 2d graphics, there's a plethora of API's you can use, but whether you should choose them or not depends on the operating system your computer is running on: DirectX is the best choice for a Windows game, but if you're a Linux user, or if you want to make your application portable, choose either SDL (www.libsdl.org) or Irrlicht (I know that Irrlicht has some 2d functionality, although I haven't yet tested it, and probably never will :p)(irrlicht.sourceforge.net) . Now, young man, you know everything you need to get started. Prepare for an amazing journey into the world of problem solving, conceptual thinking, and last not least, banging at your keyboard when your apparently simple to code application doesn't compile or doesn't work as expected and you cannot bloody find why. :)
I want to make a game as good as Elder Scrolls oblivion with no programming, just point&click. If it's not possible, I want a team of programmers I'd be able to order around. After all, I'm a n00b.

#4 sagoga69

    New Member

  • Members
  • PipPip
  • 10 posts

Posted 13 May 2006 - 09:23 AM

I recommend you to use SDLlibrary for 2D graphics. I started learning it a week and a half ago, and I'm really happy with it. Personally, I haven't had any problem with programming with SDL on Windows, but may be I've had luck, I don't know.

#5 akiosabt

    New Member

  • Members
  • Pip
  • 5 posts

Posted 13 May 2006 - 04:22 PM

Josh1billion said:

Are you trying to incorporate a C++ application into a PHP (+MySQL) script? It sounds like that's what you're trying to do, and I'm not sure if that's even possible.

nope, thats not what i want to do.. the php thing was just to say that im not a beginner programmer. I want my game to be written all in C++. but maybe my c++ can interact with a sql datase with the coordinate of the space shuttle. need to understand that every pixel gonna be a diferent coordinate.. so thats why am not sure about coordinate because the game must be fluid enough...

#6 monjardin

    Senior Member

  • Members
  • PipPipPipPip
  • 1033 posts

Posted 13 May 2006 - 07:55 PM

Almos gave some good advice, and I would second the use of SDL.

A SQL database is probably overkill for the game you have in mind. Take a look at these networking links I put in the wiki: http://www.devmaster...etworking_links.
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*

#7 akiosabt

    New Member

  • Members
  • Pip
  • 5 posts

Posted 13 May 2006 - 08:18 PM

after researching on my side after posting i found that sending coordinate in mysql woulb be overkill like you said.. but what i will do is i will send the player score and name (with some other info) in a databse .. that way i can keep a rank of best player on the website..

thanks for the link... gonne read that tonigh.

edit : i got a question tho.. like i said in my first post.. i dont know how my entity will move in my world.. will it be a (x,y) coordinate with a degree of direction facing... or other thing like that.. because i need to know what will be the best thing for my game to be fluid... the game will be like "asteroid" but in a multiplayer way... the shuttle must move with certain physic restriction and stuff like taht.. if you have any info on where to begin ... woulb be grateful

thank you very much

akiosabt

#8 SmokingRope

    Valued Member

  • Members
  • PipPipPip
  • 210 posts

Posted 13 May 2006 - 09:40 PM

You could use a vector to represent your players orientation. You'll still need a coordinate pair to keep track of your players location though.

#9 Jack9

    Member

  • Members
  • PipPip
  • 37 posts

Posted 13 May 2006 - 09:50 PM

As a matter of fact I am in the exact same situation as the OP. I am a fulltime veteran PHP developer (since PHP/FI 1). I can scarcely recall my C++ Bnet bot experiences. However, I believe that the best course of action to rapidly producing a solid 2D multiplayer game would be to use Erlang for the server, C++ for clientside logic and (C++) HGE for graphics. I have tutorials covering how to do each...excepting the erlang server design is not really for a 2D game.

In fact, I have been keeping a journal until I have progressed enough to warrant a gamedev.net journal. Here is the excerpt from my first weekend of development.

05/06/06
12:00am

Last night I started on my project. About midnight

Before I even "started" I had to decide on what it was going to look like.

2D top-down or isometric. I installed GTA (oldschool) and saw that 2D with fake-perspective could work just fine. That decision is final.

I had to decide on a library to use. HGE or SDL.
I chose SDL for various reasons. I am not a C++ guru, so I had to go with who used it more. There are more complete commercial games using SDL than HGE. SDL wins. That decision is final.

Went and looked up a tutorial for SDL installing (I know it's just libraries, but like I said, I'm C++ newb and have no development environment). I came up with http://lazyfooproduc...rials/index.php (ta-da). I program in PHP, so that was nice to see. Perhaps his programming style and thought processes will be similar to mine.

Started on the tutorial. Choose an IDE? Um, Eclipse was what I used to use when i was writing a MASSIVE Java game that never got finished. Tutorial asks to copy random files to MinGW. I try visiting MinGW's webpage. On the frontpage it makes fun of itself and how near-impossible it is to figure out which packages you will need to download and install. What a SH*TTY website. I'm gonna try to go as far as I can without it. After awhile the tutorial is simply not reflecting reality. I'm missing some things which is basically a deathnell for a C++ environment. I try a couple different times with variations. It's all too complicated and C++ish for me to grasp. If I knew how to set up an environment, I wouldnt need the tutorial. If I didn't know how to set up an environment, an incomplete tutorial is a WASTE OF TIME DAMNIT. I look through the SDL tutorial webpages for a contact email.

Sent to the author lazy foo:
> I am starting on my first 2D game and I chose SDL over HGE,
> primarily for the multimedia and input control.
> I have very little practical C++ experience, but I am partially
> familiar with Eclipse from some 400k lines of Java I wrote back in
> Eclipse 1.2.
> I am just lost on your tutorial which doesnt seem to apply to
> Eclipse 3.1 and SDL 1.2.9
>
> I don't have any gcc installed (I can see you mouthing the words
> "so go get it"). You mention copying some files over to a C:\minGW\
> but minGW is by far the most confusing thing to try to set up. I'd
> need a whole tutorial just to know what to D/L from the MinGW
> webpage, much less how to install it BEFORE I start on the
> Eclipse/SDL install. Could you possibly help in putting up an
> Eclipse tutorial for another compiler or a walkthru on how to set
> up MinGW/Eclipse/SDL from nothing? Cause that's what I have.


3:00am

----

Still 05/06/06

8:30am

Yay for people who are serious about "will respond within 24 hours". Hell, I dont even CHECK my email in Outlook when it's open at work all day long. If you need to get ahold of me you know how. My phone. My AIM. My YahooMsg if I'm at work.

Response to Jack9:

>Just a warning, setting up the CDT plugin on eclipse is a pain in the
>ass on windows:
>http://met.dnsalias....1111/howto/cdt/
>That should get the CDT plugin installed and then you can start my tutorial.
>
>Also don't start using SDL if you're not profecient in C++. Read the
>FAQ to see how much you need to know.


Which FAQ is he referring to? None of the SDL FAQs cover "how much you need to know", neither do any of the dnsalias pages have a FAQ. His site doesnt have a FAQ. I have to consider that this guy is telling me that people who are competent enough in C++ to use his incomplete tutorial without assistance are the real people that will be using SDL. I am officially scared off. I will switch to HGE. This decision is final.

Following the happy dnsalias guide, I get a nice windows MinGW compiler with MSYS and all the other doodads you need to get g++ working on windows. yay. I have installed/deleted Eclipse about 4 times now. The environment kept giving me cygpath warnings and wouldnt compile. Eclipse likes to look through and configure itself for the popular compilers that are installed on your machine. I have must have (correctly/incorrectly?) installed 2 compilers (cygwin, Dev-C++) in the past, so I have deleted those directories and am trying AGAIN.

Extract Eclipse from tar.gz
Copy eclipse folder into my CodeBase folder
Start eclipse
Select my codebase folder as my workspace
Install CDT (C-development-toolkit using dnsalias guide). Eclipse does not come with native C/C++ support. Nice. But like I said; done this about 4 times before.
Restarts Eclipse
New Managed C++ project. Same warning. Sigh.
Looked up the cypath problem on Eclipse.org. It's a native problem to the CDT on Eclipse when using MinGW. Nice again.

Trying to start the first HGE tutorial code anyways.

Copied the headers into the MinGW\include folder
Copied the libs into the MinGW\libs folder

<SNIP 6 HOURS OF FRUSTRATION AS TO WHY HGE TUTORIALS WONT COMPILE /SNIP>

Decided to walk through the SDL tutorial again, now that I've been fiddling with HGE awhile. I may be a C++ newb, but I'm still a competent programmer. I can solve this. Saw something interesting regarding SDL requiring you to add mingw, SDLmain, SDL (in that order!) to the C++ linker to get it to compile the first SDL tutorial.
!Click!
Added mingw, HGE to the C++ linker.

It compiled. I ran it. It works. Oh joy.
---

My AIM is Jack9HC, feel free to ask about how to set up HGE for Eclipse or if you have any questions about why I chose the tools I have.

#10 akiosabt

    New Member

  • Members
  • Pip
  • 5 posts

Posted 13 May 2006 - 11:35 PM

yep.. the vector idea is good. but where i will store that on the server... since i need to shoot these info to all player so the client can translate that in an enemy position (or friendly if they make alliance) need more info on that..

#11 monjardin

    Senior Member

  • Members
  • PipPipPipPip
  • 1033 posts

Posted 14 May 2006 - 01:52 AM

For an Asteroids clone, I would send orientation as a single byte. Enumerate your facings instead of using a floating-point angle. For example, if you limit the orientation to 64 directions then you can encode the heading in 6 bits. ;) I've played some fun ones that only use 16 positions (4 bits).
I'd also plan on sending velocity (dx/dy) for client-side interpolation.
You need to decide on a topology first (client-server, peer-to-peer, etc).
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*

#12 akiosabt

    New Member

  • Members
  • Pip
  • 5 posts

Posted 14 May 2006 - 02:16 AM

thanks for reply

i will use client-server because i want that all "official" game must be monitered (sending info on score to mysql database) the player will be able to create local game but they will not appear in the list of actual game in the server. Need to have a database too because in way future i want to integrate rpg style in it (like you can custumize your space ship with new gun that cost Y and need X speed) stuff like that. will check tonight about the 6 or 4 bits.. ( i actually dont know you can insert stuff in the byte and how you send it ... like i said before.. its my first time entering a real time world using a screen ( the windows with the game in it) php is only text based... also, im canadian french and my english is so-so. i know about physic in french but some word i cant understand.

thats waht i understand in your message:

1: creating a 16 direction for my shuttle
ex
\ | /
- S -
/ | \

while S is the shuttle .. and the line the direction (cannot do 16 direction.. srry)
i get this info with the coodinate and send this to the server.. this will be resent to other client and interpret as an other shuttle.

if i understand what velocity and interpolation is in french: i need to send the speed that my shuttle is going in that direction (do not need to send the acceleration detail since they are going to be in client with max speed and other info)

if i can do that firts.. will be good. i will add attack and other thing later..

please.. tell me if anything wrong in my logic.. :huh:

thanks

p.s. i promise i will do a tutorial (maybe video) on how to do that after.. for beginner like me :happy:

edit : must precise that my database will only hold the space shuttle caracteristic, the score of the player and stuff like that.. like i said before.. the game info like coordinate will be store in another way that i will learn just now..

edit2: after reading a bit .. do i need to store the coordinate info ?? after all, once they are on the server they are redirected immediatly to the other player





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users