Progress:
This week we made a lot of progress toward the user interface of the app. We added some functionality to the buttons and created some visual queues for body selection and launching.
All of the button functionality improvements were already talked about in detail in previous posts this week. Besides attaching some function calls to a few of the buttons (such as adding bodies), we also implemented a slider for adjusting mass.
The next major update was the adding of a visual queue for selection. The selected body gets highlighted. This was done by extending our DynamicSprite class to create a BodyHighlight class. BodyHighlight overrides the update() method so that it can update the location of the highlight sprite to lay on top of the DynamicSprite (which lays over the body). The highlight sprite is basically just a semi-transparent yellow circle with dimensions slightly larger than the body it’s covering. This creates the following effect:
Here, the small body in the bottom of the screen is selected. |
The complete code can be found here:
The last major improvement we added was a simulator to predict how a body will be launched. This uses Euler’s method to take into account the forces from all of the other bodies given a specific launch velocity. With every step (TIME_STEP), the position is updated based on the previous step’s velocity and the velocity is updated based on the forces acting on the body in its new (simulated) location. The code responsible can be found here (look at the doSimulation() method:
The dots show a simulation of the launch before it happens. |
Future Plans
We’ve mentioned this already but we really need to start focusing on scale and units. We are working on optimizing the scale of the numbers (distance, mass, gravitational constant, etc) so that users can experiment and see realistic results. If we didn’t do this, all of the bodies would be incredibly far away from each other. If you wanted to see multiple planets at the same time, they wouldn’t even be a pixel in diameter. It would also literally take years for a model of the earth to orbit the sun. We also want to add informational menus that will pop up where users can see numbers for velocities, distances, and masses. If we’re going to do this, we need to decide where in our code we want to convert units so that the user is presented with the realistic values. It doesn’t matter if the simulation uses drastically different numbers than the user actually sees as long as the user sees realistic numbers. The main reason we have to do these conversions is because libGDX and box2D have a speed limit of moving bodies 2 units per frame. We just need to decide what these units should be so that it works out the way we need it to.
Moving forward, we also need to finish up the menu and optimize everything for mobile devices. These things are all obviously easier said than done and it’s going to be a lot more work than it looks like on paper. However, we are definitely approaching our deadline and we need to start wrapping things up. I think we’re in good shape.
No comments:
Post a Comment