The sprite system currently works by splitting an entire character's spritesheet into separate pieces called **vanity items**. These items are created by each vanity factory ([example](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/edu/ship/engr/shipsim/view/player/PlayerHatFactory.java)), then added as actors to the worldstage and moved individually each time the player moves.
The sprite system currently works by splitting an entire character's spritesheet into separate pieces called **vanity items**. These items are created by each vanity factory ([example](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/edu/ship/engr/shipsim/view/player/PlayerHatFactory.java)), then added as actors to the worldstage and moved individually each time the player moves.
## Layering
## Layering
Since all the sprites are rendered as separate pieces, they must be layered in the game world in a specific order so they show up correct. For example, when facing north a character's hat should appear behind them and their hair below the hat. However, when facing south, the opposite should occur. This problem is solved in the system by a comparable function in [Vanity](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/view/player/Vanity.java) which uses the order of vanities in the [Direction](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/view/player/Direction.java) enum to order them in the worldstage.
Since all the sprites are rendered as separate pieces, they must be layered in the game world in a specific order so they show up correct. For example, when facing north a character's hat should appear behind them and their hair below the hat. However, when facing south, the opposite should occur. This problem is solved in the system by a comparable function in [Vanity](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/edu/ship/engr/shipsim/view/player/Vanity.java) which uses the order of vanities in the [Direction](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/edu/ship/engr/shipsim/view/player/Direction.java) enum to order them in the worldstage.
## PlayerSprite and Vanity relationship
## PlayerSprite and Vanity relationship
PlayerSprite is a class that holds each and every vanity the player is currently wearing, holds general information about the player's current facing, position, etc, and allows the vanity items to be controlled as a whole, rather than individual pieces. This functionality is most useful for teleportation or for gathering quick information about the player's sprites without having to know about each vanity item.
PlayerSprite is a class that holds each and every vanity the player is currently wearing, holds general information about the player's current facing, position, etc, and allows the vanity items to be controlled as a whole, rather than individual pieces. This functionality is most useful for teleportation or for gathering quick information about the player's sprites without having to know about each vanity item.