Class CollisionDetector



    Purpose

    Detect if collision would occur before a client wants to move.

    Functionality

    CollisionDetector first checks if the client has reached the boundary of the environment. If so, move is not allowed. Otherwise, it will check if the client will move from the current block to another block. If so, it will check the new block, otherwise it will check the current block. When checking a block, CollisionDetector checks if the client has reached a wall. If so, move is not allowed. Otherwise, move is allowed.

    If move is allowed, CollisionDetector will further detect if the client needs more new block data. If so, CollisionDetector will ask ReqSender to send map requests to the server and throw away those useless map data.

    Structure

    CollisionDetector has four methods: MoveUp(Player), MoveDown(Player), MoveLeft(Player), and MoveRight(Player). These methods are used to check if collision would occur when a client wants to move up, move down, move left, or move right respectively.




    [Go to Class Index Table] [Go back to Program Architecture Diagram]
    [Source Code of CollisionDetector.java]