hi guys,
i am trying to implement a multiplayer snake game on the same machine where each player can see the same map, control his own snake. but i do not really see a concrete idea for managing multiplaying aspect.
can you share your thoughts about it?
so far, there are few things i tried to came up with.
1. on execution, a program checks if host(server) is online, if true, join the game, else create the arena.
a)create arena: it will use standard window (stdscr, using ncurses), it will create a snake and places there, then I think i should create a structure boardMAP and pass snakes and power up fruit to a method that would fill that boardMAP up.
if movement happens, games pauses (nano seconds), each snake on the map writes its on snake structure (location of body, length, etc) to certain memory segment (parallel, to different locations, lets sanke snake1 to memloc1, snake2 memloc2 so on), then host will read that data (FIFO principle?), it will analyze map, players (collision detection, progress move step etc), then it will write back to certain memory back, and the clients (and host) will read from that memory and print whats in there on their own screens.
b)joins: it checks for the host, waits for the next pause, when all the snakes made their mvoe and collision detection passed, it will show a flag that "hey, iam waiting to join", then host will take that guy and place him somewhere on the map.
and so on in that matter. what do you think about it?
i am trying to implement a multiplayer snake game on the same machine where each player can see the same map, control his own snake. but i do not really see a concrete idea for managing multiplaying aspect.
can you share your thoughts about it?
so far, there are few things i tried to came up with.
1. on execution, a program checks if host(server) is online, if true, join the game, else create the arena.
a)create arena: it will use standard window (stdscr, using ncurses), it will create a snake and places there, then I think i should create a structure boardMAP and pass snakes and power up fruit to a method that would fill that boardMAP up.
if movement happens, games pauses (nano seconds), each snake on the map writes its on snake structure (location of body, length, etc) to certain memory segment (parallel, to different locations, lets sanke snake1 to memloc1, snake2 memloc2 so on), then host will read that data (FIFO principle?), it will analyze map, players (collision detection, progress move step etc), then it will write back to certain memory back, and the clients (and host) will read from that memory and print whats in there on their own screens.
b)joins: it checks for the host, waits for the next pause, when all the snakes made their mvoe and collision detection passed, it will show a flag that "hey, iam waiting to join", then host will take that guy and place him somewhere on the map.
and so on in that matter. what do you think about it?
Comment