Specifically, I'm wondering if it would be possible to implement a network-based Tetris game using a REST API. The resources would be: current-block
, grid
, score
, etc... Moving a block would be a POST request on the current-block
resource with the arguments embedded in the request body. To get the current gamestate a GET request would be used, etc...
Does it make sense to do it this way?
Such approach would be fine for game like Chess, but it not so great for Tetris.
Tetris is a real-time game. To keep that aspect, either server would have to run the game and expect client to poll state very often, or the client would have to run game simulation, and then server isn't really needed.
For realtime game you usually need lower overhead message passing and streaming. This can be done over HTTP (COMET, Server-Sent events API, Web Sockets), but I wouldn't call it REST.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With