codingteam / Hyperspace

Simple 2D game written in Clojure and Kotlin.
MIT License
8 stars 4 forks source link

Project requirements #29

Closed ForNeVeR closed 6 months ago

ForNeVeR commented 7 years ago

Based on the current project state and its historical value (see #27), I propose the following.

Synopsis

Hyperspace should be a network multiplayer game for now designed for two players. It should consist of dedicated server application and a client application, both written in Clojure. Also, there should be a shared library of physical simulation functions used both by the client and the server code.

Game

Hyperspace is a turn-based physic simulator game. There're two players and a number of planets on the game field. Each player shoot a missile during each turn (but he could choose to skip the turn; that could also happen due to turn timeout); missiles behave as a bodies of mass in a static environment with Newtonian physics. Only missiles and planets have mass; missiles, planets and players also have a collision radius that should be taken into account by the simulation.

If the player is hit by enemy's missile, he's dead. If the missile hits the planet surface, then the missile explodes. If the missile hits the game world boundaries, it's considered "lost".

Player controls the shot power (in some diapason allowed by server) and direction.

The player turns are performed simultaneously. If both of the players are hit by enemy missiles at the same turn, the game is a tie.

Server

Server should provide HTTP API capable of:

When joining the game, server sends to the client a game key that should be used to schedule turns and query the game state.

When scheduling a turn, each client sends to the server their shot power and direction parameters.

When all the players in a game have been scheduled their turns, server simultaneously performs the turns.

When the client queries the game state, server sends the game map and the shot/direction history for each player. Shot information also contains a coordinates where the shot has been exploded and information whether any of players was hit by the collision.

Each game should have a round timeout. If any of the clients haven't scheduled their turn in time, their shooting phase should be skipped.

Client

Client is a desktop application. It should have two windows:

The game client should calculate the trajectory itself using the same library as the server, and render the missile at its way to the target. But it should respect server decisions on whether any of the players was hit by the bullet, and show the point where the server reported a bullet collision. (In general, server and client calculations should be almost the same, but they could differ due to floating point arithmetic; server obviously always have the priority in case of any desyncronization.)