martedì 2 agosto 2016

Orbit Duel

Un gioco dal concept inedito che ho sviluppato con Alessio, presi dal sacro fuoco della programmazione in python.

Segue descrizione, e questi sono i link per il download:

Orbit duel: the gravitational game

Orbit Duel (abbreviated in "Orbit 2l" because the number 2 in Italian is pronounced "due") is a game that simulates the orbitation of two satellites around a planet.

The starting position and speed of the two satellites is random, so in the common case the two satellites start to revolve around the planet on random trajectories. The contemplative players can observe the trajectories of the satellites, guessing if and when they will pass next to each other, and what will happen to them.
Sometimes orbits make beautiful patterns, such as those plotted by Spirograph. Satellites exercise gravitational force, so that when they get close to each other they exchange energy*.  In rare cases, they also exchange orbits.

Observing this gravitational dance is a good way to understand space physics, getting insight about what happen over our heads and how celestial bodies behave. Of course, this is a simplified environment, but the game reproduces laws of gravitation, so that several phenomena are observable.

Players interact with satellites trajectory through 4 direction keys (Arrows Keys for white and WASD Keys for red), making satellites accelerate towards specific directions. This gives to the player the possibility to change the satellite’s trajectory.
The game finishes when one of the satellites falls onto the planet surface, or if a satellite gets lost in space. In this case, it is possible to press Escape Key to end the match**.

The acceleration of the two satellites occurs through directional boosters powered by fuel. Remember that fuel is limited! If the player presses a direction key repeatedly, the first boost will be strong, the second of mid-strength, and the third weak. To regain boost power player has to wait for a few seconds. The available amount of fuel is visible on the top corners of the screen, where the number of the bars shows the boost power (the number of remaining shots) available. A beep sound announces when there is an increment of available power for one of the players.

A blue bar sometime appears underneath the power bars, to indicate that the player speed exceed escape velocity.
When this indicator flashes, is good to try to regain control of the satellite, because it is getting far from the central planet. Because of the simplified formula employed to compute escape velocity, in some cases (when the satellite’s orbit is particularly stretched) the blue bar can flash even there is no escape danger, but in this case it quickly switches off.

To simplify gameplay we implemented two control modes that can be switched by setting the GAME_OPT['CTR1_REL'] and GAME_OPT['CTR2_REL'] Boolean variables. We suggest that player set these variables as they find more intuitive.
In ABSOLUTE control mode (var:False) directions are relative to screen. This means that up, down, left, right arrows -or equivalent W,S,A,D keys- make satellite accelerate toward absolute UP (North), DOWN (South), LEFT (West) and RIGHT (East) direction.
In RELATIVE control mode (var:True) direction of acceleration is relative to current satellite velocity.
In this case the pressing of up, down, left, right arrows -or equivalent W,S,A,D Keys- make satellite accelerate in a direction relative to satellite current movement, like commands given to radio controlled cars. So UP make satellite accelerate in the current direction, DOWN make satellite decelerate, LEFT makes the satellite turn left and RIGHT turn right.

This is really an open issue for us, so that any suggestions and comments are welcome!
Simply speaking, a player loses when his or her satellite falls against the planet or gets lost into the infinite universe. But Newtonian laws do not allow that an object is shot (i.e. toward the planet) if another object is not shot in the opposite direction. For this reason, when satellites pass very close each other, they are never really safe, and we found that this situation leads to almost random effects.
We also found that when a satellite -follows- the other, the follower gains energy (elevating its orbit) at the expense of the other (which loses energy and lowers its orbit), so if initial orbit of the leader was low or stretched enough, it can fall onto the planet’s surface.
Technically, a satellite’s orbit meets the planet surface when its angular momentum (tangent speed) nullifies. In some cases, we observed that a satellite stops and falls "like an apple from the branch" after approaching to the other.
This is a happy situation for the other player, but we do not know how to transform this observation in a well-defined game strategy. We hope that a NASA operator can tell it to us one of these days… :)

Thank you, enjoy the game and give us feedback!

Christian and Alessio.


* In our system, energy of a satellite is the sum of gravitational potential energy (due to gravitational force of the planet and of the other satellite) plus kinetic energy. The simulation follows the law of conservation of energy, in a closed system total energy cannot increased or decreased, but only be transformed from a kind to another. We have also chemical energy of boosters that adds or subtracts energy to the system.
Effects of Keplero laws, the conservation of momentum and angular momentum (probably I forgot some other laws...) can be observed.

** In another version of the game we implemented a time control that automatically terminates the match if a satellite stays out of sight for more than 15 seconds, but we think that this "consensual end" of the game is more gracious.

1 commento:



Archivio blog