I am making a 2D network game. The concept is simple, a player have to shoot the other player to win. I'd like to improve this game ( add a map, items, monsters, w/e ), but later.
This is my first network programming experience. I have little theorical knowledges about packets, sockets, client/server side, what is dangerous to do client sided, but I've never really used them.
Goals set :
- This is a 2 players LAN game, no more no less.
- No server. Player 1 starts the game waiting for player 2...
- ... which leads the game open for reverse engineering or packet editing, but w/e, for this kind of game I prefer simplicity over security.
Pretty basic. For a first network game that will never be shared, I take off problems and will see later.
This is where I am : each player is a square that can move in four directions. The approach :
- TCP Packets.
- Each movement ( each frame a key is pressed to be accurate ), a packet is sent to the other player with his position.
- Packets are received each frames before drawing and updating game elements, in the same thread, with a non-blocking receive() function.
And that's it.
My questions :
- Is sending a packet for each moves overkill? Will I have problems with this later?
- What kind of problem can I meet? mono-thread + non blocking function will be a problem later, assuming the goals I've set?