poke capture

Upload: grender5

Post on 02-Jun-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Poke Capture

    1/12

    PokeCaptureSNCHEZ TORREGROSA, LVARO1405091

  • 8/10/2019 Poke Capture

    2/12

    Content

    The Idea Network Architecture

    Application-level protocol

    UDP

    Network API

    Structure of the Code Structure of the Network

    Prediction & Interpolation

    Effectiveness

    Changes

  • 8/10/2019 Poke Capture

    3/12

    The Idea

    The game is based on the famous pokemon video games

    Two players appear on the scene, they see each other but nothingelse

    Their objective is to find the hidden pokeball and then the hiddenpokemon to win the game

  • 8/10/2019 Poke Capture

    4/12

    Network Architecture

    Peer-to-Peer (few players)

    Broadcast (few players)

    Hybrid multi-server (Small world)

    Hybrid client/server (no scalability required)

    The selected arquitecture is clientserver

    Both clients need to connect to the server and then will wait until theother player is ready

    All the movement, or actions will be sended from the client to the serveand then him will check if the operation can be executed and then wianwer the clients

  • 8/10/2019 Poke Capture

    5/12

    Application-level protocol

    There are 2 Data Structures that are shared between the client andthe server:

    StateMessage Win, lose, Start Game, FirstConnection

    GameMessageMovement, Pokeball Collected, Pokemon Collected

  • 8/10/2019 Poke Capture

    6/12

    UDP

    The application runs with non-blocking UDP sockets. Which means Less reliability (package loss)

    Better latency (since TCP deliberately delays and merges packets) butUDP just send them)

    Easy to stablish (you dontneed to accept all the connections sinceUDP sockets arentconnected all the time)

    Only one socket on the server side instead of a list of connections

  • 8/10/2019 Poke Capture

    7/12

    Network API

    WinSock Previously used

    Rich Documentation

    Internet full of examples and discussions about it

    Other alternatives

    SFML Networking

  • 8/10/2019 Poke Capture

    8/12

    Structure of the Code

    The main class of the code is called GameClass and handles allthe logic of the game.

    There is also an InputClass which handles the input of the playerand a GraphicClass who renders the screen.

    After those 3 clases there are data classes such as player, object,levelScene or collision and one important class called Client.

  • 8/10/2019 Poke Capture

    9/12

    Structure of the Network

    Client The Client is a singleton which 4 methods.

    SendStateMessage / SendGameMessage Send to the server the data

    ReceiveStateMessage / ReceiveGameMessage Receive a msg structureand returns it to the GameClass

    The GameClass is the one that analizes which type of message is and

    deals with it, modifying the proper logic to get the game working.

  • 8/10/2019 Poke Capture

    10/12

    Structure of the Network

    Server First of all it binds the socket and waits for an state message of First

    Connect, as son as he gets it he sends the player information to the clientand waits for the other one. Once he has the two clients he sends aGameStart (state Message) message

    After that he has 4 methods just like the client for receiving and sendingmessages depending on their type and just wait until he receives somethin

    then works with it and send-it back. The situations that he is ready to react are:

    Try to find Check if the player is near a hidden object then notifies the client

    Try to collect Check if the player has discover the object and is near it

    Win / Loose Check if the player has accomplish all the objectives of the gameand ends the game if itscorrect

  • 8/10/2019 Poke Capture

    11/12

    Prediction & Interpolation

    Linear Prediction When the player moves he sends a message of movement, then he

    wontsend a message until he stops moving or changes direction.

    The server will notify the clients the new position and then the client wilpredict the movement of the other player

    Interpolation

    If the client receives a movement message and the new position of theplayer is very different from the previous one the player will move fasteto the right position

  • 8/10/2019 Poke Capture

    12/12

    Changes

    How to deal with package loss Clients send a secuence number when they send an important message to

    the server (such as trying to find or trying to collect)

    The server needs to send the same secuence number as an answer

    If the client doesntreceive the secuence number it shows a message tellintry again, connection failed

    Synchronising animation when idle

    Now if the server update the position of the clients clients notice if the otheplayerhasntmade a move since the previous update and modifies hisanimation to an idle animation

    Reducing amoung of messages The client only send a message when they change direction of movement

    so the server considers that while he doesntreceive a change the player istill moving