Added look_back as a kart control, which means that the AI
karts can (though atm don't yet) fire backwards. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2871 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2601771c4d
commit
54cafb7f25
@ -118,16 +118,18 @@ void Camera::setMode(Mode mode)
|
||||
if(m_mode==CM_CLOSEUP)
|
||||
m_distance = 2.5f;
|
||||
else
|
||||
{
|
||||
m_distance = m_kart->getKartProperties()->getCameraDistance();
|
||||
{
|
||||
m_distance = m_kart->getKartProperties()->getCameraDistance();
|
||||
|
||||
// In 2 and 3 player mode we have a different FOV and would not see our
|
||||
// kart at the default distance. We use 1.5 times the distance to fix that.
|
||||
const int num_players = race_manager->getNumPlayers();
|
||||
if (num_players == 2 || num_players == 3)
|
||||
m_distance += m_distance / 2;
|
||||
}
|
||||
// In 2 and 3 player mode we have a different FOV and would not see our
|
||||
// kart at the default distance. We use 1.5 times the distance to fix that.
|
||||
const int num_players = race_manager->getNumPlayers();
|
||||
if (num_players == 2 || num_players == 3)
|
||||
m_distance += m_distance / 2;
|
||||
}
|
||||
} // setMode
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
Camera::Mode Camera::getMode()
|
||||
{
|
||||
return m_mode;
|
||||
@ -187,7 +189,7 @@ void Camera::update (float dt)
|
||||
// --------------------------------------------
|
||||
// The reverse mode and the cam used in follow the leader mode (when a
|
||||
// kart has been eliminated) are facing backwards:
|
||||
bool reverse = m_mode==CM_REVERSE || m_mode==CM_LEADER_MODE;
|
||||
bool reverse = m_kart->getControls().m_look_back || m_mode==CM_LEADER_MODE;
|
||||
Vec3 cam_rel_pos(0.f, reverse ? m_distance : -m_distance, 1.5f);
|
||||
|
||||
// Set the camera rotation
|
||||
|
@ -35,7 +35,6 @@ public:
|
||||
CM_CLOSEUP, // Normal camera, closer to kart
|
||||
CM_DRIFTING, // FIXME: drifting behind when accelerating = not yet implemented
|
||||
CM_LEADER_MODE, // for deleted player karts in follow the leader
|
||||
CM_REVERSE, // Camera is pointing backwards
|
||||
CM_FINAL, // Final camera to show the end of the race
|
||||
CM_SIMPLE_REPLAY
|
||||
};
|
||||
|
@ -31,9 +31,7 @@ Bowling::Bowling(Kart *kart) : Flyable(kart, POWERUP_BOWLING, 50.0f /* mass */)
|
||||
float y_offset = 0.5f*kart->getKartLength() + m_extend.getY()/2.0f;
|
||||
|
||||
// if the kart is looking backwards, release from the back
|
||||
PlayerKart* pk = dynamic_cast<PlayerKart*>(kart);
|
||||
const bool reverse_mode = (pk != NULL && pk->getCamera()->getMode() == Camera::CM_REVERSE);
|
||||
if( reverse_mode )
|
||||
if( kart->getControls().m_look_back )
|
||||
{
|
||||
y_offset = -y_offset;
|
||||
m_speed = -m_speed*2;
|
||||
|
@ -34,8 +34,7 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER)
|
||||
float y_offset = 0.5f*kart->getKartLength()+0.5f*m_extend.getY();
|
||||
|
||||
// if the kart is looking backwards, release from the back
|
||||
PlayerKart* pk = dynamic_cast<PlayerKart*>(kart);
|
||||
m_reverse_mode = (pk != NULL && pk->getCamera()->getMode() == Camera::CM_REVERSE);
|
||||
m_reverse_mode = kart->getControls().m_look_back;
|
||||
|
||||
// find closest kart in front of the current one
|
||||
const Kart *closest_kart=0; btVector3 direction; float kartDistSquared;
|
||||
|
@ -32,24 +32,21 @@ public:
|
||||
bool m_drift;
|
||||
bool m_rescue;
|
||||
bool m_fire;
|
||||
bool m_look_back;
|
||||
|
||||
KartControl() : m_steer(0.0f), m_accel(0.0f), m_brake(false),
|
||||
m_nitro(false), m_drift(false), m_rescue(false),
|
||||
m_fire(false)
|
||||
m_fire(false), m_look_back(false)
|
||||
{
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Construct kart control from a Message (i.e. unserialise) */
|
||||
KartControl(Message *m)
|
||||
{
|
||||
m_steer = m->getFloat();
|
||||
m_accel = m->getFloat();
|
||||
char c = m->getChar();
|
||||
m_brake = (c & 1) != 0;
|
||||
m_nitro = (c & 2) != 0;
|
||||
m_drift = (c & 4) != 0;
|
||||
m_rescue = (c & 8) != 0;
|
||||
m_fire = (c & 16) != 0;
|
||||
m_steer = m->getFloat();
|
||||
m_accel = m->getFloat();
|
||||
char c = m->getChar();
|
||||
setButtonsCompressed(c);
|
||||
} // KartControl(Message*)
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return the serialised size in bytes. */
|
||||
@ -73,11 +70,12 @@ public:
|
||||
/** Compresses all buttons into a single integer value. */
|
||||
char getButtonsCompressed() const
|
||||
{
|
||||
return m_brake ? 1 : 0
|
||||
+ m_nitro ? 2 : 0
|
||||
+ m_drift ? 4 : 0
|
||||
+ m_rescue ? 8 : 0
|
||||
+ m_fire ? 16 : 0;
|
||||
return m_brake ? 1 : 0
|
||||
+ m_nitro ? 2 : 0
|
||||
+ m_drift ? 4 : 0
|
||||
+ m_rescue ? 8 : 0
|
||||
+ m_fire ? 16 : 0
|
||||
+ m_look_back ? 32 : 0;
|
||||
} // getButtonsCompressed
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the buttons from a compressed representation.
|
||||
@ -85,11 +83,12 @@ public:
|
||||
*/
|
||||
void setButtonsCompressed(char c)
|
||||
{
|
||||
m_brake = (c & 1) != 0;
|
||||
m_nitro = (c & 2) != 0;
|
||||
m_drift = (c & 4) != 0;
|
||||
m_rescue = (c & 8) != 0;
|
||||
m_fire = (c & 16) != 0;
|
||||
m_brake = (c & 1) != 0;
|
||||
m_nitro = (c & 2) != 0;
|
||||
m_drift = (c & 4) != 0;
|
||||
m_rescue = (c & 8) != 0;
|
||||
m_fire = (c & 16) != 0;
|
||||
m_look_back = (c & 32) != 0;
|
||||
} // setButtonsCompressed
|
||||
};
|
||||
|
||||
|
@ -144,7 +144,7 @@ void PlayerKart::action(KartAction action, int value)
|
||||
m_controls.m_fire = (value!=0);
|
||||
break;
|
||||
case KA_LOOK_BACK:
|
||||
m_camera->setMode(value!=0 ? Camera::CM_REVERSE : Camera::CM_NORMAL);
|
||||
m_controls.m_look_back = (value!=0);
|
||||
break;
|
||||
case KA_DRIFT:
|
||||
m_controls.m_drift = (value!=0);
|
||||
|
@ -124,6 +124,8 @@ DefaultRobot::~DefaultRobot()
|
||||
//line, then move forward while turning.
|
||||
void DefaultRobot::update(float dt)
|
||||
{
|
||||
// This is used to enable firing an item backwards.
|
||||
m_controls.m_look_back = false;
|
||||
m_track_sector = m_world->m_kart_info[ getWorldKartId() ].m_track_sector;
|
||||
// The client does not do any AI computations.
|
||||
if(network_manager->getMode()==NetworkManager::NW_CLIENT)
|
||||
|
Loading…
Reference in New Issue
Block a user