[Add] Wheels up/down transition.
This commit is contained in:
parent
d0bbe9df73
commit
1e48dbafe5
BIN
icons/wheels_down.png
Normal file
BIN
icons/wheels_down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 460 B |
BIN
icons/wheels_up.png
Normal file
BIN
icons/wheels_up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 454 B |
14
src/ship.cpp
14
src/ship.cpp
@ -7,6 +7,8 @@
|
||||
#include "space.h"
|
||||
|
||||
Ship::Ship(ShipType::Type shipType) : RigidBody() {
|
||||
m_wheelTransition = 0;
|
||||
m_wheelState = 0;
|
||||
m_dockedWith = 0;
|
||||
m_mesh = 0;
|
||||
m_shipType = shipType;
|
||||
@ -95,6 +97,12 @@ void Ship::AITurn(void) {
|
||||
dGeomSetData(ray, static_cast<Object*>(&m_laserCollisionObj));
|
||||
m_tempLaserGeom[i] = ray;
|
||||
}
|
||||
|
||||
if(m_wheelTransition != 0.0f) {
|
||||
m_wheelState += m_wheelTransition*timeStep*0.001;
|
||||
m_wheelState = CLAMP(m_wheelState, 0, 1);
|
||||
if((m_wheelState == 0) || (m_wheelState == 1)) m_wheelTransition = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const ShipType& Ship::GetShipType(void) {
|
||||
@ -124,6 +132,11 @@ void Ship::SetGunState(int idx, int state) {
|
||||
m_gunState[idx] = state;
|
||||
}
|
||||
|
||||
void Ship::SetWheelState(bool down) {
|
||||
if(down) m_wheelTransition = 1;
|
||||
else m_wheelTransition = -1;
|
||||
}
|
||||
|
||||
/* Assumed to be at model coords. */
|
||||
void Ship::RenderLaserfire(void) {
|
||||
const ShipType& stype = GetShipType();
|
||||
@ -167,6 +180,7 @@ void Ship::Render(const Frame* camFrame) {
|
||||
params.pAnim[ASRC_MINFRAC] = L3D::GetGameTime() / 60;
|
||||
params.pAnim[ASRC_HOURFRAC] = L3D::GetGameTime() / 3600.0f;
|
||||
params.pAnim[ASRC_DAYFRAC] = L3D::GetGameTime() / (24*3600.0f);
|
||||
params.pAnim[ASRC_GEAR] = m_wheelState;
|
||||
|
||||
strncpy(params.pText[0], GetLabel().c_str(), sizeof(params.pText));
|
||||
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
const ShipType& GetShipType(void);
|
||||
void CalcStats(shipstats_t* stats);
|
||||
void UpdateMass(void);
|
||||
void SetWheelState(bool down);
|
||||
|
||||
class LaserObj : public Object {
|
||||
public:
|
||||
@ -45,6 +46,9 @@ protected:
|
||||
ObjMesh* m_mesh;
|
||||
Uint32 m_gunState[ShipType::GUNMOUNT_MAX];
|
||||
private:
|
||||
float m_wheelState;
|
||||
float m_wheelTransition;
|
||||
|
||||
float m_thrusters[ShipType::THRUSTER_MAX];
|
||||
float m_angThrusters[3];
|
||||
dGeomID m_tempLaserGeom[ShipType::GUNMOUNT_MAX];
|
||||
|
@ -11,6 +11,13 @@ static const float lightCol[] = { 1, 1, .9, 0 };
|
||||
WorldView::WorldView(void): View() {
|
||||
SetTransparency(true);
|
||||
|
||||
Gui::MultiStateImageButton* wheels_button = new Gui::MultiStateImageButton();
|
||||
wheels_button->SetShortcut(SDLK_F7, KMOD_NONE);
|
||||
wheels_button->AddState(0, "icons/wheels_up.png");
|
||||
wheels_button->AddState(1, "icons/wheels_down.png");
|
||||
wheels_button->onClick.connect(sigc::mem_fun(this, &WorldView::OnChangeWheelsState));
|
||||
m_rightButtonBar->Add(wheels_button, 34, 2);
|
||||
|
||||
m_hyperspaceButton = new Gui::ImageButton("icons/hyperspace_f8.png");
|
||||
m_hyperspaceButton->SetShortcut(SDLK_F8, KMOD_NONE);
|
||||
m_hyperspaceButton->onClick.connect(sigc::mem_fun(this, &WorldView::OnClickHyperspace));
|
||||
@ -37,6 +44,10 @@ WorldView::WorldView(void): View() {
|
||||
glEndList();
|
||||
}
|
||||
|
||||
void WorldView::OnChangeWheelsState(Gui::MultiStateImageButton* b) {
|
||||
L3D::player->SetWheelState(b->GetState());
|
||||
}
|
||||
|
||||
void WorldView::OnClickHyperspace(void) {
|
||||
StarSystem* s = L3D::GetSelectedSystem();
|
||||
if(s /* && isn's current system. */) {
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
|
||||
private:
|
||||
void OnClickHyperspace(void);
|
||||
void OnChangeWheelsState(Gui::MultiStateImageButton* b);
|
||||
Gui::ImageButton* m_hyperspaceButton;
|
||||
GLuint m_bgstarsDlist;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user