[][src]Module rusty_sword_arena::game

Everything in the game module is shared by the server and the client

Structs

ButtonProcessor

Stateful, stack-based button processor. You can use this to process button state/values and update a PlayerInput that you can send to the server. Also handles the attack button.

GameSettings

The game settings. Mostly useful if you want to try to write client-side animations that match server simulation, movement prediction, AI, etc.

GameState

Once per frame, the server will broadcast a GameState to all clients. IMPORTANT: If you don't receive a GameState for 2 full seconds, the client MUST DROP its ServerConnection (or just exit entirely). The underlying networking that we're currently using hides network disconnects, which can leave the networking in a funky state if one end drops. So we need to rely on detecting this heartbeat and shutting down the clients to ensure networking is clean when the server restarts. (In the future, lets switch to a protocol that can detect disconnects...)

HighScores

High Scores! High scores are reset every time the server restarts, but other than that they are persistent across joins/leaves.

PlayerInput

Clients should send PlayerInputs to the server often. The quicker the server gets inputs, the more accurate the simulation will be. But of course, you also shouldn't overload the server with too much traffic, because that's bad too. Good rule of thumb: Coalesce 15 milliseconds worth of input together, and send that. That's just faster than frames are sent by the server (60fps = 16.7ms). The server should be able to handle ~67 pkts/sec per client. I hope.

PlayerState

Represents the state of the player on the server for the current GameState. The server always creates PlayeStates, updates them, and sends them to the client each frame inside a GameState. The client is free to modify its local copy (for example, to remove PlayerEvents it has processed) -- a new set of PlayerStates will be delivered the next frame. Clients typically look at the fields, drain and process the player events, but don't call any of the methods (since the methods are for server-side updates). You could potentially do your own updates just for prediction or AI purposes, though.

Score

A single player's score

Weapon

A weapon a player may hold.

Enums

GameControlMsg

Various game control actions. Used by the networking module and the server.

PlayerEvent

A player event that has happened to your player this frame! Note that it's possible to receive a whole bunch of events in the same frame.

Traits

Floatable

Convenience trait that adds an .f32() method that returns a 32-bit float representation of something. Implemented for std::time::Duration and rusty_sword_arena::timer::Timer.