Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: TCP or UDP for a simple pong game, and help designing loop?  (Read 4913 times)

0 Members and 1 Guest are viewing this topic.

keyforge

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Hello everyone, just thought I would introduce myself. I am new here at the SFML Forums. I'm a beginning game programmer and have a small amount of experience with C++ and I know the basics of networking.

Which would be more suitable for a simple online pong game with a chat, UDP or TCP? And UDP or TCP for the chat too? Setting up multiple streams would probably be wise if I were to do so.

I'm lost with networking with my game loop. What I'm thinking is a design like:  

main
  engine::network::setup();
  engine::game::run();
 
And for my Update method within my engine, and please note this is not real code and is just a design document:

Code: [Select]

engine::game::tick() {
  while(myWindow.IsOpened()
    while(myWindow.GetEvent())
      currentState.HandleEvents();
      engine::network::SendData();
      myWindow.Clear();
      currentState.Draw();
      myWindow.Display();
    }
  }
}


Criticism is welcome :)

Also, should my server and client be separate programs? Or should I just assign a server to the person who starts the game? How would that implement into the loop?

Also, anyone with articles to share please share them :)
Need a place to upload your code, files or screenshots? Use SFML Uploads!

GatorQue

  • Newbie
  • *
  • Posts: 36
    • View Profile
Networking article
« Reply #1 on: June 04, 2011, 10:53:09 pm »
Hey,

I'm somewhat new to SFML as well, and I have found this article (see link below) to be very useful in terms of describing networking.  You might also enjoy looking at my Basic Game Engine Wiki Tutorial.  I'm working on a simple Asteroids game that I hope to expand into something bigger and I hope to include networking as part of the game as well.

http://gafferongames.com/networking-for-game-programmers/

keyforge

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
TCP or UDP for a simple pong game, and help designing loop?
« Reply #2 on: June 08, 2011, 07:30:31 pm »
Thanks!

I've looked through your game engine before and it's very well written. It helped me get ideas on how to actually start writing a game engine and I have a Game class and a Logging Singleton class working now. I thank you greatly for it, as before I was very lost. My main goal was to create an asteroids / space shooter game (with multiplayer and ai?) as well! But I should probably start simple with Pong. Again, thanks!
Need a place to upload your code, files or screenshots? Use SFML Uploads!

 

anything