Android Tutorial Class example - Galaxy system emulation

This "galaxy" example simulates planets movements based on the gravity forces.

The purpose of this example is to demonstrate the usage of classes in a graphical program.

SS-2012-07-09_15.45.55.png


Each star holds a reference to a list of stars which are considered the star "moons". On each timer tick event the gravity force is calculated between each star and its moons and then all the stars are redrawn in their new position.

The user can change the gravity constant which affects the gravity force.

It is recommended to test this example on a real device (in Release mode).

This example can be easily modified to show more stars in different positions and velocities. This is an advantage of using classes. You can easily instantiate any number of Star objects.
 

Attachments

  • Stars.zip
    8 KB · Views: 1,129
Top