Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE mbed wave_player
Fork of MazeRunner_Fall2017-shell by
physics.h@1:2c6ae0fe9a2a, 2017-12-29 (annotated)
- Committer:
- navaem
- Date:
- Fri Dec 29 15:32:31 2017 +0000
- Revision:
- 1:2c6ae0fe9a2a
- Parent:
- 0:cf4396614a79
December 29, 2017;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rconnorlawson | 0:cf4396614a79 | 1 | #pragma once |
| rconnorlawson | 0:cf4396614a79 | 2 | |
| navaem | 1:2c6ae0fe9a2a | 3 | |
| rconnorlawson | 0:cf4396614a79 | 4 | /** |
| rconnorlawson | 0:cf4396614a79 | 5 | * The main state structure for the game. |
| rconnorlawson | 0:cf4396614a79 | 6 | * This structure holds all the global state for the game, and is updated during |
| rconnorlawson | 0:cf4396614a79 | 7 | * the game loop. When you implement the "jump back" feature, this is the |
| rconnorlawson | 0:cf4396614a79 | 8 | * structure you need to save/restore. |
| rconnorlawson | 0:cf4396614a79 | 9 | */ |
| rconnorlawson | 0:cf4396614a79 | 10 | struct Physics { |
| rconnorlawson | 0:cf4396614a79 | 11 | float px, py; // Ball position |
| rconnorlawson | 0:cf4396614a79 | 12 | float vx, vy; // Ball velocity |
| rconnorlawson | 0:cf4396614a79 | 13 | float ax, ay; // Ball acceleration |
| rconnorlawson | 0:cf4396614a79 | 14 | }; |
| rconnorlawson | 0:cf4396614a79 | 15 | |
| rconnorlawson | 0:cf4396614a79 | 16 | /** |
| rconnorlawson | 0:cf4396614a79 | 17 | * Performs one step of Forward Euler integration, given a time step delta. |
| rconnorlawson | 0:cf4396614a79 | 18 | * |
| rconnorlawson | 0:cf4396614a79 | 19 | * @param[out] out The structure to store the result of the integration. |
| rconnorlawson | 0:cf4396614a79 | 20 | * @param[in] in The current state of the system. |
| rconnorlawson | 0:cf4396614a79 | 21 | * @param[in] delta The time step, in seconds.s |
| rconnorlawson | 0:cf4396614a79 | 22 | */ |
| navaem | 1:2c6ae0fe9a2a | 23 | void forward_euler(Physics* state, float delta); |
| navaem | 1:2c6ae0fe9a2a | 24 | |
| navaem | 1:2c6ae0fe9a2a | 25 | |
| navaem | 1:2c6ae0fe9a2a | 26 | /* |
| navaem | 1:2c6ae0fe9a2a | 27 | *This function returns a copy of the current physics state |
| navaem | 1:2c6ae0fe9a2a | 28 | * in a different memory location |
| navaem | 1:2c6ae0fe9a2a | 29 | * |
| navaem | 1:2c6ae0fe9a2a | 30 | *@param Physics* curr the physics state to be copied |
| navaem | 1:2c6ae0fe9a2a | 31 | *@return Physics* the copy of the physics state |
| navaem | 1:2c6ae0fe9a2a | 32 | */ |
| navaem | 1:2c6ae0fe9a2a | 33 | Physics* copy_physics(Physics* curr); |
