Algorithm for Client-Server Games

后端 未结 6 1557
谎友^
谎友^ 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:23

    It would be something like

    Client:

    while( user does not exit )
        check for user input
        send commands to the server
        receive updates about the game from the server
        draw graphics
        play sounds
    end
    

    Server:

    while( true )
        check for client commands
        run AI
        move all entities
        resolve collisions
        send updates about the game to the clients
    end
    

提交回复
热议问题