bool // result undefined if class names are not all unique SmokeObject::instanceOf(const char *className) const { Smoke *smoke = this->smoke(); // the base class must be 'found', i.e., it cannot be external Smoke::ModuleIndex other = smoke->findClass(className); return smoke->isDerivedFrom(smoke, classId(), other.smoke, other.index); }
// --- Methods inherited from ReferenceTarget --- // This method is called to have the plug-in clone itself. RefTargetHandle Smoke::Clone(RemapDir &remap) { // Create a new instance of the plug-in class Smoke *newSmoke = new Smoke(); // Copy superclass stuff *((MtlBase *)newSmoke) = *((MtlBase *)this); // Clone the items we reference newSmoke->ReplaceReference(0, remap.CloneRef(xyzGen)); newSmoke->ReplaceReference(1, remap.CloneRef(pblock)); newSmoke->col[0] = col[0]; newSmoke->col[1] = col[1]; newSmoke->size = size; newSmoke->power = power; newSmoke->iter = iter; newSmoke->phase = phase; newSmoke->texValidity.SetEmpty(); newSmoke->mapValid.SetEmpty(); for (int i = 0; i < NUM_SUB_TEXMAPS; i++) { newSmoke->subTex[i] = NULL; newSmoke->mapOn[i] = mapOn[i]; if (subTex[i]) newSmoke->ReplaceReference(i+2, remap.CloneRef(subTex[i])); } BaseClone(this, newSmoke , remap); // Return the new cloned texture return (RefTargetHandle)newSmoke; }
/* Cast the instance pointer to a parent class. This is necessary, because the compiler does not know how to cast a void* to a parent class when multiple inheritance is involved. */ void * SmokeObject::castPtr(const char *className, bool clone) const { Smoke *smoke = this->smoke(); // Be very careful changing this -- it is written as intended return smoke->cast(clone ? clonePtr() : _ptr, classId(), smoke->idClass(className, true).index); }
SmokeGenerator::SmokeGenerator(PositionedElement* sourceElement, int smokeNumber) { _sourceElement = sourceElement; _smokeNumber = smokeNumber; addContext(new BlendingContext(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); for (int i = 0; i < smokeNumber; ++i) { Smoke* smoke = new Smoke(); smoke->setVisible(false); addChild(smoke); } }
void SmokeObject::invokeMethod(const char *name, Smoke::Stack stack) { Smoke *smoke = this->smoke(); Smoke::ModuleIndex nameId = smoke->idMethodName(name); Smoke::ModuleIndex classIdx = Smoke::ModuleIndex(smoke, classId()); Smoke::ModuleIndex meth = nameId.smoke->findMethod(classIdx, nameId); if (meth.index > 0) { Smoke::Method &m = meth.smoke->methods[meth.smoke->methodMaps[meth.index].method]; Smoke::ClassFn fn = meth.smoke->classes[m.classId].classFn; (*fn)(m.method, _ptr, stack); } else { error("Cannot find (unambiguous) %s::%s", smoke->classes[classIdx.index].className, name); } }
static void qobjectTypeResolver(JSmoke::Object::Instance * instance) { Smoke::ModuleIndex classId = instance->classId; Smoke * smoke = classId.smoke; QObject * qobject = reinterpret_cast<QObject*>(instance->cast(JSmoke::Global::QObjectClassId)); const QMetaObject * meta = qobject->metaObject(); while (meta != 0) { Smoke::ModuleIndex classId = smoke->findClass(meta->className()); if (classId != smoke->NullModuleIndex) { instance->classId = classId; return; } meta = meta->superClass(); } instance->value = instance->cast(instance->classId); return; }
INT_PTR SmokeDlgProc::DlgProc( TimeValue t,IParamMap2 *map,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch (msg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SWAP: { smoke = (Smoke*)map->GetParamBlock()->GetOwner(); smoke->SwapInputs(); } break; } break; } return FALSE; }
void SmokeGenerator::_animate(int timerInterval) { static int remainingIntervals = 0; static int i = 0; if (remainingIntervals <= 0) { vector<Element*>& elements = getElements(); Smoke* smoke = (Smoke*) elements[i]; smoke->setVisible(true); smoke->setX(_sourceElement->x()); smoke->setY(_sourceElement->y()); smoke->setZ(_sourceElement->z()); smoke->setScaleWidth(1.0); smoke->setScaleHeight(1.0); smoke->setAlpha(1.0); i = (i + 1) % _smokeNumber; remainingIntervals = 45; } remainingIntervals--; CompositeElement::_animate(timerInterval); }
bool SmokeObject::instanceOf(const SmokeType &type) const { Smoke *smoke = this->smoke(); return smoke->isDerivedFrom(smoke, classId(), type.smoke(), type.classId()); }
// only works for pure Smoke instances, but that may be OK void * SmokeObject::clonePtr() const { Smoke *smoke = this->smoke(); const char *className = _klass->name(); int classNameLen = strlen(className); // copy constructor signature QByteArray ccSig(className); int pos = ccSig.lastIndexOf("::"); if (pos != -1) { ccSig = ccSig.mid(pos + strlen("::")); } ccSig.append("#"); Smoke::ModuleIndex ccId = smoke->findMethodName(className, ccSig); char *ccArg = new char[classNameLen + 8]; sprintf(ccArg, "const %s&", className); Smoke::ModuleIndex classIdx = Smoke::ModuleIndex(smoke, classId()); Smoke::ModuleIndex ccMeth = smoke->findMethod(classIdx, ccId); if (ccMeth.index == 0) { qWarning("failed to construct copy: %s %p\n", className, _ptr); delete[] ccArg; return 0; } Smoke::Index method = ccMeth.smoke->methodMaps[ccMeth.index].method; if (method > 0) { delete[] ccArg; if (!(ccMeth.smoke->methods[method].flags & Smoke::mf_copyctor)) { qCritical("failed to construct copy: %s %p\n", className, _ptr); return 0; } ccMeth.index = method; } else { // ambiguous method, pick the copy constructor Smoke::Index i = -method; while (ccMeth.smoke->ambiguousMethodList[i]) { if (ccMeth.smoke->methods[ccMeth.smoke->ambiguousMethodList[i]].flags & Smoke::mf_copyctor) break; i++; } delete[] ccArg; ccMeth.index = ccMeth.smoke->ambiguousMethodList[i]; if (ccMeth.index == 0) { qCritical("construct_copy() failed %s %p\n", className, _ptr); return 0; } } // Okay, ccMeth is the copy constructor. Time to call it. Smoke::StackItem args[2]; args[0].s_voidp = 0; args[1].s_voidp = _ptr; Smoke::ClassFn fn = smoke->classes[classId()].classFn; (*fn)(smoke->methods[ccMeth.index].method, 0, args); // Initialize the binding for the new instance Smoke::StackItem s[2]; s[1].s_voidp = module()->binding(); (*fn)(0, args[0].s_voidp, s); return args[0].s_voidp; }
static void qeventTypeResolver(JSmoke::Object::Instance * instance) { Smoke::ModuleIndex classId = instance->classId; Smoke * smoke = classId.smoke; QEvent * qevent = reinterpret_cast<QEvent*>(instance->cast(JSmoke::Global::QEventClassId)); switch (qevent->type()) { case QEvent::Timer: instance->classId = smoke->findClass("QTimerEvent"); break; case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: case QEvent::MouseMove: instance->classId = smoke->findClass("QMouseEvent"); break; case QEvent::KeyPress: case QEvent::KeyRelease: case QEvent::ShortcutOverride: instance->classId = smoke->findClass("QKeyEvent"); break; case QEvent::FocusIn: case QEvent::FocusOut: instance->classId = smoke->findClass("QFocusEvent"); break; case QEvent::Enter: case QEvent::Leave: instance->classId = smoke->findClass("QEvent"); break; case QEvent::Paint: instance->classId = smoke->findClass("QPaintEvent"); break; case QEvent::Move: instance->classId = smoke->findClass("QMoveEvent"); break; case QEvent::Resize: instance->classId = smoke->findClass("QResizeEvent"); break; case QEvent::Create: case QEvent::Destroy: instance->classId = smoke->findClass("QEvent"); break; case QEvent::Show: instance->classId = smoke->findClass("QShowEvent"); break; case QEvent::Hide: instance->classId = smoke->findClass("QHideEvent"); case QEvent::Close: instance->classId = smoke->findClass("QCloseEvent"); break; case QEvent::Quit: case QEvent::ParentChange: case QEvent::ParentAboutToChange: case QEvent::ThreadChange: case QEvent::WindowActivate: case QEvent::WindowDeactivate: case QEvent::ShowToParent: case QEvent::HideToParent: instance->classId = smoke->findClass("QEvent"); break; case QEvent::Wheel: instance->classId = smoke->findClass("QWheelEvent"); break; case QEvent::WindowTitleChange: case QEvent::WindowIconChange: case QEvent::ApplicationWindowIconChange: case QEvent::ApplicationFontChange: case QEvent::ApplicationLayoutDirectionChange: case QEvent::ApplicationPaletteChange: case QEvent::PaletteChange: instance->classId = smoke->findClass("QEvent"); break; case QEvent::Clipboard: instance->classId = smoke->findClass("QClipboardEvent"); break; case QEvent::Speech: case QEvent::MetaCall: case QEvent::SockAct: case QEvent::WinEventAct: case QEvent::DeferredDelete: instance->classId = smoke->findClass("QEvent"); break; case QEvent::DragEnter: instance->classId = smoke->findClass("QDragEnterEvent"); break; case QEvent::DragLeave: instance->classId = smoke->findClass("QDragLeaveEvent"); break; case QEvent::DragMove: instance->classId = smoke->findClass("QDragMoveEvent"); case QEvent::Drop: instance->classId = smoke->findClass("QDropEvent"); break; case QEvent::DragResponse: instance->classId = smoke->findClass("QDragResponseEvent"); break; case QEvent::ChildAdded: case QEvent::ChildRemoved: case QEvent::ChildPolished: instance->classId = smoke->findClass("QChildEvent"); break; case QEvent::ShowWindowRequest: case QEvent::PolishRequest: case QEvent::Polish: case QEvent::LayoutRequest: case QEvent::UpdateRequest: case QEvent::EmbeddingControl: case QEvent::ActivateControl: case QEvent::DeactivateControl: instance->classId = smoke->findClass("QEvent"); break; case QEvent::ContextMenu: instance->classId = smoke->findClass("QContextMenuEvent"); break; case QEvent::DynamicPropertyChange: instance->classId = smoke->findClass("QDynamicPropertyChangeEvent"); break; case QEvent::InputMethod: instance->classId = smoke->findClass("QInputMethodEvent"); break; case QEvent::AccessibilityPrepare: instance->classId = smoke->findClass("QEvent"); break; case QEvent::TabletMove: case QEvent::TabletPress: case QEvent::TabletRelease: instance->classId = smoke->findClass("QTabletEvent"); break; case QEvent::LocaleChange: case QEvent::LanguageChange: case QEvent::LayoutDirectionChange: case QEvent::Style: case QEvent::OkRequest: case QEvent::HelpRequest: instance->classId = smoke->findClass("QEvent"); break; case QEvent::IconDrag: instance->classId = smoke->findClass("QIconDragEvent"); break; case QEvent::FontChange: case QEvent::EnabledChange: case QEvent::ActivationChange: case QEvent::StyleChange: case QEvent::IconTextChange: case QEvent::ModifiedChange: case QEvent::MouseTrackingChange: instance->classId = smoke->findClass("QEvent"); break; case QEvent::WindowBlocked: case QEvent::WindowUnblocked: case QEvent::WindowStateChange: instance->classId = smoke->findClass("QWindowStateChangeEvent"); break; case QEvent::ToolTip: case QEvent::WhatsThis: instance->classId = smoke->findClass("QHelpEvent"); break; case QEvent::StatusTip: instance->classId = smoke->findClass("QEvent"); break; case QEvent::ActionChanged: case QEvent::ActionAdded: case QEvent::ActionRemoved: instance->classId = smoke->findClass("QActionEvent"); break; case QEvent::FileOpen: instance->classId = smoke->findClass("QFileOpenEvent"); break; case QEvent::Shortcut: instance->classId = smoke->findClass("QShortcutEvent"); break; case QEvent::WhatsThisClicked: instance->classId = smoke->findClass("QWhatsThisClickedEvent"); break; case QEvent::ToolBarChange: instance->classId = smoke->findClass("QToolBarChangeEvent"); break; case QEvent::ApplicationActivated: case QEvent::ApplicationDeactivated: case QEvent::QueryWhatsThis: case QEvent::EnterWhatsThisMode: case QEvent::LeaveWhatsThisMode: case QEvent::ZOrderChange: instance->classId = smoke->findClass("QEvent"); break; case QEvent::HoverEnter: case QEvent::HoverLeave: case QEvent::HoverMove: instance->classId = smoke->findClass("QHoverEvent"); break; case QEvent::AccessibilityHelp: case QEvent::AccessibilityDescription: instance->classId = smoke->findClass("QEvent"); case QEvent::GraphicsSceneMouseMove: case QEvent::GraphicsSceneMousePress: case QEvent::GraphicsSceneMouseRelease: case QEvent::GraphicsSceneMouseDoubleClick: instance->classId = smoke->findClass("QGraphicsSceneMouseEvent"); break; case QEvent::GraphicsSceneContextMenu: instance->classId = smoke->findClass("QGraphicsSceneContextMenuEvent"); break; case QEvent::GraphicsSceneHoverEnter: case QEvent::GraphicsSceneHoverMove: case QEvent::GraphicsSceneHoverLeave: instance->classId = smoke->findClass("QGraphicsSceneHoverEvent"); break; case QEvent::GraphicsSceneHelp: instance->classId = smoke->findClass("QGraphicsSceneHelpEvent"); break; case QEvent::GraphicsSceneDragEnter: case QEvent::GraphicsSceneDragMove: case QEvent::GraphicsSceneDragLeave: case QEvent::GraphicsSceneDrop: instance->classId = smoke->findClass("QGraphicsSceneDragDropEvent"); break; case QEvent::GraphicsSceneWheel: instance->classId = smoke->findClass("QGraphicsSceneWheelEvent"); break; case QEvent::KeyboardLayoutChange: instance->classId = smoke->findClass("QEvent"); break; default: break; } instance->value = instance->cast(instance->classId); return; }
void Scene_Game::Update() { if (bPause) return; Scene::Update(); if (bBoss) { D3DXVECTOR3 bosspos = D3DXVECTOR3((float)pBoss->iX*BLOCK_SIZE+BLOCK_SIZE/2, (float)pBoss->iY*BLOCK_SIZE+BLOCK_SIZE/2, 0); float distance = abs(pPlayer->vPos.x-bosspos.x); if (distance > iMapWidthPixel/2) { bosspos.x += (bosspos.x < iMapWidthPixel/2)? iMapWidthPixel:-iMapWidthPixel; distance = iMapWidthPixel-distance; } if (distance < 256.f && abs(pPlayer->vPos.y-bosspos.y) < 256.f) { vCameraDest = (pPlayer->vPos+bosspos)/2 - D3DXVECTOR3(200, 150, 0); } else vCameraDest = pPlayer->vPos-D3DXVECTOR3(200, 150, 0); } else vCameraDest = pPlayer->vPos-D3DXVECTOR3(200, 150, 0); if (vCameraDest.y+vCameraDelta.y < 0) vCameraDest.y = -vCameraDelta.y; else if (vCameraDest.y+vCameraDelta.y+300 > iMapHeightPixel) vCameraDest.y = (float)(iMapHeightPixel-vCameraDelta.y-300); vCamera += (vCameraDest+vCameraDelta-vCamera)*0.25f; if (fShake>0.1f) { fTriFuncConst -= 0.375f*fShake; while (fTriFuncConst < 0) fTriFuncConst += D3DX_PI*2; JInput::controller.SetVibration((unsigned)(fShake*32768), (unsigned)(fShake*32768), 0); vCameraShake.x = sin(fTriFuncConst)*fShake*2.5f; vCameraShake.y = sin(fTriFuncConst+0.5f)*fShake*2.5f; fShake = fShake*0.875f; if (fShake<0.125f) fShake = 0; } mPlayerPos.x = ((int)pPlayer->vPos.x)/BLOCK_SIZE; mPlayerPos.y = max(((int)pPlayer->vPos.y+8)/BLOCK_SIZE, 0); if (pBoss && pBoss->IsDead() && mCutScene == CUTSCENE_NULL) { bInputLock = true; bGameOver = true; bEnding = true; if (mLastCutScene == CUTSCENE_UNOBTAINIUM_BOSS) { mCutScene = CUTSCENE_UNOBTAINIUM_ENDING; } else if (mLastCutScene == CUTSCENE_COOKIE_BOSS) { mCutScene = CUTSCENE_COOKIE_ENDING; } } if (bTheEnd) { fEndingAlpha = min(fEndingAlpha+0.0625f, 1); } mBaseCamp.Update(); mBaseMenu.Update(); // 컷신 switch (mCutScene) { case CUTSCENE_NORMAL_ENDING: NormalEndingCutScene(); break; case CUTSCENE_UNOBTAINIUM_ENDING: UnobtainiumEndingCutScene(); break; case CUTSCENE_COOKIE_ENDING: CookieEndingCutScene(); break; case CUTSCENE_UNOBTAINIUM_BOSS: UnobtainiumBossCutScene(); break; case CUTSCENE_COOKIE_BOSS: CookieBossCutScene(); break; } fWarningAlpha = max(1-(float)pPlayer->iAir/pPlayer->iAirMax*5, 0); if (pPlayer->iHealth > 0 && pPlayer->iAir <= pPlayer->iAirMax*0.25) BGMManager::GetInstance().PlayBGM("air_warning"); else BGMManager::GetInstance().FadeOutBGMAndStop("air_warning", 200); bNearCamp = false; if (!bGameOver) { pPlayer->iAir = max(pPlayer->iAir - (int)(max(0, mPlayerPos.y-mBaseCamp.iY)*0.25f), 0); for each (Building building in mBuildings) { if (building.type != BUILDING_SMALL_CAMP) continue; int cx = building.x+gBuildingData[building.type].width/2; int cy = building.y; bNearCamp = (abs(cx-mPlayerPos.x) < 2 || abs((cx+iMapWidth/2)%iMapWidth-(mPlayerPos.x+iMapWidth/2)%iMapWidth) < 2) // 건물이 경계에 걸쳤을 경우 && abs(cy-mPlayerPos.y) < 2 && cy >= mPlayerPos.y; if (bNearCamp) break; } if (gBlockData[mGameMap[mPlayerPos.x+mPlayerPos.y*iMapWidth]].fluid) { pPlayer->bInFluid = true; if (gBlockData[mGameMap[mPlayerPos.x+(mPlayerPos.y-1)*iMapWidth]].fluid) pPlayer->bTotalyInFluid = true; } if (mGameMap[mPlayerPos.x+mPlayerPos.y*iMapWidth] == BLOCK_MAGMA && iMagmaDamage>0) { pPlayer->iHitCooltime = 120; pPlayer->iHealth = max(pPlayer->iHealth-iMagmaDamage, 0); } if (pPlayer->vPos.y < -500) pPlayer->iHealth = 0; if (bBuild) { mBuildingPos.x = mPlayerPos.x-gBuildingData[iSelectedBuilding].width/2; mBuildingPos.y = mPlayerPos.y; } if (pPlayer->iAirpackBrokenTimer > 0) { D3DXVECTOR3 pos = pPlayer->vPos; pos.x += (float)Random::rand.NextDouble()*10-5; pos.y += (float)Random::rand.NextDouble()*10-5; Smoke* smoke = new Smoke(0, pos.x, pos.y) ; smoke->z = 1; smoke->AddVelocity(0, -3); AddObject(smoke); } }
void Scene_Game::InputProc() { // debug if (JInput::IsPressed(VK_SHIFT) && JInput::IsPressed('F')) mBaseCamp.iFuel += 256; if (JInput::IsPressed(VK_SHIFT) && JInput::IsPressed('M')) mBaseCamp.iMineral += 256; if (JInput::IsPressed(VK_SHIFT) && JInput::IsTriggered('L')) bIgnoreLight = !bIgnoreLight; if (!bBoss && JInput::IsPressed(VK_SHIFT) && JInput::IsTriggered('B')) { StartUnobtainiumBossBattle(); } if (!bBoss && JInput::IsPressed(VK_SHIFT) && JInput::IsTriggered('C')) { StartCookieBossBattle(); } if (JInput::IsTriggered(VK_ESCAPE) || JInput::controller.IsButtonTriggered(Controller::START, 0)) { bPause = !bPause; if (bPause) { SEManager::GetInstance().PlaySE("pause"); BGMManager::GetInstance().SetBGMsVolume(0.25f); MakePauseTexture(); } else { SEManager::GetInstance().PlaySE("unpause"); BGMManager::GetInstance().SetBGMsVolume(1.0f); } } if (bPause) { if (JInput::IsTriggered(VK_F2) || JInput::controller.IsButtonTriggered(Controller::BACK, 0)) { Reset(); return; } if (bCleared) { for (int i=0; i<MODE_NUM; i++) { if (JInput::IsTriggered('1'+i)) mNextSpecialMode = (SpecialMode)i; } if (JInput::IsTriggered('0')) mNextSpecialMode = MODE_NUM; } } if (bPause || bInputLock) return; if (mBaseMenu.bActive) { mBaseMenu.InputProc(); return; } mGameUI.InputProc(); if (mGameUI.bBuild) return; float right_con_x, right_con_y; JInput::controller.GetRightAnalogStick(&right_con_x, &right_con_y, 0); if (bBuild) { if (JInput::IsTriggered('X') || JInput::controller.IsButtonTriggered(Controller::B, 0)) { bBuild = false; Build(); } } if (JInput::IsPressed(VK_CONTROL)) { if (JInput::IsPressed(VK_LEFT)) { vCameraDelta.x -= fLookAroundLimit*0.0625f; if (iHelpStep == 3) bHelpKeyInput[4] = true; } if (JInput::IsPressed(VK_RIGHT)) { vCameraDelta.x += fLookAroundLimit*0.0625f; if (iHelpStep == 3) bHelpKeyInput[4] = true; } if (JInput::IsPressed(VK_UP)) { vCameraDelta.y -= fLookAroundLimit*0.0625f; if (iHelpStep == 3) bHelpKeyInput[4] = true; } if (JInput::IsPressed(VK_DOWN)) { vCameraDelta.y += fLookAroundLimit*0.0625f; if (iHelpStep == 3) bHelpKeyInput[4] = true; } if (D3DXVec3Length(&vCameraDelta) > fLookAroundLimit) { D3DXVECTOR3 v; D3DXVec3Normalize(&v, &vCameraDelta); vCameraDelta = v*fLookAroundLimit; } } else if (JInput::IsReleased(VK_CONTROL)) vCameraDelta = D3DXVECTOR3(0,0,0); if (JInput::controller.IsConnected(0)) { vCameraDelta.x = right_con_x*fLookAroundLimit; vCameraDelta.y = -right_con_y*fLookAroundLimit; if (iHelpStep == 3 && D3DXVec3Length(&vCameraDelta) > 1) bHelpKeyInput[4] = true; } if (!JInput::IsPressed(VK_CONTROL)) { if (JInput::IsPressed(VK_LEFT) || JInput::controller.IsStickPressed(Controller::LSTICK, Controller::LEFT, 0)) { pPlayer->Move(0); if (iHelpStep == 1) bHelpKeyInput[0] = true; } if (JInput::IsPressed(VK_RIGHT) || JInput::controller.IsStickPressed(Controller::LSTICK, Controller::RIGHT, 0)) { pPlayer->Move(1); if (iHelpStep == 1) bHelpKeyInput[0] = true; } } if (JInput::IsPressed('Z') || JInput::controller.IsButtonPressed(Controller::A, 0)) { pPlayer->Jump(); if (iHelpStep == 1) bHelpKeyInput[1] = true; } if (JInput::IsPressed('X') || JInput::controller.IsButtonPressed(Controller::B, 0)) { iDrillingX = mPlayerPos.x; iDrillingY = mPlayerPos.y; pPlayer->bDrilling = true; int dx = 1, dy = 1; if (JInput::IsPressed(VK_LEFT) || JInput::controller.IsStickPressed(Controller::LSTICK, Controller::LEFT, 0)) { iDrillingX = (iDrillingX+iMapWidth-1)%iMapWidth; dx-=1; } if (JInput::IsPressed(VK_RIGHT) || JInput::controller.IsStickPressed(Controller::LSTICK, Controller::RIGHT, 0)) { iDrillingX = (iDrillingX+1)%iMapWidth; dx+=1; } if (JInput::IsPressed(VK_UP) || JInput::controller.IsStickPressed(Controller::LSTICK, Controller::UP, 0)) { if (JInput::IsPressed(VK_LEFT) ||JInput::controller.IsStickPressed(Controller::LSTICK, Controller::LEFT, 0) ||JInput::IsPressed(VK_RIGHT) ||JInput::controller.IsStickPressed(Controller::LSTICK, Controller::RIGHT, 0)) iDrillingY = max(iDrillingY-1, 0); else iDrillingY = max(iDrillingY-2, 0); dy-=1; } if (JInput::IsPressed(VK_DOWN) || JInput::controller.IsStickPressed(Controller::LSTICK, Controller::DOWN, 0)) { iDrillingY = min(iMapHeight-1, iDrillingY+1); dy+=1; } pPlayer->iDir = dx+dy*3; bDrawCracking = false; Drill(iDrillingX, iDrillingY); if (iHelpStep == 1) bHelpKeyInput[2] = true; } else if (JInput::IsReleased('X') || JInput::controller.IsButtonReleased(Controller::B, 0)) { pPlayer->bDrilling = false; pPlayer->iDrillDamage = 0; bDrawCracking = false; } if (mBaseCamp.bNearBase && (JInput::IsTriggered('Y') || JInput::controller.IsButtonTriggered(Controller::Y, 0))) { mBaseMenu.Open(); } if (JInput::IsPressed(VK_LSHIFT) || JInput::controller.IsButtonPressed(Controller::RTRIGGER, 0)) { pPlayer->Jet(); mGameUI.Show(GameHUD::UI_JETPACK); if (pPlayer->iJetFuel > 0) { BGMManager::GetInstance().PlayBGM("jetpack"); D3DXVECTOR3 pos = pPlayer->vPos; pos.x += (float)Random::rand.NextDouble()*10-5; pos.y += (float)Random::rand.NextDouble()*10-5; Smoke* smoke = new Smoke(0, pos.x, pos.y) ; smoke->z = 1; smoke->AddVelocity(0, 2); AddObject(smoke); } if (iHelpStep == 1) bHelpKeyInput[3] = true; } else BGMManager::GetInstance().FadeOutBGMAndStop("jetpack", 200); }
static void qgraphicsitemTypeResolver(JSmoke::Object::Instance * instance) { Smoke::ModuleIndex classId = instance->classId; Smoke * smoke = classId.smoke; QGraphicsItem * item = reinterpret_cast<QGraphicsItem*>(instance->cast(JSmoke::Global::QGraphicsItemClassId)); switch (item->type()) { case 1: instance->classId = smoke->findClass("QGraphicsItem"); break; case 2: instance->classId = smoke->findClass("QGraphicsPathItem"); break; case 3: instance->classId = smoke->findClass("QGraphicsRectItem"); case 4: instance->classId = smoke->findClass("QGraphicsEllipseItem"); break; case 5: instance->classId = smoke->findClass("QGraphicsPolygonItem"); break; case 6: instance->classId = smoke->findClass("QGraphicsLineItem"); break; case 7: instance->classId = smoke->findClass("QGraphicsItem"); break; case 8: instance->classId = smoke->findClass("QGraphicsTextItem"); break; case 9: instance->classId = smoke->findClass("QGraphicsSimpleTextItem"); break; case 10: instance->classId = smoke->findClass("QGraphicsItemGroup"); break; } instance->value = instance->cast(instance->classId); return; }
void FightingLayer::update(float dt) { _playDuration += dt; Rect rect = Rect(0, 0, _ground->getContentSize().width, _ground->getContentSize().height); // Update bullets for (std::vector<Bullet *>::size_type i = 0; i != _bullets->size(); i++) { Bullet *bullet = _bullets->at(i); bullet->update(dt); if (!rect.containsPoint(bullet->getPosition())) { bullet->kill(); _bullets->erase(_bullets->begin() + i); i--; continue; } for (std::vector<Enemy *>::size_type j = 0; j != _enemies->size(); j++) { Enemy *enemy = _enemies->at(j); // Check if bullet hits if (enemy->getBoundingBox().containsPoint(bullet->getPosition())) { _score += 10; // Remove enemy //enemy->removeFromParent(); enemy->kill(); _enemies->erase(_enemies->begin() + j); j--; // REmove bullet bullet->kill(); _bullets->erase(_bullets->begin() + i); i--; updateScore(); break; } } } for (std::vector<Smoke *>::size_type i = 0; i != _smokes->size(); i++) { Smoke *smoke = _smokes->at(i); Point position = smoke->getPosition(); if (position.x < 0) { position.x = 0; smoke->reverse(); } else if (position.x > rect.size.width) { position.x = rect.size.width; smoke->reverse(); } } for (std::vector<Enemy *>::size_type i = 0; i != _enemies->size(); i++) { Enemy *enemy = _enemies->at(i); // Check if outside bool isOutside = (enemy->getDirection() == -1 && enemy->getPosition().x < 0) || (enemy->getDirection() == 1 && enemy->getPosition().x > _ground->getContentSize().width); if (isOutside) { enemy->removeFromParent(); _enemies->erase(_enemies->begin() + i); i--; continue; } // Check if hits player if (_player->getBoundingBox().intersectsRect(enemy->getBoundingBox()) && _player->isAlive()) { _player->kill(); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("die_sound.wav"); this->gameDidEnd(); break; } } if (_player->isAlive()) { Point playerPosition = _player->getPosition(); if (playerPosition.x < _player->getContentSize().width) { playerPosition.x = _player->getContentSize().width; _player->setPosition(playerPosition); } else if (playerPosition.x > _ground->getContentSize().width -_player->getContentSize().width) { _player->setPositionX(_ground->getContentSize().width -_player->getContentSize().width); } } }
static void showClass(const Smoke::ModuleIndex& classId, int indent) { if (showClassNamesOnly) { QString className = QString::fromLatin1(classId.smoke->classes[classId.index].className); className.replace("::", "."); if (!matchPattern || targetPattern.indexIn(className) != -1) { while (indent > 0) { qOut << " "; indent--; } qOut << className << "\n"; } return; } Smoke * smoke = classId.smoke; Smoke::Index imax = smoke->numMethodMaps; Smoke::Index imin = 0, icur = -1, methmin, methmax; methmin = -1; methmax = -1; // kill warnings int icmp = -1; while (imax >= imin) { icur = (imin + imax) / 2; icmp = smoke->leg(smoke->methodMaps[icur].classId, classId.index); if (icmp == 0) { Smoke::Index pos = icur; while (icur != 0 && smoke->methodMaps[icur-1].classId == classId.index) { icur --; } methmin = icur; icur = pos; while (icur < imax && smoke->methodMaps[icur+1].classId == classId.index) { icur ++; } methmax = icur; break; } if (icmp > 0) { imax = icur - 1; } else { imin = icur + 1; } } if (icmp == 0) { for (Smoke::Index i = methmin ; i <= methmax ; i++) { Smoke::Index ix = smoke->methodMaps[i].method; if (ix >= 0) { // single match if ((smoke->methods[ix].flags & Smoke::mf_dtor) == 0) { QString method = methodToString(Smoke::ModuleIndex(smoke, ix)); if (!matchPattern || targetPattern.indexIn(method) != -1) { qWarning("%s", method.toLatin1().constData()); } } } else { // multiple match ix = -ix; // turn into ambiguousMethodList index while (smoke->ambiguousMethodList[ix]) { if ((smoke->methods[smoke->ambiguousMethodList[ix]].flags & Smoke::mf_dtor) == 0) { QString method = methodToString(Smoke::ModuleIndex(smoke, smoke->ambiguousMethodList[ix])); if (!matchPattern || targetPattern.indexIn(method) != -1) { qWarning("%s", method.toLatin1().constData()); } } ix++; } } } } }