         guard !state.gameIsOver else {
             return
         }
+        updateEventQueue()
         updateObstaclePositions()
         handleCollisions()
         updatePlayerStates()

    
    private var timeStep = 0
    private var lastObstacleTimeStep: Int?
    
    init(playerNumber: Int, seed: Int? = nil, isMultiplayer: Bool, peers: [MCPeerID]) {
        obstacleGenerator = ObstacleGenerator(seed: seed)

    private func insertPlayer(player: Player) {
        state.players.append(player)
    }
    
    private func appendToEventQueue(event: GameEvent, playerNumber: Int, occurringTimeStep: Int) {
        eventQueue.append((event: event, playerNumber: playerNumber, timeStep: occurringTimeStep))
        eventQueue.sortInPlace { $0.timeStep > $1.timeStep }
    }
}

// MARK: GameNetworkPortalGameStateDelegate
extension LogicEngine: GameNetworkPortalGameStateDelegate {
    func jumpActionReceived(data: AnyObject, peer: MCPeerID) {
        guard let playerNumber = state.peerMapping[peer],
            dataDict = data as? [String: AnyObject] else {
            return
        }
        guard let timeStepOccurrenceString = dataDict["time_step"] as? String else {
            return
        }
        guard let occurringTimeStep = Int(timeStepOccurrenceString) {
            return
        }
        appendToEventQueue(.PlayerDidJump, playerNumber: playerNumber,
                           occurringTimeStep: occurringTimeStep)
    }

    func duckActionReceived(data: AnyObject, peer: MCPeerID) {
        guard let playerNumber = state.peerMapping[peer],
            dataDict = data as? [String: AnyObject] else {
                return
        }
        guard let timeStepOccurrenceString = dataDict["time_step"] as? String else {
            return
        }
        guard let occurringTimeStep = Int(timeStepOccurrenceString) {
            return
        }
        appendToEventQueue(.PlayerDidDuck, playerNumber: playerNumber,
                           occurringTimeStep: occurringTimeStep)
    }

    func collideActionReceived(data: AnyObject, peer: MCPeerID) {

    }

    func gameStartSignalReceived(data: AnyObject, peer: MCPeerID) {
        if let player = gameState.getPlayer(withPeerID: peer) {
            player.ready()
        }
    }

    func gameEndSignalReceived(data: AnyObject, peer: MCPeerID) {

    }
}