本文整理汇总了C++中d_rand函数的典型用法代码示例。如果您正苦于以下问题:C++ d_rand函数的具体用法?C++ d_rand怎么用?C++ d_rand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d_rand函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FixDiv
void CShrapnel::Move (void)
{
fix xSpeed = FixDiv (m_info.xSpeed, I2X (25) / 1000);
CFixVector vOffs;
time_t nTicks;
if ((nTicks = gameStates.app.nSDLTicks - m_info.tUpdate) < 25)
return;
xSpeed = (fix) (xSpeed / gameStates.gameplay.slowmo [0].fSpeed);
for (; nTicks >= 25; nTicks -= 25) {
if (--(m_info.nTurn))
vOffs = m_info.vOffs;
else {
m_info.nTurn = ((m_info.xTTL > I2X (1) / 2) ? 2 : 4) + d_rand () % 4;
vOffs = m_info.vDir;
vOffs [X] = FixMul (vOffs [X], 2 * d_rand ());
vOffs [Y] = FixMul (vOffs [Y], 2 * d_rand ());
vOffs [Z] = FixMul (vOffs [Z], 2 * d_rand ());
CFixVector::Normalize (vOffs);
m_info.vOffs = vOffs;
}
vOffs *= xSpeed;
m_info.vPos += vOffs;
}
if (m_info.nSmoke >= 0)
particleManager.SetPos (m_info.nSmoke, &m_info.vPos, NULL, -1);
m_info.tUpdate = gameStates.app.nSDLTicks - nTicks;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:28,代码来源:shrapnel.cpp
示例2: DoAIRobotHit
// --------------------------------------------------------------------------------------------------------------------
// If a hiding robot gets bumped or hit, he decides to find another hiding place.
void DoAIRobotHit (CObject *objP, int nType)
{
int r;
if (objP->info.controlType != CT_AI)
return;
if ((nType != PA_WEAPON_ROBOT_COLLISION) && (nType != PA_PLAYER_COLLISION))
return;
if (objP->cType.aiInfo.behavior != AIB_STILL)
return;
r = d_rand ();
// Attack robots (eg, green guy) shouldn't have behavior = still.
//Assert (ROBOTINFO (objP->info.nId).attackType == 0);
// 1/8 time, charge CPlayerData, 1/4 time create path, rest of time, do nothing
if (r < 4096) {
CreatePathToPlayer (objP, 10, 1);
objP->cType.aiInfo.behavior = AIB_STATION;
objP->cType.aiInfo.nHideSegment = objP->info.nSegment;
gameData.ai.localInfo [objP->Index ()].mode = AIM_CHASE_OBJECT;
}
else if (r < 4096 + 8192) {
CreateNSegmentPath (objP, d_rand () / 8192 + 2, -1);
gameData.ai.localInfo [objP->Index ()].mode = AIM_FOLLOW_PATH;
}
}
开发者ID:paud,项目名称:d2x-xl,代码行数:27,代码来源:aifire.cpp
示例3: SeismicDisturbanceFrame
void SeismicDisturbanceFrame (void)
{
if (gameStates.gameplay.seismic.nShakeFrequency) {
if (((gameStates.gameplay.seismic.nStartTime < gameData.time.xGame) &&
(gameStates.gameplay.seismic.nEndTime > gameData.time.xGame)) || StartSeismicDisturbance()) {
fix deltaTime = gameData.time.xGame - gameStates.gameplay.seismic.nStartTime;
int fc, rx, rz;
fix h;
fc = abs(deltaTime - (gameStates.gameplay.seismic.nEndTime - gameStates.gameplay.seismic.nStartTime) / 2);
fc /= F1_0 / 16;
if (fc > 16)
fc = 16;
else if (fc == 0)
fc = 1;
gameStates.gameplay.seismic.nVolume += fc;
h = 3 * F1_0 / 16 + (F1_0 * (16 - fc)) / 32;
rx = FixMul(d_rand() - 16384, h);
rz = FixMul(d_rand() - 16384, h);
gameData.objs.console->mType.physInfo.rotVel.p.x += rx;
gameData.objs.console->mType.physInfo.rotVel.p.z += rz;
// Shake the buddy!
if (gameData.escort.nObjNum != -1) {
gameData.objs.objects[gameData.escort.nObjNum].mType.physInfo.rotVel.p.x += rx*4;
gameData.objs.objects[gameData.escort.nObjNum].mType.physInfo.rotVel.p.z += rz*4;
}
// Shake a guided missile!
gameStates.gameplay.seismic.nMagnitude += rx;
}
}
}
开发者ID:paud,项目名称:d2x-xl,代码行数:31,代码来源:seismic.cpp
示例4: DrawDebrisCorona
void DrawDebrisCorona (CObject *objP)
{
static tRgbaColorf debrisGlow = {0.66f, 0, 0, 1};
static tRgbaColorf markerGlow = {0, 0.66f, 0, 1};
static time_t t0 = 0;
if (objP->info.nType == OBJ_MARKER)
RenderWeaponCorona (objP, &markerGlow, 0.75f, 0, 4, 1, 1, 0);
#if DBG
else if (objP->info.nType == OBJ_DEBRIS) {
#else
else if ((objP->info.nType == OBJ_DEBRIS) && gameOpts->render.nDebrisLife) {
#endif
float h = (float) nDebrisLife [gameOpts->render.nDebrisLife] - X2F (objP->info.xLifeLeft);
if (h < 0)
h = 0;
if (h < 10) {
h = (10 - h) / 20.0f;
if (gameStates.app.nSDLTicks - t0 > 50) {
t0 = gameStates.app.nSDLTicks;
debrisGlow.red = 0.5f + X2F (d_rand () % (I2X (1) / 4));
debrisGlow.green = X2F (d_rand () % (I2X (1) / 4));
}
RenderWeaponCorona (objP, &debrisGlow, h, 5 * objP->info.xSize, 1.5f, 1, LIGHTTRAIL_BLENDMODE, 0);
}
}
}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:27,代码来源:lighttrails.cpp
示例5: start_seismic_disturbance
// Return true if time to start a seismic disturbance.
static int start_seismic_disturbance(void)
{
int rval;
if (Level_shake_duration < 1)
return 0;
rval = (2 * fixmul(d_rand(), Level_shake_frequency)) < FrameTime;
if (rval) {
Seismic_disturbance_start_time = GameTime64;
Seismic_disturbance_end_time = GameTime64 + Level_shake_duration;
if (!Seismic_sound_playing) {
digi_play_sample_looping(Seismic_sound, F1_0, -1, -1);
Seismic_sound_playing = 1;
Next_seismic_sound_time = GameTime64 + d_rand()/2;
}
#ifdef NETWORK
if (Game_mode & GM_MULTI)
multi_send_seismic (Seismic_disturbance_start_time,Seismic_disturbance_end_time);
#endif
}
return rval;
}
开发者ID:Foran,项目名称:dxx-rebirth,代码行数:27,代码来源:weapon.cpp
示例6: CreateSmallFireballOnObject
void CreateSmallFireballOnObject (CObject *objP, fix size_scale, int bSound)
{
fix size;
CFixVector vPos, vRand;
short nSegment;
vPos = objP->info.position.vPos;
vRand = CFixVector::Random();
vRand *= (objP->info.xSize / 2);
vPos += vRand;
size = FixMul (size_scale, I2X (1) / 2 + d_rand () * 4 / 2);
nSegment = FindSegByPos (vPos, objP->info.nSegment, 1, 0);
if (nSegment != -1) {
CObject *explObjP = /*Object*/CreateExplosion (nSegment, vPos, size, VCLIP_SMALL_EXPLOSION);
if (!explObjP)
return;
AttachObject (objP, explObjP);
if (bSound || (d_rand () < 8192)) {
fix vol = I2X (1) / 2;
if (objP->info.nType == OBJ_ROBOT)
vol *= 2;
audio.CreateObjectSound (SOUND_EXPLODING_WALL, SOUNDCLASS_EXPLOSION, objP->Index (), 0, vol);
}
}
}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:25,代码来源:createobject.cpp
示例7: RandomPoint
// --------------------------------------------------------------------------------
// Picks a Random point in a CSegment like so:
// From center, go up to 50% of way towards any of the 8 vertices.
CFixVector CSegment::RandomPoint (void)
{
int nVertex = (d_rand () * MAX_VERTICES_PER_SEGMENT) >> 15;
CFixVector v = gameData.segs.vertices [m_verts [nVertex]] - m_vCenter;
v *= (d_rand ());
return v;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:10,代码来源:segment.cpp
示例8: SpitPowerup
//this function is for when the CPlayerData intentionally drops a powerup
//this function is based on DropPowerup()
int SpitPowerup (CObject *spitterP, ubyte id, int seed)
{
short nObject;
CObject *objP;
CFixVector newVelocity, newPos;
tObjTransformation *posP = OBJPOS (spitterP);
#if 0
if ((gameData.app.nGameMode & GM_NETWORK) &&
(gameData.multiplayer.powerupsInMine [(int)id] + PowerupsOnShips (id) >=
gameData.multiplayer.maxPowerupsAllowed [id]))
return -1;
#endif
newVelocity = spitterP->mType.physInfo.velocity + spitterP->info.position.mOrient.FVec() * I2X (SPIT_SPEED);
newVelocity[X] += (d_rand() - 16384) * SPIT_SPEED * 2;
newVelocity[Y] += (d_rand() - 16384) * SPIT_SPEED * 2;
newVelocity[Z] += (d_rand() - 16384) * SPIT_SPEED * 2;
// Give keys zero velocity so they can be tracked better in multi
if (IsMultiGame && (id >= POW_KEY_BLUE) && (id <= POW_KEY_GOLD))
newVelocity.SetZero ();
//there's a piece of code which lets the CPlayerData pick up a powerup if
//the distance between him and the powerup is less than 2 time their
//combined radii. So we need to create powerups pretty far out from
//the player.
newPos = posP->vPos + posP->mOrient.FVec () * spitterP->info.xSize;
if (IsMultiGame && (gameData.multigame.create.nLoc >= MAX_NET_CREATE_OBJECTS))
return (-1);
nObject = CreatePowerup (id, (short) (GetTeam (gameData.multiplayer.nLocalPlayer) + 1), (short) OBJSEG (spitterP), newPos, 1);
if (nObject < 0) {
Int3();
return nObject;
}
objP = OBJECTS + nObject;
objP->mType.physInfo.velocity = newVelocity;
objP->mType.physInfo.drag = 512; //1024;
objP->mType.physInfo.mass = I2X (1);
objP->mType.physInfo.flags = PF_BOUNCE;
objP->rType.vClipInfo.nClipIndex = gameData.objs.pwrUp.info [objP->info.nId].nClipIndex;
objP->rType.vClipInfo.xFrameTime = gameData.eff.vClipP [objP->rType.vClipInfo.nClipIndex].xFrameTime;
objP->rType.vClipInfo.nCurFrame = 0;
if (spitterP == gameData.objs.consoleP)
objP->cType.powerupInfo.nFlags |= PF_SPAT_BY_PLAYER;
switch (objP->info.nId) {
case POW_CONCUSSION_1:
case POW_CONCUSSION_4:
case POW_SHIELD_BOOST:
case POW_ENERGY:
objP->info.xLifeLeft = (d_rand() + I2X (3)) * 64; // Lives for 3 to 3.5 binary minutes (a binary minute is 64 seconds)
if (gameData.app.nGameMode & GM_MULTI)
objP->info.xLifeLeft /= 2;
break;
default:
//if (gameData.app.nGameMode & GM_MULTI)
// objP->info.xLifeLeft = (d_rand() + I2X (3)) * 64; // Lives for 5 to 5.5 binary minutes (a binary minute is 64 seconds)
break;
}
MultiSendWeapons (1);
return nObject;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:61,代码来源:dropweapon.cpp
示例9: rock_the_mine_frame
// If a smega missile been detonated, rock the mine!
// This should be called every frame.
// Maybe this should affect all robots, being called when they get their physics done.
void rock_the_mine_frame(void)
{
int i;
for (i=0; i<MAX_SMEGA_DETONATES; i++) {
if (Smega_detonate_times[i] != 0) {
fix delta_time = GameTime64 - Smega_detonate_times[i];
if (!Seismic_sound_playing) {
digi_play_sample_looping(Seismic_sound, F1_0, -1, -1);
Seismic_sound_playing = 1;
Next_seismic_sound_time = GameTime64 + d_rand()/2;
}
if (delta_time < SMEGA_SHAKE_TIME) {
// Control center destroyed, rock the player's ship.
int fc, rx, rz;
// -- fc = abs(delta_time - SMEGA_SHAKE_TIME/2);
// Changed 10/23/95 to make decreasing for super mega missile.
fc = (SMEGA_SHAKE_TIME - delta_time)/2;
fc /= SMEGA_SHAKE_TIME/32;
if (fc > 16)
fc = 16;
if (fc == 0)
fc = 1;
Seismic_tremor_volume += fc;
rx = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
rz = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
if (FixedStep & EPS20)
{
ConsoleObject->mtype.phys_info.rotvel.x += rx;
ConsoleObject->mtype.phys_info.rotvel.z += rz;
// Shake the buddy!
if (Buddy_objnum != object_none) {
Objects[Buddy_objnum].mtype.phys_info.rotvel.x += rx*4;
Objects[Buddy_objnum].mtype.phys_info.rotvel.z += rz*4;
}
}
// Shake a guided missile!
Seismic_tremor_magnitude += rx;
} else
Smega_detonate_times[i] = 0;
}
}
// Hook in the rumble sound effect here.
}
开发者ID:Foran,项目名称:dxx-rebirth,代码行数:60,代码来源:weapon.cpp
示例10: setup_func
/* Setup a random function in the given dimensions */
static void setup_func(funcp *p, int di) {
double mn,mx;
double ax[MXDI][2];
int i, j;
p->di = di;
/* Setup random input curve parameters */
/* (This is the one that effects smoothness of function the most) */
for (j = 0; j < di; j++) {
for (mx = 4.0, i = 0; i < MXCHPARAMS; i++, mx *= 0.6) {
p->ip[j][i] = d_rand(-mx, mx);
}
}
/* Setup random shape parameters */
for (j = 0; j < di; j++) {
for (i = 0; i < (1 << di); i++) { /* Initially random */
p->shape[j][i] = d_rand(-0.1, 0.1);
}
}
/* Setup the random output value parameters */
/* First some axis dominant values */
for (i = 0; i < di; i++) {
ax[i][0] = d_rand(0.0, 1.0);
ax[i][1] = ax[i][0] + d_rand(-1.0, 1.0);
}
/* Sum them orthogonally and add indepent terms */
mn = 5.0;
mx = -5.0;
for (i = 0; i < (1 << di); i++) { /* Initially random */
p->op[i] = 0.0;
for (j = 0; j < di; j++) {
if ((1 << j) & i)
p->op[i] += ax[j][1];
else
p->op[i] += ax[j][0];
}
p->op[i] += d_rand(-0.3, 0.3);
if (p->op[i] < mn)
mn = p->op[i];
if (p->op[i] > mx)
mx = p->op[i];
}
for (i = 0; i < (1 << di); i++) { /* Then scale to between 0.0 and 1.0 */
p->op[i] = (p->op[i] - mn)/(mx - mn);
}
}
开发者ID:beku,项目名称:Argyll-Releases,代码行数:54,代码来源:smtnd.c
示例11: I2X
void CObject::RandomBump (fix xScale, fix xForce, bool bSound)
{
fix angle;
angle = (d_rand () - I2X (1) / 4);
mType.physInfo.rotVel [X] += FixMul (angle, xScale);
angle = (d_rand () - I2X (1) / 4);
mType.physInfo.rotVel [Z] += FixMul (angle, xScale);
CFixVector vRand = CFixVector::Random ();
Bump (vRand, xForce);
if (bSound)
audio.CreateObjectSound (SOUND_PLAYER_HIT_WALL, SOUNDCLASS_GENERIC, Index ());
}
开发者ID:paud,项目名称:d2x-xl,代码行数:13,代码来源:object.cpp
示例12: DoSnipeFire
void DoSnipeFire (CObject *objP, tAILocalInfo *ailP)
{
if (ailP->nextActionTime < 0) {
tAIStaticInfo *aiP = &objP->cType.aiInfo;
CreateNSegmentPath (objP, 10 + d_rand () / 2048, OBJSEG (TARGETOBJ));
aiP->nPathLength = (aiP->nHideIndex < 0) ? 0 : SmoothPath (objP, &gameData.ai.routeSegs [aiP->nHideIndex], aiP->nPathLength);
if (d_rand () < 8192)
ailP->mode = AIM_SNIPE_RETREAT_BACKWARDS;
else
ailP->mode = AIM_SNIPE_RETREAT;
ailP->nextActionTime = SNIPE_RETREAT_TIME;
}
}
开发者ID:paud,项目名称:d2x-xl,代码行数:13,代码来源:aisnipe.cpp
示例13: do_seismic_stuff
// ---------------------------------------------------------------------------------------
// Do seismic disturbance stuff including the looping sounds with changing volume.
void do_seismic_stuff(void)
{
int stv_save;
stv_save = Seismic_tremor_volume;
Seismic_tremor_magnitude = 0;
Seismic_tremor_volume = 0;
rock_the_mine_frame();
seismic_disturbance_frame();
if (stv_save != 0) {
if (Seismic_tremor_volume == 0) {
digi_stop_looping_sound();
Seismic_sound_playing = 0;
}
if ((GameTime64 > Next_seismic_sound_time) && Seismic_tremor_volume) {
int volume;
volume = Seismic_tremor_volume * 2048;
if (volume > F1_0)
volume = F1_0;
digi_change_looping_volume(volume);
Next_seismic_sound_time = GameTime64 + d_rand()/4 + 8192;
}
}
}
开发者ID:Foran,项目名称:dxx-rebirth,代码行数:31,代码来源:weapon.cpp
示例14: d_rand
int CShrapnelCloud::Create (CObject* parentObjP, CObject* objP)
{
int i, h = (int) (X2F (parentObjP->info.xSize) * fShrapnelScale [gameOpts->render.effects.nShrapnels] + 0.5);
objP->info.xLifeLeft = 0;
objP->cType.explInfo.nSpawnTime = -1;
objP->cType.explInfo.nDeleteObj = -1;
objP->cType.explInfo.nDeleteTime = -1;
h += d_rand () % h;
if (!CStack<CShrapnel>::Create (h))
return 0;
if (!Grow (h))
return 0;
#pragma omp parallel
{
#pragma omp for
for (i = 0; i < h; i++) {
m_data.buffer [i].Create (parentObjP, objP);
}
}
objP->info.xLifeLeft *= 2;
objP->cType.explInfo.nSpawnTime = -1;
objP->cType.explInfo.nDeleteObj = -1;
objP->cType.explInfo.nDeleteTime = -1;
return 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:26,代码来源:shrapnel.cpp
示例15: I2X
void CShrapnel::Draw (void)
{
if ((m_info.xTTL > 0) && LoadExplBlast ()) {
fix xSize = I2X (1) / 2 + d_rand () % (I2X (1) / 4);
G3DrawSprite (m_info.vPos, xSize, xSize, bmpExplBlast, NULL, X2F (m_info.xTTL) / X2F (m_info.xLife) / 2, 0, 0);
}
}
开发者ID:paud,项目名称:d2x-xl,代码行数:7,代码来源:shrapnel.cpp
示例16: DoSeismicStuff
void DoSeismicStuff (void)
{
int stv_save;
if (gameStates.limitFPS.bSeismic && !gameStates.app.tick40fps.bTick)
return;
stv_save = gameStates.gameplay.seismic.nVolume;
gameStates.gameplay.seismic.nMagnitude = 0;
gameStates.gameplay.seismic.nVolume = 0;
RockTheMineFrame();
SeismicDisturbanceFrame();
if (stv_save != 0) {
if (gameStates.gameplay.seismic.nVolume == 0) {
DigiStopLoopingSound();
gameStates.gameplay.seismic.bSound = 0;
}
if ((gameData.time.xGame > gameStates.gameplay.seismic.nNextSoundTime) && gameStates.gameplay.seismic.nVolume) {
int volume = gameStates.gameplay.seismic.nVolume * 2048;
if (volume > F1_0)
volume = F1_0;
DigiChangeLoopingVolume (volume);
gameStates.gameplay.seismic.nNextSoundTime = gameData.time.xGame + d_rand () / 4 + 8192;
}
}
}
开发者ID:paud,项目名称:d2x-xl,代码行数:26,代码来源:seismic.cpp
示例17: 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,代码来源:fusion.cpp
示例18: FadeEffect
void CPaletteManager::FadeEffect (void)
{
float nDecAmount = 0;
bool bForce = false;
// Diminish at FADE_RATE units/second.
// For frame rates > FADE_RATE Hz, use randomness to achieve this.
if (gameData.time.xFrame < I2X (1) / FADE_RATE) {
if (d_rand () < gameData.time.xFrame * FADE_RATE / 2)
nDecAmount = 1;
}
else {
if (!(nDecAmount = X2F (gameData.time.xFrame * FADE_RATE))) // one second = FADE_RATE counts
nDecAmount = 1; // make sure we decrement by something
}
nDecAmount /= 64.0f;
if (m_data.xFlashDuration) {
// Part of hack system to force update of palette after exiting a menu.
if (m_data.xLastEffectTime)
bForce = true;
if ((m_data.xLastEffectTime + I2X (1)/8 < gameData.time.xGame) || (m_data.xLastEffectTime > gameData.time.xGame)) {
audio.PlaySound (SOUND_CLOAK_OFF, SOUNDCLASS_GENERIC, m_data.xFlashDuration / 4);
m_data.xLastEffectTime = gameData.time.xGame;
}
m_data.xFlashDuration -= gameData.time.xFrame;
if (m_data.xFlashDuration < 0)
m_data.xFlashDuration = 0;
if (bForce || (d_rand () > 4096)) {
if ((gameData.demo.nState == ND_STATE_RECORDING) && (m_data.effect.red || m_data.effect.green || m_data.effect.blue))
NDRecordPaletteEffect (short (m_data.effect.red * 64), short (m_data.effect.green * 64), short (m_data.effect.blue * 64));
paletteManager.SetEffect ();
return;
}
}
m_data.effect.red = UpdateEffect (m_data.effect.red, nDecAmount);
m_data.effect.green = UpdateEffect (m_data.effect.green, nDecAmount);
m_data.effect.blue = UpdateEffect (m_data.effect.blue, nDecAmount);
if ((gameData.demo.nState == ND_STATE_RECORDING) && (m_data.effect.red || m_data.effect.green || m_data.effect.blue))
NDRecordPaletteEffect (short (m_data.effect.red * 64), short (m_data.effect.green * 64), short (m_data.effect.blue * 64));
SetEffect (bForce);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:47,代码来源:palette.cpp
示例19: ipx_mcast4_InitNetgameAuxData
/* Create the netgame aux data.
* Byte 0 is the protcol version number.
* Bytes 1-4 hold the IPv4 multicast session for the game.
*/
static void ipx_mcast4_InitNetgameAuxData(ipx_socket_t *sk, u_char buf[NETGAME_AUX_SIZE])
{
char addr[16];
Assert(game_addr.s_addr == 0);
// The first byte is the version number
buf[0] = IPX_MCAST4_VERSION;
// Generate a random session
// game_addr = inet_makeaddr(239*256 + 255, d_rand() % 0xFFFF);
sprintf(addr, "%i.%i.%i.%i", 239, 255, d_rand() % 0xFF, d_rand() % 0xFF);
game_addr.s_addr = inet_addr(addr);
memcpy(buf + 1, &game_addr, sizeof(game_addr));
// Since we're obviously the hosting machine, subscribe to this address
ipx_mcast4_HandleNetgameAuxData(sk, buf);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:21,代码来源:ipx_mcast4.c
示例20: UpdateAllObjects
// -----------------------------------------------------------------------------
//move all OBJECTS for the current frame
int UpdateAllObjects (void)
{
int i;
CObject *objP, *nextObjP;
gameData.objs.nFrameCount++;
#if DBG
static int bOnce = 0;
if (bOnce >= 0) {
if (bOnce > 0)
bOnce = -1;
if (!OBJECTS [gameData.multiplayer.nLocalPlayer].CriticalDamage () &&
(gameStates.app.nSDLTicks - OBJECTS [gameData.multiplayer.nLocalPlayer].TimeLastRepaired () > 5000))
OBJECTS [gameData.multiplayer.nLocalPlayer].SetDamage (1 + d_rand () % 10, 1 + d_rand () % 10, 1 + d_rand () % 10);
}
#endif
if (gameData.objs.nLastObject [0] > gameData.objs.nMaxUsedObjects)
FreeObjectSlots (gameData.objs.nMaxUsedObjects); // Free all possible CObject slots.
#if LIMIT_PHYSICS_FPS
if (!gameStates.app.tick60fps.bTick)
return 1;
gameData.physics.xTime = SECS2X (gameStates.app.tick60fps.nTime);
#else
gameData.physics.xTime = gameData.time.xFrame;
#endif
CleanupObjects ();
if (gameOpts->gameplay.nAutoLeveling)
gameData.objs.consoleP->mType.physInfo.flags |= PF_LEVELLING;
else
gameData.objs.consoleP->mType.physInfo.flags &= ~PF_LEVELLING;
// Move all OBJECTS
gameStates.entropy.bConquering = 0;
UpdatePlayerOrient ();
//WaitForEffectsThread ();
i = 0;
for (objP = gameData.objs.lists.all.head; objP; objP = nextObjP) {
nextObjP = objP->Links (0).next;
if ((objP->info.nType != OBJ_NONE) && (objP->info.nType != OBJ_GHOST) && !(objP->info.nFlags & OF_SHOULD_BE_DEAD) && !objP->Update ())
return 0;
i++;
}
return 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:47,代码来源:updateobject.cpp
注:本文中的d_rand函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论