这篇教程C++ I2X函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中I2X函数的典型用法代码示例。如果您正苦于以下问题:C++ I2X函数的具体用法?C++ I2X怎么用?C++ I2X使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了I2X函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ChargeFusion// -----------------------------------------------------------------------------// Fire Laser: Registers a laser fire, and performs special stuff for the fusion// cannon.void ChargeFusion (void){if ((LOCALPLAYER.energy < I2X (2)) && (gameData.fusion.xAutoFireTime == 0)) { gameData.laser.nGlobalFiringCount = 0; }else { gameData.fusion.xFrameTime += gameData.time.xFrame; if (!gameData.FusionCharge ()) LOCALPLAYER.energy -= I2X (2); fix h = (gameData.fusion.xFrameTime <= LOCALPLAYER.energy) ? gameData.fusion.xFrameTime : LOCALPLAYER.energy; gameData.SetFusionCharge (gameData.FusionCharge () + h); LOCALPLAYER.energy -= h; if (LOCALPLAYER.energy > 0) gameData.fusion.xAutoFireTime = gameData.time.xGame + gameData.fusion.xFrameTime / 2 + 1; else { LOCALPLAYER.energy = 0; gameData.fusion.xAutoFireTime = gameData.time.xGame - 1; // Fire now! } if (gameStates.limitFPS.bFusion && !gameStates.app.tick40fps.bTick) return; float fScale = float (gameData.FusionCharge () >> 11) / 64.0f; tRgbaColorf* colorP = gameData.weapons.color + FUSION_ID; if (gameData.FusionCharge () < I2X (2)) paletteManager.BumpEffect (colorP->red * fScale, colorP->green * fScale, colorP->blue * fScale); else paletteManager.BumpEffect (colorP->blue * fScale, colorP->red * fScale, colorP->green * fScale); if (gameData.time.xGame < gameData.fusion.xLastSoundTime) //gametime has wrapped gameData.fusion.xNextSoundTime = gameData.fusion.xLastSoundTime = gameData.time.xGame; if (gameData.fusion.xNextSoundTime < gameData.time.xGame) { if (gameData.FusionCharge () > I2X (2)) { audio.PlaySound (11); gameData.objs.consoleP->ApplyDamageToPlayer (gameData.objs.consoleP, d_rand () * 4); } else { CreateAwarenessEvent (gameData.objs.consoleP, WEAPON_ROBOT_COLLISION); audio.PlaySound (SOUND_FUSION_WARMUP); if (IsMultiGame) MultiSendPlaySound (SOUND_FUSION_WARMUP, I2X (1)); } gameData.fusion.xLastSoundTime = gameData.time.xGame; gameData.fusion.xNextSoundTime = gameData.time.xGame + I2X (1) / 8 + d_rand () / 4; } gameData.fusion.xFrameTime = 0; }}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:50,
示例2: I2Xvoid CHUD::DrawCloak (void){if (cockpit->Hide ()) return; static int nIdCloak = 0;if ((LOCALPLAYER.flags & PLAYER_FLAGS_CLOAKED) && ((LOCALPLAYER.cloakTime + CLOAK_TIME_MAX - gameData.time.xGame > I2X (3)) || (gameData.time.xGame & 0x8000))) { int y = CCanvas::Current ()->Height (); if (IsMultiGame) y -= 7 * m_info.nLineSpacing; else y -= 4 * m_info.nLineSpacing; if ((LOCALPLAYER.flags & PLAYER_FLAGS_AFTERBURNER) && !gameOpts->render.cockpit.bTextGauges) y -= m_info.nLineSpacing + gameStates.render.fonts.bHires + 1; fontManager.SetColorRGBi (GREEN_RGBA, 1, 0, 0); nIdCloak = GrPrintF (&nIdCloak, 2, y, "%s", TXT_CLOAKED); }}
开发者ID:paud,项目名称:d2x-xl,代码行数:22,
示例3: BitBltvoid CStatusBar::DrawAfterburnerBar (void){if (gameStates.app.bD1Mission) return; int nEraseHeight;CCanvas::Push ();fontManager.SetScale (floor (float (CCanvas::Current ()->Width ()) / 640.0f));CCanvas::SetCurrent (CurrentGameScreen ());BitBlt (SB_GAUGE_AFTERBURNER, SB_AFTERBURNER_GAUGE_X, SB_AFTERBURNER_GAUGE_Y);nEraseHeight = FixMul ((I2X (1) - gameData.physics.xAfterburnerCharge), SB_AFTERBURNER_GAUGE_H);if (nEraseHeight > 0) { glDisable (GL_BLEND); Rect (SB_AFTERBURNER_GAUGE_X, SB_AFTERBURNER_GAUGE_Y, SB_AFTERBURNER_GAUGE_X + SB_AFTERBURNER_GAUGE_W - 1, SB_AFTERBURNER_GAUGE_Y + nEraseHeight - 1); glEnable (GL_BLEND); }fontManager.SetScale (1.0f);CCanvas::Pop ();}
开发者ID:paud,项目名称:d2x-xl,代码行数:22,
示例4: StartSound// Volume 0-I2X (1)int CAudio::StartSound (short nSound, int nSoundClass, fix nVolume, int nPan, int bLooping, int nLoopStart, int nLoopEnd, int nSoundObj, int nSpeed, const char *pszWAV, CFixVector* vPos){ CAudioChannel* channelP;if (!gameStates.app.bUseSound) return -1;if (!m_info.bAvailable) return -1;if (((nSoundObj > -1) || bLooping || (nVolume > I2X (1))) && !nSoundClass) nSoundClass = -1;if (!(channelP = FindFreeChannel (nSoundClass))) return -1;if (0 > channelP->Start (nSound, nSoundClass, nVolume, nPan, bLooping, nLoopStart, nLoopEnd, nSoundObj, nSpeed, pszWAV, vPos)) { return -1; }int i = m_info.nFreeChannel;if (++m_info.nFreeChannel >= MAX_SOUND_CHANNELS) m_info.nFreeChannel = 0;return i;}
开发者ID:paud,项目名称:d2x-xl,代码行数:23,
示例5: I2Xint CParticleSystem::Update (void){if (!m_bValid) return 0; CParticleEmitter *emitterP; int i = 0;if ((m_nObject == 0x7fffffff) && (m_nType == SMOKE_PARTICLES) && (gameStates.app.nSDLTicks - m_nBirth > (MAX_SHRAPNEL_LIFE / I2X (1)) * 1000)) SetLife (0);#if DBGif ((m_nObject >= 0) && (m_nObject < 0x70000000) && (OBJECTS [m_nObject].info.nType == 255)) i = i;#endifif ((emitterP = m_emitters.Buffer ())) { bool bKill = (m_nObject < 0) || ((m_nObject < 0x70000000) && ((OBJECTS [m_nObject].info.nSignature != m_nSignature) || (OBJECTS [m_nObject].info.nType == OBJ_NONE))); for (i = 0; i < m_nEmitters; ) { if (!m_emitters) return 0; if (emitterP->IsDead (gameStates.app.nSDLTicks)) { if (!RemoveEmitter (i)) { //particleManager.Destroy (m_nId); m_bDestroy = true; break; } } else { if (bKill) emitterP->SetLife (0); emitterP->Update (gameStates.app.nSDLTicks, -1); emitterP++, i++; } } }return i;}
开发者ID:paud,项目名称:d2x-xl,代码行数:38,
示例6: DrawObjectRodTexPoly//------------------------------------------------------------------------------//draw an CObject that is a texture-mapped rodvoid DrawObjectRodTexPoly (CObject *objP, tBitmapIndex bmi, int bLit, int iFrame){ CBitmap *bmP = gameData.pig.tex.bitmaps [0] + bmi.index; fix light; CFixVector delta, top_v, bot_v; g3sPoint top_p, bot_p;LoadBitmap (bmi.index, 0);if ((bmP->Type () == BM_TYPE_STD) && bmP->Override ()) { bmP->SetupTexture (1, gameOpts->render.bDepthSort <= 0); bmP = bmP->Override (iFrame); }delta = objP->info.position.mOrient.UVec () * objP->info.xSize;top_v = objP->info.position.vPos + delta;bot_v = objP->info.position.vPos - delta;G3TransformAndEncodePoint (&top_p, top_v);G3TransformAndEncodePoint (&bot_p, bot_v);if (bLit) light = ComputeObjectLight (objP, &top_p.p3_vec);else light = I2X (1);G3DrawRodTexPoly (bmP, &bot_p, objP->info.xSize, &top_p, objP->info.xSize, light, NULL);}
开发者ID:paud,项目名称:d2x-xl,代码行数:25,
示例7: RenderPowerupCoronavoid RenderPowerupCorona (CObject *objP, float red, float green, float blue, float alpha){if ((IsEnergyPowerup (objP->info.nId) ? gameOpts->render.coronas.bPowerups : gameOpts->render.coronas.bWeapons) && LoadGlare ()) { static tRgbaColorf keyColors [3] = { {0.2f, 0.2f, 0.9f, 0.2f}, {0.9f, 0.2f, 0.2f, 0.2f}, {0.9f, 0.8f, 0.2f, 0.2f} }; tRgbaColorf color; fix xSize; float fScale; if ((objP->info.nId >= POW_KEY_BLUE) && (objP->info.nId <= POW_KEY_GOLD)) { int i = objP->info.nId - POW_KEY_BLUE; color = keyColors [(((i < 0) || (i > 2)) ? 3 : i)]; xSize = I2X (12); } else { float b = (float) sqrt ((red * 3 + green * 5 + blue * 2) / 10); color.red = red / b; color.green = green / b; color.blue = blue / b; xSize = 2 * objP->info.xSize; //I2X (8); } color.alpha = alpha; fScale = coronaIntensities [gameOpts->render.coronas.nObjIntensity] / 2; color.red *= fScale; color.green *= fScale; color.blue *= fScale; bmpGlare->SetColor (&color); ogl.RenderSprite (bmpGlare, objP->info.position.vPos, xSize, xSize, alpha, LIGHTTRAIL_BLENDMODE, 5); bmpGlare->SetColor (NULL); }}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:36,
示例8: BitBltvoid CCockpit::DrawAfterburnerBar (void){#if 1if (!(LOCALPLAYER.flags & PLAYER_FLAGS_AFTERBURNER)) return; //don't draw if don't haveif (!gameData.physics.xAfterburnerCharge) return;#endif//CCanvas::Current ()->SetColorRGB (255, 255, 255, 255);BitBlt (GAUGE_AFTERBURNER, AFTERBURNER_GAUGE_X, AFTERBURNER_GAUGE_Y);int yMax = FixMul (I2X (1) - gameData.physics.xAfterburnerCharge, AFTERBURNER_GAUGE_H);if (yMax) { int x [4], y [4]; ubyte* tableP = gameStates.video.nDisplayMode ? afterburnerBarTableHires : afterburnerBarTable; y [0] = y [1] = ScaleY (AFTERBURNER_GAUGE_Y); y [3] = ScaleY (AFTERBURNER_GAUGE_Y + yMax) - 1; x [1] = ScaleX (AFTERBURNER_GAUGE_X + tableP [0]); x [0] = ScaleX (AFTERBURNER_GAUGE_X + tableP [1] + 1); x [2] = x [1]; y [2] = 0; for (int i = 1; i < yMax - 1; i++) if (x [2] >= tableP [2 * i]) { x [2] = tableP [2 * i]; y [2] = i; } x [2] = ScaleX (AFTERBURNER_GAUGE_X + x [2] + 1); y [2] = ScaleY (AFTERBURNER_GAUGE_Y + y [2]); x [3] = ScaleX (AFTERBURNER_GAUGE_X + tableP [2 * yMax - 1] + 1); gameStates.render.grAlpha = 1.0f; glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); OglDrawFilledPoly (x, y, 4, gaugeFadeColors [0], 1); glDisable (GL_BLEND); }}
开发者ID:paud,项目名称:d2x-xl,代码行数:36,
示例9: PowerupToModelint CObject::PowerupToDevice (void){ CAngleVector a; short nModel, nId; int bHasModel = 0;if (!SHOW_OBJ_FX) return 0;if (!gameOpts->render.powerups.b3D) return 0;if (info.controlType == CT_WEAPON) return 1;if ((info.nType != OBJ_POWERUP) && (info.nType != OBJ_WEAPON)) return 0;nModel = PowerupToModel (info.nId);if (nModel) nId = info.nId;else { nId = PowerupToObject (info.nId); if (nId >= 0) { nModel = gameData.weapons.info [nId].nModel; bHasModel = 1; } }if (!bHasModel && ((info.nType != OBJ_WEAPON) || !gameData.objs.bIsMissile [info.nId]) && !(nModel && HaveReplacementModel (nModel))) return 0;if (gameData.demo.nState != ND_STATE_PLAYBACK) { a[PA] = (rand () % I2X (1)) - I2X (1) / 2; a[BA] = (rand () % I2X (1)) - I2X (1) / 2; a[HA] = (rand () % I2X (1)) - I2X (1) / 2; info.position.mOrient = CFixMatrix::Create(a); }mType.physInfo.mass = I2X (1);mType.physInfo.drag = 512;mType.physInfo.brakes = 0;#if 0if ((info.nType == OBJ_WEAPON) && gameData.objs.bIsMissile [info.nId])#endif { mType.physInfo.rotVel[X] = 0; mType.physInfo.rotVel[Y] = mType.physInfo.rotVel[Z] = gameOpts->render.powerups.nSpin ? I2X (1) / (5 - gameOpts->render.powerups.nSpin) : 0; }#if 0else { mType.physInfo.rotVel[X] = mType.physInfo.rotVel[Z] = 0; mType.physInfo.rotVel[Y] = gameOpts->render.powerups.nSpin ? I2X (1) / (5 - gameOpts->render.powerups.nSpin) : 0; }#endifinfo.controlType = CT_WEAPON;info.renderType = RT_POLYOBJ;info.movementType = MT_PHYSICS;mType.physInfo.flags = PF_BOUNCE | PF_FREE_SPINNING;rType.polyObjInfo.nModel = nModel;#if 1if (bHasModel) info.xSize = gameData.models.polyModels [0][rType.polyObjInfo.nModel].Rad ();#endifrType.polyObjInfo.nTexOverride = -1;info.xLifeLeft = IMMORTAL_TIME;return 1;}
开发者ID:paud,项目名称:d2x-xl,代码行数:65,
示例10: DoPlayerSmokevoid DoPlayerSmoke (tObject *objP, int i){ int h, j, d, nParts, nType; float nScale; tCloud *pCloud; vmsVector fn, mn, vDir, *vDirP; tThrusterInfo ti; static int bForward = 1;if (i < 0) i = objP->info.nId;if ((gameData.multiplayer.players [i].flags & PLAYER_FLAGS_CLOAKED) || (gameStates.render.automap.bDisplay && IsMultiGame && !AM_SHOW_PLAYERS)) { KillObjectSmoke (i); return; }j = OBJ_IDX (objP);if (gameOpts->render.smoke.bDecreaseLag && (i == gameData.multiplayer.nLocalPlayer)) { fn = objP->info.position.mOrient[FVEC]; mn = objP->info.position.vPos - objP->info.vLastPos; vmsVector::Normalize(fn); vmsVector::Normalize(mn); d = vmsVector::Dot(fn, mn); if (d >= -F1_0 / 2) bForward = 1; else { if (bForward) { if ((h = gameData.smoke.objects [j]) >= 0) { KillObjectSmoke (j); DestroySmoke (h); } bForward = 0; nScale = 0; return; } } }#if 0if (EGI_FLAG (bThrusterFlames, 1, 1, 0)) { if ((a <= F1_0 / 4) && (a || !gameStates.input.bControlsSkipFrame)) //no thruster flames if moving backward DropAfterburnerBlobs (objP, 2, I2X (1), -1, gameData.objs.consoleP, 1); //F1_0 / 4); }#endifif ((gameData.app.nGameMode & GM_NETWORK) && !gameData.multiplayer.players [i].connected) nParts = 0;else if (objP->info.nFlags & (OF_SHOULD_BE_DEAD | OF_DESTROYED)) nParts = 0;else if ((i == gameData.multiplayer.nLocalPlayer) && (gameStates.app.bPlayerIsDead || (gameData.multiplayer.players [i].shields < 0))) nParts = 0;else { h = X2IR (gameData.multiplayer.players [i].shields); nParts = 10 - h / 5; nScale = X2F (objP->info.xSize); if (h <= 25) nScale /= 1.5; else if (h <= 50) nScale /= 2; else nScale /= 3; if (nParts <= 0) { nType = 2; //nParts = (gameStates.entropy.nTimeLastMoved < 0) ? 250 : 125; } else { CreateDamageExplosion (nParts, j); nType = (h > 25); nParts *= 25; nParts += 75; } nParts = objP->mType.physInfo.thrust.IsZero() ? SHIP_MAX_PARTS : SHIP_MAX_PARTS / 2; if (SHOW_SMOKE && nParts && gameOpts->render.smoke.bPlayers) { if (gameOpts->render.smoke.bSyncSizes) { nParts = -MAX_PARTICLES (nParts, gameOpts->render.smoke.nDens [0]); nScale = PARTICLE_SIZE (gameOpts->render.smoke.nSize [0], nScale); } else { nParts = -MAX_PARTICLES (nParts, gameOpts->render.smoke.nDens [1]); nScale = PARTICLE_SIZE (gameOpts->render.smoke.nSize [1], nScale); } if (!objP->mType.physInfo.thrust.IsZero ()) vDirP = NULL; else { // if the ship is standing still, let the thruster smoke move away from it nParts /= 2; nScale /= 2; vDir = OBJPOS (objP)->mOrient [FVEC] * (F1_0 / 8); vDir = -vDir; vDirP = &vDir; } if (0 > (h = gameData.smoke.objects [j])) { //PrintLog ("creating tPlayer smoke/n"); h = SetSmokeObject (j, CreateSmoke (&objP->info.position.vPos, vDirP, NULL, objP->info.nSegment, 2, nParts, nScale, gameOpts->render.smoke.nSize [1], 2, PLR_PART_LIFE / (nType + 1) * (vDirP ? 2 : 1), PLR_PART_SPEED, SMOKE_PARTICLES, j, smokeColors + nType, 1, -1)); } else { if (vDirP) SetSmokeDir (h, vDirP); SetSmokeLife (h, PLR_PART_LIFE / (nType + 1) * (vDirP ? 2 : 1));//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例11: ReadFlyingControlsvoid ReadFlyingControls (CObject *objP){ fix forwardThrustTime; CObject* gmObjP; int bMulti;if (gameData.time.xFrame <= 0) return;if (gameStates.app.bPlayerIsDead || gameStates.app.bEnterGame) { StopPlayerMovement (); FlushInput ();/* VmVecZero(&objP->mType.physInfo.rotThrust); VmVecZero(&objP->mType.physInfo.thrust); VmVecZero(&objP->mType.physInfo.velocity);*/ gameStates.app.bEnterGame--; return; }if ((objP->info.nType != OBJ_PLAYER) || (objP->info.nId != gameData.multiplayer.nLocalPlayer)) return; //references to CPlayerShip require that this obj be the CPlayerDatatGuidedMissileInfo *gmiP = gameData.objs.guidedMissile + gameData.multiplayer.nLocalPlayer;gmObjP = gmiP->objP;if (gmObjP && (gmObjP->info.nSignature == gmiP->nSignature)) { CAngleVector vRotAngs; CFixMatrix mRot, mOrient; fix speed; //this is a horrible hack. guided missile stuff should not be //handled in the middle of a routine that is dealing with the CPlayerData objP->mType.physInfo.rotThrust.SetZero (); vRotAngs [PA] = Controls [0].pitchTime / 2 + gameStates.gameplay.seismic.nMagnitude / 64; vRotAngs [BA] = Controls [0].bankTime / 2 + gameStates.gameplay.seismic.nMagnitude / 16; vRotAngs [HA] = Controls [0].headingTime / 2 + gameStates.gameplay.seismic.nMagnitude / 64; mRot = CFixMatrix::Create (vRotAngs); mOrient = gmObjP->info.position.mOrient * mRot; gmObjP->info.position.mOrient = mOrient; speed = WI_speed (gmObjP->info.nId, gameStates.app.nDifficultyLevel); gmObjP->mType.physInfo.velocity = gmObjP->info.position.mOrient.FVec () * speed; if(IsMultiGame) MultiSendGuidedInfo (gmObjP, 0); }else {#if DBG if (Controls [0].headingTime) Controls [0].headingTime = Controls [0].headingTime;#endif objP->mType.physInfo.rotThrust = CFixVector::Create (Controls [0].pitchTime, Controls [0].headingTime, //Controls [0].headingTime ? I2X (1) / 4 : 0; //Controls [0].headingTime; Controls [0].bankTime); }forwardThrustTime = Controls [0].forwardThrustTime;if ((LOCALPLAYER.flags & PLAYER_FLAGS_AFTERBURNER) && (d_rand () < OBJECTS [gameData.multiplayer.nLocalPlayer].DriveDamage ())) { if (Controls [0].afterburnerState) { //CPlayerData has key down fix afterburner_scale; int oldCount,newCount; //add in value from 0..1 afterburner_scale = I2X (1) + min (I2X (1) / 2, gameData.physics.xAfterburnerCharge) * 2; forwardThrustTime = FixMul (gameData.time.xFrame, afterburner_scale); //based on full thrust oldCount = (gameData.physics.xAfterburnerCharge / (DROP_DELTA_TIME / AFTERBURNER_USE_SECS)); if (!gameStates.gameplay.bAfterburnerCheat) gameData.physics.xAfterburnerCharge -= gameData.time.xFrame / AFTERBURNER_USE_SECS; if (gameData.physics.xAfterburnerCharge < 0) gameData.physics.xAfterburnerCharge = 0; newCount = (gameData.physics.xAfterburnerCharge / (DROP_DELTA_TIME / AFTERBURNER_USE_SECS)); if (gameStates.app.bNostalgia && (oldCount != newCount)) gameStates.render.bDropAfterburnerBlob = 1; //drop blob (after physics called) } else { fix xChargeUp = min (gameData.time.xFrame / 8, I2X (1) - gameData.physics.xAfterburnerCharge); //recharge over 8 seconds if (xChargeUp > 0) { fix xCurEnergy = LOCALPLAYER.energy - I2X (10); xCurEnergy = max (xCurEnergy, 0) / 10; //don't drop below 10 if (xCurEnergy > 0) { //maybe limit charge up by energy xChargeUp = min (xChargeUp, xCurEnergy / 10); if (xChargeUp > 0) { gameData.physics.xAfterburnerCharge += xChargeUp; LOCALPLAYER.energy -= xChargeUp * 100 / 10; //full charge uses 10% of energy } } } } }// Set CObject's thrust vector for forward/backwardobjP->mType.physInfo.thrust = objP->info.position.mOrient.FVec () * forwardThrustTime;// slide left/rightobjP->mType.physInfo.thrust += objP->info.position.mOrient.RVec () * Controls [0].sidewaysThrustTime;// slide up/downobjP->mType.physInfo.thrust += objP->info.position.mOrient.UVec () * Controls [0].verticalThrustTime;objP->mType.physInfo.thrust *= 2 * objP->DriveDamage ();if (!gameStates.input.bSkipControls) memcpy (&gameData.physics.playerThrust, &objP->mType.physInfo.thrust, sizeof (gameData.physics.playerThrust));bMulti = IsMultiGame;if ((objP->mType.physInfo.flags & PF_WIGGLE) && !gameData.objs.speedBoost [objP->Index ()].bBoosted) {#if 1//!DBG WiggleObject (objP);//.........这里部分代码省略.........
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:101,
示例12: Wall// -----------------------------------------------------------------------------//if an effect is hit, and it can blow up, then blow it up//returns true if it blew upint CSegment::CheckEffectBlowup (int nSide, CFixVector& vHit, CObject* blowerP, int bForceBlowup){ int tm, tmf, ec, nBitmap = 0; int bOkToBlow = 0, nSwitchType = -1; short nSound, bPermaTrigger; ubyte vc; fix u, v; fix xDestSize; tEffectClip* ecP = NULL; CBitmap* bmP; CWall* wallP; CTrigger* trigP; CObject* parentP = (!blowerP || (blowerP->cType.laserInfo.parent.nObject < 0)) ? NULL : OBJECTS + blowerP->cType.laserInfo.parent.nObject; // If this CWall has a CTrigger and the blowerP-upper is not the CPlayerData or the buddy, abort!if (parentP) { if ((parentP->info.nType == OBJ_ROBOT) && ROBOTINFO (parentP->info.nId).companion) bOkToBlow = 1; if (!(bOkToBlow || (parentP->info.nType == OBJ_PLAYER)) && ((wallP = Wall (nSide)) && (wallP->nTrigger < gameData.trigs.m_nTriggers))) return 0; }if (!(tm = m_sides [nSide].m_nOvlTex)) return 0;tmf = m_sides [nSide].m_nOvlOrient; //tm flagsec = gameData.pig.tex.tMapInfoP [tm].nEffectClip;if (ec < 0) { if (gameData.pig.tex.tMapInfoP [tm].destroyed == -1) return 0; nBitmap = -1; nSwitchType = 0; }else { ecP = gameData.eff.effectP + ec; if (ecP->flags & EF_ONE_SHOT) return 0; nBitmap = ecP->nDestBm; if (nBitmap < 0) return 0; nSwitchType = 1; }//check if it's an animation (monitor) or casts lightbmP = gameData.pig.tex.bitmapP + gameData.pig.tex.bmIndexP [tm].index;LoadBitmap (gameData.pig.tex.bmIndexP [tm].index, gameStates.app.bD1Data);//this can be blown up...did we hit it?if (!bForceBlowup) { HitPointUV (nSide, &u, &v, NULL, vHit, 0); //evil: always say face zero bForceBlowup = !PixelTranspType (tm, tmf, m_sides [nSide].m_nFrame, u, v); }if (!bForceBlowup) return 0;if (IsMultiGame && netGame.bIndestructibleLights && !nSwitchType) return 0;//note: this must get called before the texture changes,//because we use the light value of the texture to change//the static light in the CSegmentwallP = Wall (nSide);bPermaTrigger = (trigP = Trigger (nSide)) && (trigP->flags & TF_PERMANENT);if (!bPermaTrigger) SubtractLight (Index (), nSide);if (gameData.demo.nState == ND_STATE_RECORDING) NDRecordEffectBlowup (Index (), nSide, vHit);if (nSwitchType) { xDestSize = ecP->xDestSize; vc = ecP->nDestVClip; }else { xDestSize = I2X (20); vc = 3; }/*Object*/CreateExplosion (short (Index ()), vHit, xDestSize, vc);if (nSwitchType) { if ((nSound = gameData.eff.vClipP [vc].nSound) != -1) audio.CreateSegmentSound (nSound, Index (), 0, vHit); if ((nSound = ecP->nSound) != -1) //kill sound audio.DestroySegmentSound (Index (), nSide, nSound); if (!bPermaTrigger && (ecP->nDestEClip != -1) && (gameData.eff.effectP [ecP->nDestEClip].nSegment == -1)) { tEffectClip *newEcP = gameData.eff.effectP + ecP->nDestEClip; int nNewBm = newEcP->changingWallTexture; if (ChangeTextures (-1, nNewBm)) { newEcP->xTimeLeft = EffectFrameTime (newEcP); newEcP->nCurFrame = 0; newEcP->nSegment = Index (); newEcP->nSide = nSide; newEcP->flags |= EF_ONE_SHOT | ecP->flags; newEcP->flags &= ~EF_INITIALIZED; newEcP->nDestBm = ecP->nDestBm; Assert ((nNewBm != 0) && (m_sides [nSide].m_nOvlTex != 0)); m_sides [nSide].m_nOvlTex = nNewBm; //replace with destoyed } } else { Assert ((nBitmap != 0) && (m_sides [nSide].m_nOvlTex != 0));//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例13: NetworkHandlePingReturnvoid NetworkHandlePingReturn (ubyte nPlayer){if ((nPlayer >= gameData.multiplayer.nPlayers) || !pingStats [nPlayer].launchTime) {#if 1 console.printf (CON_DBG, "Got invalid PING RETURN from %s!/n", gameData.multiplayer.players [nPlayer].callsign);#endif return; }xPingReturnTime = TimerGetFixedSeconds ();pingStats [nPlayer].ping = X2I (FixMul (xPingReturnTime - pingStats [nPlayer].launchTime, I2X (1000)));if (!gameStates.render.cockpit.bShowPingStats) HUDInitMessage ("Ping time for %s is %d ms!", gameData.multiplayer.players [nPlayer].callsign, pingStats [nPlayer].ping);pingStats [nPlayer].launchTime = 0;pingStats [nPlayer].received++;}
开发者ID:paud,项目名称:d2x-xl,代码行数:15,
示例14: NetworkDoFramevoid NetworkDoFrame (int bForce, int bListen){ tFrameInfoShort shortSyncPack; static fix xLastEndlevel = 0; int i;if (!(gameData.app.nGameMode & GM_NETWORK)) return;if ((networkData.nStatus == NETSTAT_PLAYING) && !gameStates.app.bEndLevelSequence) { // Don't send postion during escape sequence... if (nakedData.nLength) { Assert (nakedData.nDestPlayer >- 1); if (gameStates.multi.nGameType >= IPX_GAME) IPXSendPacketData (reinterpret_cast<ubyte*> (nakedData.buf), nakedData.nLength, netPlayers.players [nakedData.nDestPlayer].network.ipx.server, netPlayers.players [nakedData.nDestPlayer].network.ipx.node, gameData.multiplayer.players [nakedData.nDestPlayer].netAddress); nakedData.nLength = 0; nakedData.nDestPlayer = -1; } if (networkData.refuse.bWaitForAnswer && TimerGetApproxSeconds ()> (networkData.refuse.xTimeLimit+ (I2X (12)))) networkData.refuse.bWaitForAnswer=0; networkData.xLastSendTime += gameData.time.xFrame; networkData.xLastTimeoutCheck += gameData.time.xFrame; // Send out packet PacksPerSec times per second maximum... unless they fire, then send more often... if ((networkData.xLastSendTime > I2X (1) / PacketsPerSec ()) || (gameData.multigame.laser.bFired) || bForce || networkData.bPacketUrgent) { if (LOCALPLAYER.connected) { int nObject = LOCALPLAYER.nObject; networkData.bPacketUrgent = 0; if (bListen) { MultiSendRobotFrame (0); MultiSendFire (); // Do firing if needed.. } networkData.xLastSendTime = 0; if (netGame.bShortPackets) {#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__) ubyte send_data [MAX_PACKETSIZE];#endif memset (&shortSyncPack, 0, sizeof (shortSyncPack)); CreateShortPos (&shortSyncPack.objPos, OBJECTS+nObject, 0); shortSyncPack.nType = PID_PDATA; shortSyncPack.nPlayer = gameData.multiplayer.nLocalPlayer; shortSyncPack.objRenderType = OBJECTS [nObject].info.renderType; shortSyncPack.nLevel = gameData.missions.nCurrentLevel; shortSyncPack.dataSize = networkData.syncPack.dataSize; memcpy (shortSyncPack.data, networkData.syncPack.data, networkData.syncPack.dataSize); networkData.syncPack.nPackets = INTEL_INT (gameData.multiplayer.players [0].nPacketsSent++); shortSyncPack.nPackets = networkData.syncPack.nPackets;#if !(defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__)) IpxSendGamePacket ( reinterpret_cast<ubyte*> (&shortSyncPack), sizeof (tFrameInfoShort) - networkData.nMaxXDataSize + networkData.syncPack.dataSize);#else SquishShortFrameInfo (shortSyncPack, send_data); IpxSendGamePacket ( reinterpret_cast<ubyte*> (send_data), IPX_SHORT_INFO_SIZE-networkData.nMaxXDataSize+networkData.syncPack.dataSize);#endif } else {// If long packets int send_dataSize; networkData.syncPack.nType = PID_PDATA; networkData.syncPack.nPlayer = gameData.multiplayer.nLocalPlayer; networkData.syncPack.objRenderType = OBJECTS [nObject].info.renderType; networkData.syncPack.nLevel = gameData.missions.nCurrentLevel; networkData.syncPack.nObjSeg = OBJECTS [nObject].info.nSegment; networkData.syncPack.objPos = OBJECTS [nObject].info.position.vPos; networkData.syncPack.objOrient = OBJECTS [nObject].info.position.mOrient; networkData.syncPack.physVelocity = OBJECTS [nObject].mType.physInfo.velocity; networkData.syncPack.physRotVel = OBJECTS [nObject].mType.physInfo.rotVel; send_dataSize = networkData.syncPack.dataSize; // do this so correct size data is sent#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__) // do the swap stuff if (gameStates.multi.nGameType >= IPX_GAME) { networkData.syncPack.nObjSeg = INTEL_SHORT (networkData.syncPack.nObjSeg); INTEL_VECTOR (networkData.syncPack.objPos); INTEL_MATRIX (networkData.syncPack.objOrient); INTEL_VECTOR (networkData.syncPack.physVelocity); INTEL_VECTOR (networkData.syncPack.physRotVel); networkData.syncPack.dataSize = INTEL_SHORT (networkData.syncPack.dataSize); }#endif networkData.syncPack.nPackets = INTEL_INT (gameData.multiplayer.players [0].nPacketsSent++); IpxSendGamePacket ( reinterpret_cast<ubyte*> (&networkData.syncPack), sizeof (tFrameInfo) - networkData.nMaxXDataSize + send_dataSize); } networkData.syncPack.dataSize = 0; // Start data over at 0 length. networkData.bD2XData = 0; if (gameData.reactor.bDestroyed) { if (gameStates.app.bPlayerIsDead) LOCALPLAYER.connected=3; if (TimerGetApproxSeconds () > (xLastEndlevel+ (I2X (1)/2))) { NetworkSendEndLevelPacket (); xLastEndlevel = TimerGetApproxSeconds (); } } } }//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例15: WallAlphafloat WallAlpha (short nSegment, short nSide, short nWall, ubyte widFlags, int bIsMonitor, ubyte bAdditive, tRgbaColorf *colorP, int *nColor, ubyte *bTextured, ubyte *bCloaked, ubyte* bTransparent){ static tRgbaColorf cloakColor = {1, 1, 1, 0}; CWall *wallP; float fAlpha, fMaxColor; short c;if (!IS_WALL (nWall)) return 1;#if DBGif ((nSegment == nDbgSeg) && ((nDbgSide < 0) || (nSide == nDbgSide))) nDbgSeg = nDbgSeg;#endifif (!(wallP = WALLS + nWall)) return 1;if (SHOW_DYN_LIGHT) { *bTransparent = (wallP->state == WALL_DOOR_CLOAKING) || (wallP->state == WALL_DOOR_DECLOAKING); *bCloaked = !*bTransparent && ((widFlags & WID_CLOAKED_FLAG) != 0); }else { *bTransparent = 0; *bCloaked = (wallP->state == WALL_DOOR_CLOAKING) || (wallP->state == WALL_DOOR_DECLOAKING) || ((widFlags & WID_CLOAKED_FLAG) != 0); }if (*bCloaked || *bTransparent || (widFlags & WID_TRANSPARENT_FLAG)) { if (bIsMonitor) return 1; c = wallP->cloakValue; if (*bCloaked || *bTransparent) { *colorP = cloakColor; *nColor = 1; *bTextured = !*bCloaked; colorP->alpha = (c >= FADE_LEVELS) ? 0 : 1.0f - float (c) / float (FADE_LEVELS); if (*bTransparent) colorP->red = colorP->green = colorP->blue = colorP->alpha;#if DBG if (colorP->alpha < 1) return colorP->alpha;#endif return colorP->alpha; } if (!gameOpts->render.color.bWalls) c = 0; if (WALLS [nWall].hps) fAlpha = (float) fabs ((1.0f - (float) WALLS [nWall].hps / ((float) I2X (100)))); else if (IsMultiGame && gameStates.app.bHaveExtraGameInfo [1]) fAlpha = COMPETITION ? 0.5f : (float) (FADE_LEVELS - extraGameInfo [1].grWallTransparency) / (float) FADE_LEVELS; else fAlpha = 1.0f - extraGameInfo [0].grWallTransparency / (float) FADE_LEVELS; if (fAlpha < 1) { //fAlpha = (float) sqrt (fAlpha); paletteManager.Game ()->ToRgbaf ((ubyte) c, *colorP); if (bAdditive) { colorP->red /= fAlpha; colorP->green /= fAlpha; colorP->blue /= fAlpha; } fMaxColor = colorP->red; if (fMaxColor < colorP->green) fMaxColor = colorP->green; if (fMaxColor < colorP->blue) fMaxColor = colorP->blue; if (fMaxColor > 1) { colorP->red /= fMaxColor; colorP->green /= fMaxColor; colorP->blue /= fMaxColor; } *bTextured = 0; *nColor = 1; } return colorP->alpha = fAlpha; }if (gameStates.app.bD2XLevel) { c = wallP->cloakValue; return colorP->alpha = (c && (c < FADE_LEVELS)) ? (float) (FADE_LEVELS - c) / (float) FADE_LEVELS : 1; }if (gameOpts->render.effects.bAutoTransparency && IsTransparentTexture (SEGMENTS [nSegment].m_sides [nSide].m_nBaseTex)) return colorP->alpha = 0.8f;return colorP->alpha = 1;}
开发者ID:paud,项目名称:d2x-xl,代码行数:83,
示例16: AIFireLaserAtPlayer// --------------------------------------------------------------------------------------------------------------------// Note: Parameter gameData.ai.vVecToPlayer is only passed now because guns which aren't on the forward vector from the// center of the robot will not fire right at the player. We need to aim the guns at the player. Barring that, we cheat.// When this routine is complete, the parameter gameData.ai.vVecToPlayer should not be necessary.void AIFireLaserAtPlayer (CObject *objP, CFixVector *vFirePoint, int nGun, CFixVector *vBelievedPlayerPos){ short nShot, nObject = objP->Index (); tAILocalInfo *ailP = gameData.ai.localInfo + nObject; tRobotInfo *botInfoP = &ROBOTINFO (objP->info.nId); CFixVector vFire; CFixVector bpp_diff; short nWeaponType; fix aim, dot; int count, i;Assert (nObject >= 0);// If this robot is only awake because a camera woke it up, don't fire.if (objP->cType.aiInfo.SUB_FLAGS & SUB_FLAGS_CAMERA_AWAKE) return;if (!gameStates.app.cheats.bRobotsFiring) return;if (objP->info.controlType == CT_MORPH) return;// If player is exploded, stop firing.if (gameStates.app.bPlayerExploded) return;if (objP->cType.aiInfo.xDyingStartTime) return; // No firing while in death roll.// Don't let the boss fire while in death roll. Sorry, this is the easiest way to do this.// If you try to key the boss off objP->cType.aiInfo.xDyingStartTime, it will hose the endlevel stuff.if (ROBOTINFO (objP->info.nId).bossFlag) { i = gameData.bosses.Find (nObject); if ((i < 0) || (gameData.bosses [i].m_nDyingStartTime)) return; }// If CPlayerData is cloaked, maybe don't fire based on how long cloaked and randomness.if (LOCALPLAYER.flags & PLAYER_FLAGS_CLOAKED) { fix xCloakTime = gameData.ai.cloakInfo [nObject % MAX_AI_CLOAK_INFO].lastTime; if ((gameData.time.xGame - xCloakTime > CLOAK_TIME_MAX/4) && (d_rand () > FixDiv (gameData.time.xGame - xCloakTime, CLOAK_TIME_MAX)/2)) { SetNextFireTime (objP, ailP, botInfoP, nGun); return; } }// Handle problem of a robot firing through a CWall because its gun tip is on the other// CSide of the CWall than the robot's center. For speed reasons, we normally only compute// the vector from the gun point to the player. But we need to know whether the gun point// is separated from the robot's center by a CWall. If so, don't fire!if (objP->cType.aiInfo.SUB_FLAGS & SUB_FLAGS_GUNSEG) { // Well, the gun point is in a different CSegment than the robot's center. // This is almost always ok, but it is not ok if something solid is in between. int nGunSeg = FindSegByPos (*vFirePoint, objP->info.nSegment, 1, 0); // See if these segments are connected, which should almost always be the case. short nConnSide = SEGMENTS [nGunSeg].ConnectedSide (&SEGMENTS [objP->info.nSegment]); if (nConnSide != -1) { // They are connected via nConnSide in CSegment objP->info.nSegment. // See if they are unobstructed. if (!(SEGMENTS [objP->info.nSegment].IsDoorWay (nConnSide, NULL) & WID_FLY_FLAG)) { // Can't fly through, so don't let this bot fire through! return; } } else { // Well, they are not directly connected, so use FindVectorIntersection to see if they are unobstructed. tFVIQuery fq; tFVIData hit_data; int fate; fq.startSeg = objP->info.nSegment; fq.p0 = &objP->info.position.vPos; fq.p1 = vFirePoint; fq.radP0 = fq.radP1 = 0; fq.thisObjNum = objP->Index (); fq.ignoreObjList = NULL; fq.flags = FQ_TRANSWALL; fate = FindVectorIntersection (&fq, &hit_data); if (fate != HIT_NONE) { Int3 (); // This bot's gun is poking through a CWall, so don't fire. MoveTowardsSegmentCenter (objP); // And decrease chances it will happen again. return; } } }// Set position to fire at based on difficulty level and robot's aiming abilityaim = I2X (FIRE_K) - (FIRE_K-1)* (botInfoP->aim << 8); // I2X (1) in bitmaps.tbl = same as used to be. Worst is 50% more error.// Robots aim more poorly during seismic disturbance.if (gameStates.gameplay.seismic.nMagnitude) { fix temp = I2X (1) - abs (gameStates.gameplay.seismic.nMagnitude); if (temp < I2X (1)/2) temp = I2X (1)/2; aim = FixMul (aim, temp); }// Lead the CPlayerData half the time.// Note that when leading the CPlayerData, aim is perfect. This is probably acceptable since leading is so hacked in.// Problem is all robots will lead equally badly.if (d_rand () < 16384) { if (LeadPlayer (objP, vFirePoint, vBelievedPlayerPos, nGun, &vFire)) // Stuff direction to fire at in vFirePoint. goto player_led;//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例17: RenderLaserCoronavoid RenderLaserCorona (CObject *objP, tRgbaColorf *colorP, float alpha, float fScale){if (!SHOW_OBJ_FX) return;if (SHOW_SHADOWS && (gameStates.render.nShadowPass != 1)) return;if (gameOpts->render.coronas.bShots && LoadGlare ()) { tHitbox* phb = &gameData.models.hitboxes [objP->rType.polyObjInfo.nModel].hitboxes [0]; float fLength = X2F (phb->vMax [Z] - phb->vMin [Z]) / 2; tRgbaColorf color; static CFloatVector vEye = CFloatVector::ZERO; colorP->alpha = alpha; float fScale = coronaIntensities [gameOpts->render.coronas.nObjIntensity] / 2; color = *colorP; colorP = &color; color.red *= fScale; color.green *= fScale; color.blue *= fScale; bmpGlare->SetColor (colorP); ogl.RenderSprite (bmpGlare, objP->info.position.vPos + objP->info.position.mOrient.FVec () * (F2X (fLength - 0.5f)), I2X (1), I2X (1), alpha, LIGHTTRAIL_BLENDMODE, 1); bmpGlare->SetColor (NULL); }}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:25,
示例18: GetCloakInfoint GetCloakInfo (CObject *objP, fix xCloakStartTime, fix xCloakEndTime, tCloakInfo *ciP){ tCloakInfo ci = {0, CLOAKED_FADE_LEVEL, I2X (1), I2X (1), I2X (1), 0, 0}; int i;if (!(xCloakStartTime || xCloakEndTime)) { if (objP->info.nType == OBJ_PLAYER) { xCloakStartTime = gameData.multiplayer.players [objP->info.nId].cloakTime; xCloakEndTime = gameData.multiplayer.players [objP->info.nId].cloakTime + CLOAK_TIME_MAX; } else if (objP->info.nType == OBJ_ROBOT) { if (!ROBOTINFO (objP->info.nId).bossFlag) { xCloakStartTime = gameData.time.xGame - I2X (10); xCloakEndTime = gameData.time.xGame + I2X (10); } else if (0 <= (i = gameData.bosses.Find (objP->Index ()))) { xCloakStartTime = gameData.bosses [i].m_nCloakStartTime; xCloakEndTime = gameData.bosses [i].m_nCloakEndTime; } } }if (xCloakStartTime != 0x7fffffff) ci.xTotalTime = xCloakEndTime - xCloakStartTime;else ci.xTotalTime = gameData.time.xGame;if (objP->info.nType == OBJ_PLAYER) { ci.xFadeinDuration = CLOAK_FADEIN_DURATION_PLAYER; ci.xFadeoutDuration = CLOAK_FADEOUT_DURATION_PLAYER; }else if (objP->info.nType == OBJ_ROBOT) { ci.xFadeinDuration = CLOAK_FADEIN_DURATION_ROBOT; ci.xFadeoutDuration = CLOAK_FADEOUT_DURATION_ROBOT; }else return 0;ci.xDeltaTime = gameData.time.xGame - ((xCloakStartTime == 0x7fffffff) ? 0 : xCloakStartTime);#if 0if (ci.xDeltaTime < ci.xFadeinDuration) { // make object transparent during second half ci.nFadeValue = X2I (FixDiv (ci.xFadeinDuration - ci.xDeltaTime, ci.xFadeinDuration) * CLOAKED_FADE_LEVEL); ci.bFading = 1; }#else// only decrease light during first half of cloak initiation timeif (ci.xDeltaTime < ci.xFadeinDuration / 2) { ci.xLightScale = FixDiv (ci.xFadeinDuration / 2 - ci.xDeltaTime, ci.xFadeinDuration / 2); ci.bFading = -1; }else if (ci.xDeltaTime < ci.xFadeinDuration) { // make object transparent during second half ci.nFadeValue = X2I (FixDiv (ci.xDeltaTime - ci.xFadeinDuration / 2, ci.xFadeinDuration / 2) * CLOAKED_FADE_LEVEL); ci.bFading = 1; }#endifelse if ((xCloakStartTime == 0x7fffffff) || (gameData.time.xGame < xCloakEndTime - ci.xFadeoutDuration)) { static int nCloakDelta = 0, nCloakDir = 1; static fix xCloakTimer = 0; //note, if more than one cloaked CObject is visible at once, the //pulse rate will change! xCloakTimer -= gameData.time.xFrame; while (xCloakTimer < 0) { xCloakTimer += ci.xFadeoutDuration / 12; nCloakDelta += nCloakDir; if (nCloakDelta == 0 || nCloakDelta == 4) nCloakDir = -nCloakDir; } ci.nFadeValue = CLOAKED_FADE_LEVEL - nCloakDelta; }else if (gameData.time.xGame < xCloakEndTime - ci.xFadeoutDuration / 2) { ci.nFadeValue = X2I (FixDiv (ci.xTotalTime - ci.xFadeoutDuration / 2 - ci.xDeltaTime, ci.xFadeoutDuration / 2) * CLOAKED_FADE_LEVEL); ci.bFading = -1; }else { ci.xLightScale = (fix) ((float) (ci.xFadeoutDuration / 2 - (ci.xTotalTime - ci.xDeltaTime) / (float) (ci.xFadeoutDuration / 2))); ci.bFading = 1; }if (ciP) *ciP = ci;return ci.bFading;}
开发者ID:paud,项目名称:d2x-xl,代码行数:80,
示例19: ifint CParticle::Create (CFixVector *vPos, CFixVector *vDir, CFixMatrix *mOrient, short nSegment, int nLife, int nSpeed, char nParticleSystemType, char nClass, float nScale, tRgbaColorf *colorP, int nCurTime, int bBlowUp, float fBrightness, CFixVector *vEmittingFace){ static tRgbaColorf defaultColor = {1,1,1,1}; tRgbaColorf color; CFixVector vDrift; int nRad, nFrames, nType = particleImageManager.GetType (nParticleSystemType);if (nScale < 0) nRad = (int) -nScale;else if (gameOpts->render.particles.bSyncSizes) nRad = (int) PARTICLE_SIZE (gameOpts->render.particles.nSize [0], nScale);else nRad = (int) nScale;if (!nRad) nRad = I2X (1);m_nType = nType;m_bEmissive = (nParticleSystemType == LIGHT_PARTICLES);m_nClass = nClass;m_nSegment = nSegment;m_nBounce = 0;color = colorP ? *colorP : defaultColor;m_color [0] =m_color [1] = color;if ((nType == BULLET_PARTICLES) || (nType == BUBBLE_PARTICLES)) { m_bBright = 0; m_nFade = -1; }else { m_bBright = (nType == SMOKE_PARTICLES) ? (rand () % 50) == 0 : 0; if (colorP) { if (nType != LIGHT_PARTICLES) { m_color [0].red *= RANDOM_FADE; m_color [0].green *= RANDOM_FADE; m_color [0].blue *= RANDOM_FADE; } m_nFade = 0; } else { m_color [0].red = 1.0f; m_color [0].green = 0.5f; m_color [0].blue = 0.0f; m_nFade = 2; } if (m_bEmissive) m_color [0].alpha = (float) (SMOKE_START_ALPHA + 64) / 255.0f; else if (nParticleSystemType != GATLING_PARTICLES) { if (!colorP) m_color [0].alpha = (float) (SMOKE_START_ALPHA + randN (64)) / 255.0f; else { if (colorP->alpha < 0) m_color [0].alpha = -colorP->alpha; else { if (2 == (m_nFade = (char) colorP->alpha)) { m_color [0].red = 1.0f; m_color [0].green = 0.5f; m_color [0].blue = 0.0f; } m_color [0].alpha = (float) (SMOKE_START_ALPHA + randN (64)) / 255.0f; } } }#if 1 if (gameOpts->render.particles.bDisperse && !m_bBright) { fBrightness = 1.0f - fBrightness; m_color [0].alpha += fBrightness * fBrightness / 8.0f; }#endif }//nSpeed = (int) (sqrt (nSpeed) * (float) I2X (1));nSpeed *= I2X (1);if (vDir) { CAngleVector a; CFixMatrix m; float d; a [PA] = randN (I2X (1) / 4) - I2X (1) / 8; a [BA] = randN (I2X (1) / 4) - I2X (1) / 8; a [HA] = randN (I2X (1) / 4) - I2X (1) / 8; m = CFixMatrix::Create (a); vDrift = m * (*vDir); CFixVector::Normalize (vDrift); d = (float) CFixVector::DeltaAngle (vDrift, *vDir, NULL); if (d) { d = (float) exp ((I2X (1) / 8) / d); nSpeed = (fix) ((float) nSpeed / d); }#if 0 if (!colorP) // hack for static particleSystem w/o user defined color m_color [0].green = m_color [0].blue = 1.0f;#endif vDrift *= nSpeed; if ((nType == SMOKE_PARTICLES) || (nType == BUBBLE_PARTICLES)) m_vDir = *vDir * (I2X (3) / 4 + I2X (randN (16)) / 64); else m_vDir = *vDir;//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例20: I2X// Volume 0-I2X (1)int CAudioChannel::Start (short nSound, int nSoundClass, fix nVolume, int nPan, int bLooping, int nLoopStart, int nLoopEnd, int nSoundObj, int nSpeed, const char *pszWAV, CFixVector* vPos){ CSoundSample* soundP = NULL; int bPersistent = (nSoundObj > -1) || bLooping || (nVolume > I2X (1));if (!(pszWAV && *pszWAV && gameOpts->sound.bUseSDLMixer)) { if (nSound < 0) return -1; if (!gameData.pig.sound.nSoundFiles [gameStates.sound.bD1Sound]) return -1; soundP = gameData.pig.sound.sounds [gameStates.sound.bD1Sound] + nSound % gameData.pig.sound.nSoundFiles [gameStates.sound.bD1Sound]; if (!(soundP->data [soundP->bCustom].Buffer () && soundP->nLength [soundP->bCustom])) return -1; }if (m_info.bPlaying) { m_info.bPlaying = 0; if (m_info.nSoundObj > -1) audio.EndSoundObject (m_info.nSoundObj); if (soundQueue.Channel () == audio.FreeChannel ()) soundQueue.End (); }#if USE_OPENALif (m_info.source == 0xFFFFFFFF) { CFloatVector fPos; DigiALError (); alGenSources (1, &m_info.source); if (DigiALError ()) return -1; alSourcei (m_info.source, AL_BUFFER, soundP->buffer); if (DigiALError ()) return -1; alSourcef (m_info.source, AL_GAIN, ((nVolume < I2X (1)) ? X2F (nVolume) : 1) * 2 * X2F (m_info.nVolume)); alSourcei (m_info.source, AL_LOOPING, (ALuint) ((nSoundObj > -1) || bLooping || (nVolume > I2X (1)))); fPos.Assign (vPos ? *vPos : OBJECTS [LOCALPLAYER.nObject].nPosition.vPos); alSourcefv (m_info.source, AL_POSITION, reinterpret_cast<ALfloat*> (fPos)); alSource3f (m_info.source, AL_VELOCITY, 0, 0, 0); alSource3f (m_info.source, AL_DIRECTION, 0, 0, 0); if (DigiALError ()) return -1; alSourcePlay (m_info.source); if (DigiALError ()) return -1; }#endif#if USE_SDL_MIXERif (gameOpts->sound.bUseSDLMixer) { if (m_info.mixChunkP) { Mix_HaltChannel (m_info.nChannel); if (m_info.bBuiltIn) m_info.bBuiltIn = 0; else Mix_FreeChunk (m_info.mixChunkP); m_info.mixChunkP = NULL; } }#endifif (m_info.bResampled) { m_info.sample.Destroy (); m_info.bResampled = 0; }#if USE_SDL_MIXERif (gameOpts->sound.bUseSDLMixer) { //resample to two channels m_info.nChannel = audio.FreeChannel (); if (pszWAV && *pszWAV) { if (!(m_info.mixChunkP = LoadAddonSound (pszWAV, &m_info.bBuiltIn))) return -1; } else { int l; if (soundP->bHires) { l = soundP->nLength [soundP->bCustom]; m_info.sample.SetBuffer (soundP->data [soundP->bCustom].Buffer (), 1, l); m_info.mixChunkP = Mix_QuickLoad_WAV (reinterpret_cast<Uint8*> (m_info.sample.Buffer ())); } else { if (gameOpts->sound.bHires [0]) return -1; //cannot mix hires and standard sounds l = Resample (soundP, gameStates.sound.bD1Sound && (gameOpts->sound.digiSampleRate != SAMPLE_RATE_11K), songManager.MP3 ()); if (l <= 0) return -1; if (nSpeed < I2X (1)) l = Speedup (soundP, nSpeed);#if MAKE_WAV m_info.mixChunkP = Mix_QuickLoad_WAV (reinterpret_cast<Uint8*> (m_info.sample.Buffer ()));#else m_info.mixChunkP = Mix_QuickLoad_RAW (reinterpret_cast<Uint8*> (m_info.sample.Buffer ()), l);#endif } } Mix_VolPan (m_info.nChannel, nVolume, nPan); Mix_PlayChannel (m_info.nChannel, m_info.mixChunkP, bLooping ? -1 : nLoopEnd - nLoopStart); }else #elseif (pszWAV && *pszWAV)//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例21: DrawObjectBlob//.........这里部分代码省略......... } } }else { nTransp = 3; fAlpha = 1.0f; }#if 0if (bmi < 0) { PageInAddonBitmap (bmi); bmP = gameData.pig.tex.addonBitmaps - bmi - 1;#if DBG if ((objP->rType.vClipInfo.nCurFrame < 0) || (objP->rType.vClipInfo.nCurFrame >= bmP->FrameCount ())) { objP->rType.vClipInfo.nCurFrame = 0; return; }#endif }else { LoadBitmap (bmi, 0); bmP = gameData.pig.tex.bitmaps [0] + bmi; }#elseif (bmi < 0) { bmP = gameData.pig.tex.addonBitmaps - bmi - 1; bmP = bmP->SetCurFrame (iFrame); }else { CBitmap* bmoP; bmP = gameData.pig.tex.bitmaps [0] + bmi; if ((bmP->Type () == BM_TYPE_STD) && (bmoP = bmP->Override ())) bmP = bmoP->SetCurFrame (iFrame); }#endif//bmP->SetupTexture (1, 1);if (!bmP) return;#if 0if (!bmP->Prepared () && bmP->PrepareTexture (1, 0)) return;#endiffScale = ObjectBlobColor (objP, bmP, &color);if (colorP /*&& (bmi >= 0)*/) *colorP = color; //memcpy (colorP, gameData.pig.tex.bitmapColors + bmi, sizeof (tRgbaColorf));xSize = objP->info.xSize;if (nType == OBJ_POWERUP) { if ((bEnergy && gameOpts->render.coronas.bPowerups) || (!bEnergy && gameOpts->render.coronas.bWeapons)) RenderPowerupCorona (objP, color.red, color.green, color.blue, coronaIntensities [gameOpts->render.coronas.nObjIntensity]); }if ((objP->info.nType == OBJ_POWERUP) && (objP->info.nId == POW_SHIELD_BOOST) && !gameStates.app.bNostalgia && gameOpts->render.powerups.b3D && gameOpts->render.powerups.b3DShields) { if ((objP->mType.physInfo.velocity.IsZero ()) && (objP->info.movementType != MT_SPINNING)) { objP->info.movementType = MT_SPINNING; objP->mType.spinRate = objP->info.position.mOrient.UVec () * (I2X (1) / 8); } //the actual shield in the sprite texture has 3/4 of the textures size DrawShieldSphere (objP, 3 * color.red / 2, 3 * color.green / 2, 3 * color.blue / 2, 1.0f, 3 * objP->info.xSize / 4); }else if ((gameOpts->render.bDepthSort > 0) && (fAlpha < 1)) { if (bAdditive) {#if 1 color.red = color.green = color.blue = 0.5f;#else if ((nType == OBJ_FIREBALL) && (fScale > 0)) { fScale = 1.0f - fScale / 6.0f; color.red *= fScale; color.green *= fScale; color.blue *= fScale; }#endif } else color.red = color.green = color.blue = 1; color.alpha = fAlpha; if (bmP->Width () > bmP->Height ()) transparencyRenderer.AddSprite (bmP, objP->info.position.vPos, &color, xSize, FixMulDiv (xSize, bmP->Height (), bmP->Width ()), iFrame, bAdditive, (nType == OBJ_FIREBALL) ? 10.0f : 0.0f); else transparencyRenderer.AddSprite (bmP, objP->info.position.vPos, &color, FixMulDiv (xSize, bmP->Width (), bmP->Height ()), xSize, iFrame, bAdditive, (nType == OBJ_FIREBALL) ? 10.0f : 0.0f); }else { if (bmP->Width () > bmP->Height ()) G3DrawBitmap (objP->info.position.vPos, xSize, FixMulDiv (xSize, bmP->Height (), bmP->Width ()), bmP, NULL, fAlpha, nTransp); else G3DrawBitmap (objP->info.position.vPos, FixMulDiv (xSize, bmP->Width (), bmP->Height ()), xSize, bmP, NULL, fAlpha, nTransp); }gameData.render.nTotalSprites++;}
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例22: RenderWeaponModelstatic int RenderWeaponModel (CObject* objP, int bDepthSort, int bSpectate){if (automap.m_bDisplay && !AM_SHOW_POWERUPS (1)) return 0;if (!(gameStates.app.bNostalgia || gameOpts->render.powerups.b3D) && WeaponIsMine (objP->info.nId) && (objP->info.nId != SMALLMINE_ID)) ConvertWeaponToVClip (objP);else { if (gameStates.render.nType != 1) return 0; if (gameData.objs.bIsMissile [objP->info.nId]) { //make missiles smaller during launch if ((objP->cType.laserInfo.parent.nType == OBJ_PLAYER) && (gameData.models.renderModels [1][108].m_bValid > 0)) { //hires player ship float dt = X2F (gameData.time.xGame - objP->CreationTime ()); if (dt < 1) { fix xScale = (fix) (I2X (1) + I2X (1) * dt * dt) / 2; gameData.models.vScale.Set (xScale, xScale, xScale); } } //DoObjectSmoke (objP); DrawPolygonObject (objP, bDepthSort, 0);#if RENDER_HITBOX# if 0 DrawShieldSphere (objP, 0.66f, 0.2f, 0.0f, 0.4f);# else RenderHitbox (objP, 0.5f, 0.0f, 0.6f, 0.4f);# endif#endif RenderThrusterFlames (objP); gameData.models.vScale.SetZero (); } else {#if RENDER_HITBOX# if 0 DrawShieldSphere (objP, 0.66f, 0.2f, 0.0f, 0.4f);# else RenderHitbox (objP, 0.5f, 0.0f, 0.6f, 0.4f);# endif#endif if (objP->info.nType != OBJ_WEAPON) { DrawPolygonObject (objP, bDepthSort, 0); if ((objP->info.nId != SMALLMINE_ID) && !gameStates.render.bQueryCoronas) RenderLightTrail (objP); } else { if ((objP->info.nId == VULCAN_ID) || (objP->info.nId == GAUSS_ID)) { if (SHOW_OBJ_FX && extraGameInfo [0].bTracers) { if (!gameStates.render.bQueryCoronas) RenderLightTrail (objP); gameData.models.vScale.Set (I2X (1) / 4, I2X (1) / 4, I2X (2)); CFixVector vSavedPos = objP->info.position.vPos; objP->info.position.vPos += objP->info.position.mOrient.FVec (); DrawPolygonObject (objP, bDepthSort, 0); objP->info.position.vPos = vSavedPos; } } else { if ((objP->info.nId != SMALLMINE_ID) && !gameStates.render.bQueryCoronas) RenderLightTrail (objP); DrawPolygonObject (objP, bDepthSort, 0); } gameData.models.vScale.SetZero (); } } }return 1;}
开发者ID:paud,项目名称:d2x-xl,代码行数:67,
示例23: SetVertexLightfix SetVertexLight (int nSegment, int nSide, int nVertex, tFaceColor *colorP, fix light){ tRgbColorf *pdc; fix dynLight; float fl, dl, hl;//the tUVL struct has static light already in it//scale static light for destruction effectif (EGI_FLAG (bDarkness, 0, 0, 0)) light = 0;else {#if LMAP_LIGHTADJUST if (USE_LIGHTMAPS) { else { light = I2X (1) / 2 + gameData.render.lights.segDeltas [nSegment * 6 + nSide]; if (light < 0) light = 0; } }#endif if (gameData.reactor.bDestroyed || gameStates.gameplay.seismic.nMagnitude) //make lights flash light = FixMul (gameStates.render.nFlashScale, light); }//add in dynamic light (from explosions, etc.)dynLight = gameData.render.lights.dynamicLight [nVertex];fl = X2F (light);dl = X2F (dynLight);light += dynLight;#if DBGif (nVertex == nDbgVertex) nVertex = nVertex;#endifif (gameStates.app.bHaveExtraGameInfo [IsMultiGame]) { if (gameData.render.lights.bGotDynColor [nVertex]) { pdc = gameData.render.lights.dynamicColor + nVertex; if (gameOpts->render.color.bMix) { if (gameOpts->render.color.bGunLight) { if (gameStates.render.bAmbientColor) { if ((fl != 0) && gameData.render.color.vertBright [nVertex]) { hl = fl / gameData.render.color.vertBright [nVertex]; colorP->color.red = colorP->color.red * hl + pdc->red * dl; colorP->color.green = colorP->color.green * hl + pdc->green * dl; colorP->color.blue = colorP->color.blue * hl + pdc->blue * dl; ScaleColor (colorP, fl + dl); } else { colorP->color.red = pdc->red * dl; colorP->color.green = pdc->green * dl; colorP->color.blue = pdc->blue * dl; ScaleColor (colorP, dl); } } else { colorP->color.red = fl + pdc->red * dl; colorP->color.green = fl + pdc->green * dl; colorP->color.blue = fl + pdc->blue * dl; ScaleColor (colorP, fl + dl); } } else { colorP->color.red = colorP->color.green = colorP->color.blue = fl + dl; } if (gameOpts->render.color.bCap) { if (colorP->color.red > 1.0) colorP->color.red = 1.0; if (colorP->color.green > 1.0) colorP->color.green = 1.0; if (colorP->color.blue > 1.0) colorP->color.blue = 1.0; } } else { float dl = X2F (light); dl = (float) pow (dl, 1.0f / 3.0f); colorP->color.red = pdc->red * dl; colorP->color.green = pdc->green * dl; colorP->color.blue = pdc->blue * dl; } } else { ScaleColor (colorP, fl + dl); } }else { ScaleColor (colorP, fl + dl); }//saturate at max valueif (light > MAX_LIGHT) light = MAX_LIGHT;return light;}
开发者ID:paud,项目名称:d2x-xl,代码行数:93,
示例24: DrawPolygonObjectint DrawPolygonObject (CObject *objP, int bDepthSort, int bForce){ fix xLight; int imSave = 0; fix xEngineGlow [2]; //element 0 is for engine glow, 1 for headlight int bBlendPolys = 0; int bBrightPolys = 0; int bGatling = 0; int bCloaked = ObjectIsCloaked (objP); int bEnergyWeapon; int i, id, bOk = 0;if (objP->info.nType == 255) return 0;id = (int) objP->info.nId;if ((id < 0) || (id == 255)) bEnergyWeapon = id = 0;else {#if 0 bGatling = ((objP->info.nType == OBJ_WEAPON) && ((id == VULCAN_ID) || (id == GAUSS_ID)));#endif bEnergyWeapon = (objP->info.nType == OBJ_WEAPON) && gameData.objs.bIsWeapon [id] && !gameData.objs.bIsMissile [id]; }#if SHADOWSif (!bForce && FAST_SHADOWS && !gameOpts->render.shadows.bSoft && (gameStates.render.nShadowPass == 3)) return 1;#endifif (gameStates.render.bBuildModels) xLight = I2X (1);else { xLight = CalcObjectLight (objP, xEngineGlow); if ((bCloaked || bEnergyWeapon) && bDepthSort && (gameStates.render.nShadowPass != 2)) { transparencyRenderer.AddObject (objP); return 1; } if (DrawHiresObject (objP, xLight, xEngineGlow)) return 1; gameStates.render.bBrightObject = bEnergyWeapon; gameOpts->render.bDepthSort = -gameOpts->render.bDepthSort; imSave = gameStates.render.nInterpolationMethod; if (bLinearTMapPolyObjs) gameStates.render.nInterpolationMethod = 1; }if (objP->rType.polyObjInfo.nTexOverride != -1) {#if DBG CPolyModel* pm = gameData.models.polyModels [0] + objP->rType.polyObjInfo.nModel;#endif tBitmapIndex bm = gameData.pig.tex.bmIndex [0][objP->rType.polyObjInfo.nTexOverride], bmiP [MAX_MODEL_TEXTURES];#if DBG Assert (pm->TextureCount () <= 12);#endif for (i = 0; i < MAX_MODEL_TEXTURES; i++) //fill whole array, in case simple model needs more bmiP [i] = bm; bOk = DrawPolyModel (objP, &objP->info.position.vPos, &objP->info.position.mOrient, reinterpret_cast<CAngleVector*> ( &objP->rType.polyObjInfo.animAngles), objP->rType.polyObjInfo.nModel, objP->rType.polyObjInfo.nSubObjFlags, xLight, xEngineGlow, bmiP, NULL); }else { if (bCloaked) { if (objP->info.nType == OBJ_PLAYER) bOk = DrawCloakedObject (objP, xLight, xEngineGlow, gameData.multiplayer.players [id].cloakTime, gameData.multiplayer.players [id].cloakTime + CLOAK_TIME_MAX); else if (objP->info.nType == OBJ_ROBOT) { if (!ROBOTINFO (id).bossFlag) bOk = DrawCloakedObject (objP, xLight, xEngineGlow, gameData.time.xGame - I2X (10), gameData.time.xGame + I2X (10)); else if (0 <= (i = gameData.bosses.Find (objP->Index ()))) bOk = DrawCloakedObject (objP, xLight, xEngineGlow, gameData.bosses [i].m_nCloakStartTime, gameData.bosses [i].m_nCloakEndTime); } } else { tBitmapIndex *bmiAltTex = (objP->rType.polyObjInfo.nAltTextures > 0) ? mpTextureIndex [objP->rType.polyObjInfo.nAltTextures - 1] : NULL; // Snipers get bright when they fire. if (!gameStates.render.bBuildModels) { if ((objP->info.nType == OBJ_ROBOT) && (gameData.ai.localInfo [objP->Index ()].nextPrimaryFire < I2X (1) / 8) && (objP->cType.aiInfo.behavior == AIB_SNIPE)) xLight = 2 * xLight + I2X (1); bBlendPolys = bEnergyWeapon && (gameData.weapons.info [id].nInnerModel > -1); bBrightPolys = bGatling || (bBlendPolys && WI_energy_usage (id)); if (bEnergyWeapon) { if (gameOpts->legacy.bRender) gameStates.render.grAlpha = GrAlpha (FADE_LEVELS - 2); else ogl.BlendFunc (GL_ONE, GL_ONE); } if (bBlendPolys) {#if 0 fix xDistToEye = CFixVector::Dist(gameData.objs.viewerP->info.position.vPos, objP->info.position.vPos); if (xDistToEye < gameData.models.nSimpleModelThresholdScale * I2X (2))#endif bOk = DrawPolyModel (objP, &objP->info.position.vPos, &objP->info.position.mOrient,//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例25: Errorint CFont::DrawString (int left, int top, const char *s){ const char* textP, * nextRowP, * text_ptr1; int width, spacing, letter; int x, y; int origColor = CCanvas::Current ()->FontColor (0).index; //to allow easy reseting to default string color with colored strings -MPM float fScale = fontManager.Scale (); ubyte c; CBitmap* bmf; tCanvasColor* colorP = (m_info.flags & FT_COLOR) ? NULL : &CCanvas::Current ()->FontColor (0); if (CCanvas::Current ()->Mode () != BM_OGL) return -1;nextRowP = s;y = top;if (screen.Canvas ()->Mode () != BM_OGL) Error ("carp./n");while (nextRowP != NULL) { text_ptr1 = nextRowP; nextRowP = NULL; textP = text_ptr1; x = (left == 0x8000) ? fontManager.Current ()->GetCenteredX (textP) : left; while ((c = *textP)) { if (c == '/n') { nextRowP = textP + 1; y += m_info.height + 2; break; } letter = c - m_info.minChar; fontManager.Current ()->GetCharWidth (c, textP [1], width, spacing); if (c <= 0x06) { //not in font, draw as space textP = ScanEmbeddedColors (c, textP, origColor, 128, 2); continue; } if (fontManager.Current ()->InFont (letter)) { bmf = m_info.bitmaps + letter; bmf->AddFlags (BM_FLAG_TRANSPARENT); bmf->RenderScaled (x, y, int (bmf->Width () * fScale), int (bmf->Height () * fScale), I2X (1), 0, colorP); } x += spacing; textP++; } }return 0;}
开发者ID:paud,项目名称:d2x-xl,代码行数:46,
示例26: // ------------------------------------------------------------------------// static const initializationsconst CFloatVector CFloatVector::ZERO = CFloatVector::Create (0,0,0,1);const CFloatVector CFloatVector::ZERO4 = CFloatVector::Create (0,0,0,0);const CFloatVector CFloatVector::XVEC = CFloatVector::Create (1,0,0,1);const CFloatVector CFloatVector::YVEC = CFloatVector::Create (0,1,0,1);const CFloatVector CFloatVector::ZVEC = CFloatVector::Create (0,0,1,1);const CFloatVector3 CFloatVector3::ZERO = CFloatVector3::Create (0,0,0);const CFloatVector3 CFloatVector3::XVEC = CFloatVector3::Create (1,0,0);const CFloatVector3 CFloatVector3::YVEC = CFloatVector3::Create (0,1,0);const CFloatVector3 CFloatVector3::ZVEC = CFloatVector3::Create (0,0,1);const CFixVector CFixVector::ZERO = CFixVector::Create (0,0,0);const CFixVector CFixVector::XVEC = CFixVector::Create (I2X (1),0,0);const CFixVector CFixVector::YVEC = CFixVector::Create (0,I2X (1),0);const CFixVector CFixVector::ZVEC = CFixVector::Create (0,0,I2X (1));const CAngleVector CAngleVector::ZERO = CAngleVector::Create (0,0,0);const CFixMatrix CFixMatrix::IDENTITY = CFixMatrix::Create (CFixVector::XVEC, CFixVector::YVEC, CFixVector::ZVEC);const CFloatMatrix CFloatMatrix::IDENTITY = CFloatMatrix::Create (CFloatVector::Create (1.0f, 0, 0, 0), CFloatVector::Create (0, 1.0f, 0, 0), CFloatVector::Create (0, 0, 1.0f, 0), CFloatVector::Create (0, 0, 0, 1.0f));// ------------------------------------------------------------------------
开发者ID:paud,项目名称:d2x-xl,代码行数:31,
示例27: GrStringint GrString (int x, int y, const char *s, int *idP){if (gameOpts->render.coronas.nStyle < 2) { grsString *ps; if ((MODE == BM_OGL) && (ps = GetPoolString (s, idP))) { CBitmap* bmP = ps->bmP; float fScale = fontManager.Scale (); ps->bmP->RenderScaled (x, y, int (bmP->Width () * fScale), int (bmP->Height () * fScale), I2X (1), 0, &CCanvas::Current ()->FontColor (0)); return (int) (ps - stringPool) + 1; } }#if 0return fontManager.Current ()->DrawString (x, y, s);#else int w, h, aw, clipped = 0;Assert (fontManager.Current () != NULL);if (x == 0x8000) { if (y < 0) clipped |= 1; fontManager.Current ()->StringSize (s, w, h, aw); // for x, since this will be centered, only look at // width. if (w > CCanvas::Current ()->Width ()) clipped |= 1; if (y > CCanvas::Current ()->Height ()) clipped |= 3; else if ((y + h) > CCanvas::Current ()->Height ()) clipped |= 1; else if ((y + h) < 0) clipped |= 2; }else { if ((x < 0) || (y < 0)) clipped |= 1; fontManager.Current ()->StringSize (s, w, h, aw); if (x > CCanvas::Current ()->Width ()) clipped |= 3; else if ((x + w) > CCanvas::Current ()->Width ()) clipped |= 1; else if ((x + w) < 0) clipped |= 2; if (y > CCanvas::Current ()->Height ()) clipped |= 3; else if ((y + h) > CCanvas::Current ()->Height ()) clipped |= 1; else if ((y + h) < 0) clipped |= 2; }if (!clipped) return fontManager.Current ()->DrawString (x, y, s);if (clipped & 2) { // Completely clipped... return 0; }if (clipped & 1) { // Partially clipped... }// Partially clipped...if (MODE == BM_OGL) return fontManager.Current ()->DrawString (x, y, s);if (fontManager.Current ()->Flags () & FT_COLOR) return fontManager.Current ()->DrawString (x, y, s);if (CCanvas::Current ()->FontColor (1).index == -1) return GrInternalStringClippedM (x, y, s);return GrInternalStringClipped (x, y, s);#endif}
开发者ID:paud,项目名称:d2x-xl,代码行数:75,
示例28: AIDoActualFiringStuff// --------------------------------------------------------------------------------------------------------------------// If fire_anyway, fire even if CPlayerData is not visible. We're firing near where we believe him to be. Perhaps he's// lurking behind a corner.void AIDoActualFiringStuff (CObject *objP, tAIStaticInfo *aiP, tAILocalInfo *ailP, tRobotInfo *botInfoP, int nGun){ fix dot;if ((gameData.ai.nPlayerVisibility == 2) || (gameData.ai.nDistToLastPlayerPosFiredAt < FIRE_AT_NEARBY_PLAYER_THRESHOLD)) { CFixVector vFirePos = gameData.ai.vBelievedPlayerPos; // Hack: If visibility not == 2, we're here because we're firing at a nearby player. // So, fire at gameData.ai.vLastPlayerPosFiredAt instead of the CPlayerData position. if (!botInfoP->attackType && (gameData.ai.nPlayerVisibility != 2)) vFirePos = gameData.ai.vLastPlayerPosFiredAt; // Changed by mk, 01/04/95, onearm would take about 9 seconds until he can fire at you. // Above comment corrected. Date changed from 1994, to 1995. Should fix some very subtle bugs, as well as not cause me to wonder, in the future, why I was writing AI code for onearm ten months before he existed. if (!gameData.ai.bObjAnimates || ReadyToFire (botInfoP, ailP)) { dot = CFixVector::Dot (objP->info.position.mOrient.FVec (), gameData.ai.vVecToPlayer); if ((dot >= I2X (7) / 8) || ((dot > I2X (1) / 4) && botInfoP->bossFlag)) { if (nGun < botInfoP->nGuns) { if (botInfoP->attackType == 1) { if (gameStates.app.bPlayerExploded || (gameData.ai.xDistToPlayer >= objP->info.xSize + gameData.objs.consoleP->info.xSize + I2X (2))) // botInfoP->circleDistance [gameStates.app.nDifficultyLevel] + gameData.objs.consoleP->info.xSize) return; if (!AIMultiplayerAwareness (objP, ROBOT_FIRE_AGITATION - 2)) return; DoAIRobotHitAttack (objP, gameData.objs.consoleP, &objP->info.position.vPos); } else {#if 1 if (AICanFireAtPlayer (objP, &gameData.ai.vGunPoint, &vFirePos)) {#else if (gameData.ai.vGunPoint.p.x || gameData.ai.vGunPoint.p.y || gameData.ai.vGunPoint.p.z) {#endif if (!AIMultiplayerAwareness (objP, ROBOT_FIRE_AGITATION)) return; // New, multi-weapon-nType system, 06/05/95 (life is slipping awayd:/temp/dm_test.) if (nGun != 0) { if (ailP->nextPrimaryFire <= 0) { AIFireLaserAtPlayer (objP, &gameData.ai.vGunPoint, nGun, &vFirePos); gameData.ai.vLastPlayerPosFiredAt = vFirePos; } if ((ailP->nextSecondaryFire <= 0) && (botInfoP->nSecWeaponType != -1)) { CalcGunPoint (&gameData.ai.vGunPoint, objP, 0); AIFireLaserAtPlayer (objP, &gameData.ai.vGunPoint, 0, &vFirePos); gameData.ai.vLastPlayerPosFiredAt = vFirePos; } } else if (ailP->nextPrimaryFire <= 0) { AIFireLaserAtPlayer (objP, &gameData.ai.vGunPoint, nGun, &vFirePos); gameData.ai.vLastPlayerPosFiredAt = vFirePos; } } } } // Wants to fire, so should go into chase mode, probably. if ((aiP->behavior != AIB_RUN_FROM) && (aiP->behavior != AIB_STILL) && (aiP->behavior != AIB_SNIPE) && (aiP->behavior != AIB_FOLLOW) && !botInfoP->attackType && ((ailP->mode == AIM_FOLLOW_PATH) || (ailP->mode == AIM_IDLING))) ailP->mode = AIM_CHASE_OBJECT; aiP->GOAL_STATE = AIS_RECOVER; ailP->goalState [aiP->CURRENT_GUN] = AIS_RECOVER; // Switch to next gun for next fire.#if 0 if (++(aiP->CURRENT_GUN) >= botInfoP->nGuns) { if ((botInfoP->nGuns == 1) || (botInfoP->nSecWeaponType == -1)) aiP->CURRENT_GUN = 0; else aiP->CURRENT_GUN = 1; }#endif } } }else if ((!botInfoP->attackType && gameData.weapons.info [botInfoP->nWeaponType].homingFlag) || (((botInfoP->nSecWeaponType != -1) && gameData.weapons.info [botInfoP->nSecWeaponType].homingFlag))) { fix dist; // Robots which fire homing weapons might fire even if they don't have a bead on the player. if ((!gameData.ai.bObjAnimates || (ailP->achievedState [aiP->CURRENT_GUN] == AIS_FIRE)) && (((ailP->nextPrimaryFire <= 0) && (aiP->CURRENT_GUN != 0)) || ((ailP->nextSecondaryFire <= 0) && (aiP->CURRENT_GUN == 0))) && ((dist = CFixVector::Dist(gameData.ai.vHitPos, objP->info.position.vPos)) > I2X (40))) { if (!AIMultiplayerAwareness (objP, ROBOT_FIRE_AGITATION)) return; AIFireLaserAtPlayer (objP, &gameData.ai.vGunPoint, nGun, &gameData.ai.vBelievedPlayerPos); aiP->GOAL_STATE = AIS_RECOVER; ailP->goalState [aiP->CURRENT_GUN] = AIS_RECOVER; // Switch to next gun for next fire. if (++(aiP->CURRENT_GUN) >= botInfoP->nGuns) aiP->CURRENT_GUN = 0; } else { // Switch to next gun for next fire. if (++(aiP->CURRENT_GUN) >= botInfoP->nGuns) aiP->CURRENT_GUN = 0;//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
示例29: X2Fint CLightManager::Add (CSegFace* faceP, tRgbaColorf *colorP, fix xBrightness, short nSegment, short nSide, short nObject, short nTexture, CFixVector *vPos, ubyte bAmbient){ CDynLight* pl; short h, i; float fBrightness = X2F (xBrightness);#if USE_OGL_LIGHTS GLint nMaxLights;#endif#if 0if (xBrightness > I2X (1)) xBrightness = I2X (1);#endifif (fBrightness <= 0) return -1;#if DBGif ((nDbgSeg >= 0) && (nSegment == nDbgSeg)) nSegment = nSegment;if ((nDbgObj >= 0) && (nObject == nDbgObj)) nDbgObj = nDbgObj;if (colorP && ((colorP->red > 1) || (colorP->green > 1) || (colorP->blue > 1))) colorP = colorP;#endifif (gameStates.render.nLightingMethod && (nSegment >= 0) && (nSide >= 0)) {#if 1 fBrightness /= Intensity (colorP->red, colorP->green, colorP->blue);#else if (fBrightness < 1) fBrightness = (float) sqrt (fBrightness); else fBrightness *= fBrightness;#endif }if (colorP) colorP->alpha = 1.0f;if (0 <= (h = Update (colorP, fBrightness, nSegment, nSide, nObject))) return h;if (!colorP) return -1;if ((colorP->red == 0.0f) && (colorP->green == 0.0f) && (colorP->blue == 0.0f)) { if (gameStates.app.bD2XLevel && gameStates.render.bColored) return -1; colorP->red = colorP->green = colorP->blue = 1.0f; }if (m_data.nLights [0] >= MAX_OGL_LIGHTS) { gameStates.render.bHaveDynLights = 0; return -1; //too many lights }i = m_data.nLights [0]; //LastEnabledDynLight () + 1;pl = m_data.lights + i;pl->info.faceP = faceP;pl->info.nSegment = nSegment;pl->info.nSide = nSide;pl->info.nObject = nObject;pl->info.nPlayer = -1;pl->info.bState = 1;pl->info.bSpot = 0;pl->info.fBoost = 0;pl->info.bPowerup = 0;pl->info.bAmbient = bAmbient;//0: static light//2: object/lightning//3: headlightif (nObject >= 0) { CObject *objP = OBJECTS + nObject; //HUDMessage (0, "Adding object light %d, type %d", m_data.nLights [0], objP->info.nType); pl->info.nType = 2; if (objP->info.nType == OBJ_POWERUP) { int id = objP->info.nId; if ((id == POW_EXTRA_LIFE) || (id == POW_ENERGY) || (id == POW_SHIELD_BOOST) || (id == POW_HOARD_ORB) || (id == POW_MONSTERBALL) || (id == POW_INVUL)) pl->info.bPowerup = 1; else pl->info.bPowerup = 2; } pl->info.vPos = objP->info.position.vPos; pl->info.fRad = 0; //X2F (OBJECTS [nObject].size) / 2; if (fBrightness > 1) { if ((objP->info.nType == OBJ_FIREBALL) || (objP->info.nType == OBJ_EXPLOSION)) { pl->info.fBoost = 1; pl->info.fRad = fBrightness; } else if ((objP->info.nType == OBJ_WEAPON) && (objP->info.nId == FLARE_ID)) { pl->info.fBoost = 1; pl->info.fRad = 2 * fBrightness; } } m_data.owners [nObject] = m_data.nLights [0]; }else if (nSegment >= 0) {#if 0 CFixVector vOffs; CSide *sideP = SEGMENTS [nSegment].m_sides + nSide;#endif if (nSide < 0) { pl->info.nType = 2; pl->info.bVariable = 0;//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,
注:本文中的I2X函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ I810_CONTEXT函数代码示例 C++ I2C_start函数代码示例 |