| 755 | // --------------------------------------------------------------------------- |
| 756 | |
| 757 | void DoMovement(game_controls *controls) { |
| 758 | controls->sideways_thrust = 0.0f; |
| 759 | controls->vertical_thrust = 0.0f; |
| 760 | controls->forward_thrust = 0.0f; |
| 761 | controls->pitch_thrust = 0.0f; |
| 762 | controls->bank_thrust = 0.0f; |
| 763 | controls->heading_thrust = 0.0f; |
| 764 | controls->afterburn_thrust = 0.0f; |
| 765 | |
| 766 | // only read controls in game interface mode. |
| 767 | if (Game_interface_mode != GAME_INTERFACE) |
| 768 | return; |
| 769 | |
| 770 | // keyboard (always do this first.) |
| 771 | if (!Doing_input_message) |
| 772 | DoKeyboardMovement(controls); |
| 773 | |
| 774 | // controller |
| 775 | DoControllerMovement(controls); |
| 776 | |
| 777 | // clip controller values |
| 778 | if (controls->pitch_thrust > LIMIT_PITCH) |
| 779 | controls->pitch_thrust = LIMIT_PITCH; |
| 780 | if (controls->pitch_thrust < -LIMIT_PITCH) |
| 781 | controls->pitch_thrust = -LIMIT_PITCH; |
| 782 | if (controls->heading_thrust > LIMIT_HEADING) |
| 783 | controls->heading_thrust = LIMIT_HEADING; |
| 784 | if (controls->heading_thrust < -LIMIT_HEADING) |
| 785 | controls->heading_thrust = -LIMIT_HEADING; |
| 786 | if (controls->bank_thrust > LIMIT_BANK) |
| 787 | controls->bank_thrust = LIMIT_BANK; |
| 788 | if (controls->bank_thrust < -LIMIT_BANK) |
| 789 | controls->bank_thrust = -LIMIT_BANK; |
| 790 | if (controls->sideways_thrust > LIMIT_HORIZ) |
| 791 | controls->sideways_thrust = LIMIT_HORIZ; |
| 792 | if (controls->sideways_thrust < -LIMIT_HORIZ) |
| 793 | controls->sideways_thrust = -LIMIT_HORIZ; |
| 794 | if (controls->vertical_thrust > LIMIT_VERT) |
| 795 | controls->vertical_thrust = LIMIT_VERT; |
| 796 | if (controls->vertical_thrust < -LIMIT_VERT) |
| 797 | controls->vertical_thrust = -LIMIT_VERT; |
| 798 | |
| 799 | if (controls->forward_thrust > LIMIT_FORWARD) |
| 800 | controls->forward_thrust = LIMIT_FORWARD; |
| 801 | if (controls->forward_thrust < -LIMIT_FORWARD) |
| 802 | controls->forward_thrust = -LIMIT_FORWARD; |
| 803 | |
| 804 | if (controls->afterburn_thrust > LIMIT_FORWARD) |
| 805 | controls->afterburn_thrust = LIMIT_FORWARD; |
| 806 | if (controls->afterburn_thrust < -LIMIT_FORWARD) |
| 807 | controls->afterburn_thrust = -LIMIT_FORWARD; |
| 808 | |
| 809 | mprintf_at(1, 5, 30, "ch:%.2f ", controls->heading_thrust); |
| 810 | |
| 811 | // if (controls->pitch_thrust || controls->heading_thrust) |
| 812 | // mprintf(0, "p:%.2f h:%.2f\n", controls->pitch_thrust, controls->heading_thrust); |
| 813 | } |
| 814 |
no test coverage detected