本文整理汇总了C++中Missile::SetRotMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Missile::SetRotMatrix方法的具体用法?C++ Missile::SetRotMatrix怎么用?C++ Missile::SetRotMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Missile
的用法示例。
在下文中一共展示了Missile::SetRotMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FireMissile
bool Ship::FireMissile(int idx, Ship *target)
{
assert(target);
const Equip::Type t = m_equipment.Get(Equip::SLOT_MISSILE, idx);
if (t == Equip::NONE) {
return false;
}
m_equipment.Set(Equip::SLOT_MISSILE, idx, Equip::NONE);
CalcStats();
matrix4x4d m;
GetRotMatrix(m);
vector3d dir = m*vector3d(0,0,-1);
ShipType::Type mtype;
switch (t) {
case Equip::MISSILE_SMART: mtype = ShipType::MISSILE_SMART; break;
case Equip::MISSILE_NAVAL: mtype = ShipType::MISSILE_NAVAL; break;
case Equip::MISSILE_UNGUIDED: mtype = ShipType::MISSILE_UNGUIDED; break;
default:
case Equip::MISSILE_GUIDED: mtype = ShipType::MISSILE_GUIDED; break;
}
Missile *missile = new Missile(mtype, this, target);
missile->SetRotMatrix(m);
missile->SetFrame(GetFrame());
// XXX DODGY! need to put it in a sensible location
missile->SetPosition(GetPosition()+50.0*dir);
missile->SetVelocity(GetVelocity());
Space::AddBody(missile);
return true;
}
示例2: HandleEvents
void Pi::HandleEvents()
{
SDL_Event event;
Pi::mouseMotion[0] = Pi::mouseMotion[1] = 0;
while (SDL_PollEvent(&event)) {
Gui::HandleSDLEvent(&event);
switch (event.type) {
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_ESCAPE) {
// only accessible once game started
if (currentView != 0) {
if (currentView != gameMenuView) {
RequestTimeAccel(0);
SetTimeAccel(0);
SetView(gameMenuView);
}
else
RequestTimeAccel(1);
}
break;
}
// special keys. LCTRL+turd
if ((KeyState(SDLK_LCTRL) || (KeyState(SDLK_RCTRL)))) {
if (event.key.keysym.sym == SDLK_q) Pi::Quit();
if (event.key.keysym.sym == SDLK_s) {
Render::ToggleShaders();
}
if (event.key.keysym.sym == SDLK_h) {
Render::ToggleHDR();
}
if (event.key.keysym.sym == SDLK_i) Pi::showDebugInfo = !Pi::showDebugInfo;
if (event.key.keysym.sym == SDLK_p) {
Sint64 crime, fine;
Polit::GetCrime(&crime, &fine);
printf("Criminal record: %llx, $%lld\n", crime, fine);
Polit::AddCrime(0x1, 100);
Polit::GetCrime(&crime, &fine);
printf("Criminal record now: %llx, $%lld\n", crime, fine);
}
if (event.key.keysym.sym == SDLK_PRINT) {
char buf[256];
const time_t t = time(0);
struct tm *_tm = localtime(&t);
strftime(buf, sizeof(buf), "screenshot-%Y%m%d-%H%M%S.tga", _tm);
Screendump(buf);
fprintf(stderr, "Screendump to %s\n", buf);
}
#ifdef DEBUG
if (event.key.keysym.sym == SDLK_m) {
Pi::player->SetMoney(Pi::player->GetMoney() + 10000000);
}
if (event.key.keysym.sym == SDLK_F12) {
matrix4x4d m; Pi::player->GetRotMatrix(m);
vector3d dir = m*vector3d(0,0,-1);
/* add test object */
if (KeyState(SDLK_RSHIFT)) {
Missile *missile = new Missile(ShipType::MISSILE_GUIDED, Pi::player, Pi::player->GetCombatTarget());
missile->SetRotMatrix(m);
missile->SetFrame(Pi::player->GetFrame());
missile->SetPosition(Pi::player->GetPosition()+50.0*dir);
missile->SetVelocity(Pi::player->GetVelocity());
Space::AddBody(missile);
} else if (KeyState(SDLK_LSHIFT)) {
SpaceStation *s = static_cast<SpaceStation*>(Pi::player->GetNavTarget());
if (s) {
int port = s->GetFreeDockingPort();
if (port != -1) {
printf("Putting ship into station\n");
// Make police ship intent on killing the player
Ship *ship = new Ship(ShipType::LADYBIRD);
ship->AIKill(Pi::player);
ship->SetFrame(Pi::player->GetFrame());
ship->SetDockedWith(s, port);
Space::AddBody(ship);
} else {
printf("No docking ports free dude\n");
}
} else {
printf("Select a space station...\n");
}
} else {
Ship *ship = new Ship(ShipType::LADYBIRD);
ship->m_equipment.Set(Equip::SLOT_LASER, 0, Equip::PULSECANNON_1MW);
ship->AIKill(Pi::player);
ship->SetFrame(Pi::player->GetFrame());
ship->SetPosition(Pi::player->GetPosition()+100.0*dir);
ship->SetVelocity(Pi::player->GetVelocity());
ship->m_equipment.Add(Equip::DRIVE_CLASS2);
ship->m_equipment.Add(Equip::RADAR_MAPPER);
ship->m_equipment.Add(Equip::SCANNER);
ship->m_equipment.Add(Equip::SHIELD_GENERATOR);
ship->m_equipment.Add(Equip::HYDROGEN, 10);
Space::AddBody(ship);
}
}
#endif /* DEBUG */
// XXX only works on X11
//if (event.key.keysym.sym == SDLK_F11) SDL_WM_ToggleFullScreen(Pi::scrSurface);
if (event.key.keysym.sym == SDLK_F10) Pi::SetView(Pi::objectViewerView);
//.........这里部分代码省略.........