Algorithm for Client-Server Games

后端 未结 6 1566
谎友^
谎友^ 2021-01-30 11:59

For stand alone games, the basic game loop is (source: wikipedia)

while( user doesn\'t exit )
  check for user input
  run AI
  move enemies
  resolve collisions         


        
6条回答
  •  旧巷少年郎
    2021-01-30 12:32

    The client part is basically the same, except replace

    run AI
    move enemies
    resolve collisions
    

    with

    upload client data to server
    download server updates
    

    And the server just does:

    while (game is running)
    {
        get all clients data
        run AI
        resolve collisions
        udpate all clients
    }
    

提交回复
热议问题