2013/06/11

PA7 - Moving Ships

First, I began moving ships by adding NetworkStateData to the Queuing system which broadcasts the network state and the game's winner. I also modified GameScene so that it only adds ships for players in the lobby. After doing this, I noticed the following anomalies:
If I start a lobby with only one player, I can move the blue ship correctly, I can shoot lasers and place mines, and the fences work. Note that this is still entirely networked.
However, when a player joins:
Input from both machines binds to the green player, the ship cannot move (only turn), and if by some chance I get velocity on a ship, it gets stuck in the fences until I drive the other way.
The inappropriate binding was caused by assigning the machine-specific GamerIndex every time the Gamer Joined event fired, so I used e.Gamer.IsLocal. The ship unable to move is due to my early version of prediction that works as follows:

  1. If the ship is not moving, send one packet.
  2. When the packet is received, start moving the ship according to that packet and repeat that movement sender-side as long as a key is down (unless it's a laser or a mine).
  3. When a key is released pertaining to that type of movement, send a packet updating the other players.
The problem is that though the prediction works for the sender, it does not loop like this for the receiver. When two players are in the game, the packets deadlock each of them.

I am now making it so that the sender only sends packets for his own events, and I'll have to figure out some way of automating movement on the receiver-side as well.

Strange bug, the blue ship fires green lasers but places blue mines. Upon looking into this, I discovered that I had removed the index parameter from the laser respawn method (and the mine method, but that magically works). I understand why the original developer uses a queue to reduce coupling, but I would have made two queues per player because each laser and mine should intrinsically belong to one player each.

No comments:

Post a Comment