int CParticleEmitter::Render (int nThread) { if (!m_particles) return 0; #if MT_PARTICLES if (((gameOpts->render.bDepthSort > 0) && (nThread < 0)) && RunEmitterThread (emitterP, 0, rtRenderParticles)) { return 0; } else #endif { float brightness = Brightness (); int nParts = m_nParts, h, i, j, nFirstPart = m_nFirstPart, nPartLimit = m_nPartLimit; int bVisible = MayBeVisible (); #if DBG if (nFirstPart >= int (m_particles.Length ())) return 0; if (m_nPartLimit > int (m_particles.Length ())) m_nPartLimit = int (m_particles.Length ()); #endif for (h = 0, i = nParts, j = nFirstPart; i; i--, j = (j + 1) % nPartLimit) if ((bVisible || m_particles [j].IsVisible ()) && transparencyRenderer.AddParticle (m_particles + j, brightness, nThread)) h++; return h; } return 0; }
//----------------------------------------------------------------------------- bool tIMX51Video::SetBrightnessInternal() { if(m_pGstSource) { GParamSpec *param = g_object_class_find_property(G_OBJECT_GET_CLASS(m_pGstSource), "brightness"); if(!param) return false; GParamSpecInt *pint = G_PARAM_SPEC_INT (param); if(!pint) return false; int val = (pint->maximum - pint->minimum) * Brightness() / 100 + pint->minimum; //qDebug() << "Setting brightness" << val; g_object_set(m_pGstSource, "brightness", val, NULL); } return false; }
/*---GET COMMANDS FOR SPELLS---*/ void Player::Gem_Abilities(const Vector<MyString>& commands) { if (enemy != nullptr) { bool red = false; bool blue = false; bool yellow = false; bool black = false; bool white = false; CheckGems(red, blue, yellow, black, white); //Check the command introduced for casting the correct spell if (commands[0] == "1") { Fire(commands, red, blue, black); } else if (commands[0] == "2") { Water(commands, blue, red, yellow); } else if (commands[0] == "3") { Electricity(commands, yellow, blue, white); } else if (commands[0] == "4") { Darkness(commands, black, red, white); } else if (commands[0] == "5") { Brightness(commands, white, black, yellow); } } else { printf("You can't cast a spell without an objective, Simon.\n"); } }
int CParticleEmitter::Update (int nCurTime, int nThread) { if (!m_particles) return 0; #if MT_PARTICLES if ((nThread < 0) && RunEmitterThread (emitterP, nCurTime, rtUpdateParticles)) { return 0; } else #endif { int t, h, i, j; float fDist; float fBrightness = Brightness (); CFixMatrix mOrient = m_mOrient; CFixVector vDelta, vPos, *vDir = (m_bHaveDir ? &m_vDir : NULL), * vEmittingFace = m_bEmittingFace ? m_vEmittingFace : NULL; CFloatVector vDeltaf, vPosf; #if SMOKE_SLOWMO t = (int) ((nCurTime - m_nMoved) / gameStates.gameplay.slowmo [0].fSpeed); #else t = nCurTime - m_nMoved; #endif nPartSeg = -1; for (i = m_nParts, j = m_nFirstPart; i; i--, j = (j + 1) % m_nPartLimit) if (!m_particles [j].Update (nCurTime)) { if (j != m_nFirstPart) m_particles [j] = m_particles [m_nFirstPart]; m_nFirstPart = (m_nFirstPart + 1) % m_nPartLimit; m_nParts--; } m_nTicks += t; if ((m_nPartsPerPos = (int) (m_fPartsPerTick * m_nTicks)) >= 1) { if (m_nType == BUBBLE_PARTICLES) { if (rand () % 4) // create some irregularity in bubble appearance goto funcExit; } m_nTicks = 0; if (IsAlive (nCurTime)) { vDelta = m_vPos - m_vPrevPos; fDist = X2F (vDelta.Mag()); h = m_nPartsPerPos; if (h > m_nMaxParts - i) h = m_nMaxParts - i; if (h <= 0) goto funcExit; if (m_bHavePrevPos && (fDist > 0)) { vPosf.Assign (m_vPrevPos); vDeltaf.Assign (vDelta); vDeltaf [X] /= (float) h; vDeltaf [Y] /= (float) h; vDeltaf [Z] /= (float) h; } else { #if 1 vPosf.Assign (m_vPrevPos); vDeltaf.Assign (vDelta); vDeltaf [X] /= (float) h; vDeltaf [Y] /= (float) h; vDeltaf [Z] /= (float) h; #else vPosf.Assign (m_vPos); vDeltaf [X] = vDeltaf [Y] = vDeltaf [Z] = 0.0f; h = 1; #endif } for (; h; h--, j = (j + 1) % m_nPartLimit) { vPosf += vDeltaf; vPos.Assign (vPosf); /* vPos[Y] = (fix) (vPosf [Y] * 65536.0f); vPos[Z] = (fix) (vPosf [Z] * 65536.0f); */ if (m_particles [j].Create (&vPos, vDir, &mOrient, m_nSegment, m_nLife, m_nSpeed, m_nType, m_nClass, m_fScale, m_bHaveColor ? &m_color : NULL, nCurTime, m_bBlowUpParts, fBrightness, vEmittingFace)) m_nParts++; if (/*(m_nType == LIGHT_PARTICLES) ||*/ (m_nType == BULLET_PARTICLES)) goto funcExit; } } } funcExit: m_bHavePrevPos = 1; m_nMoved = nCurTime; m_vPrevPos = m_vPos; m_nTicks = m_nTicks; m_nFirstPart = m_nFirstPart; return m_nParts = m_nParts; } }
void LCD1602::Init() { PinInit(); Brightness(false); RW(false); RS(false); DB4(0); E(false); // Wait 50 ms from power on delay_ms(50); DB4(3); // Run three clock cycles to init E(true); LCD_DELAY_SHORT; E(false); LCD_DELAY_LONG; E(true); LCD_DELAY_SHORT; E(false); LCD_DELAY_SHORT; E(true); LCD_DELAY_SHORT; E(false); LCD_DELAY_SHORT; // Configure display DB4(2); E(true); LCD_DELAY_SHORT; E(false); LCD_DELAY_LONG; DB(0x28); LCD_DELAY_SHORT; DB(0x8); LCD_DELAY_SHORT; DB(0x1); LCD_DELAY_SHORT; DB(0x6); LCD_DELAY_SHORT; RS(false); DB(0x0c); LCD_DELAY_LONG; // Test code, TODO Locate(0, 0); Print(" ld analyzer b1 "); Locate(0, 1); Print(" analyzer-1 "); //Brightness(true); Contrast(false); // Enable SCT peripheral clock CGU_ConfigPWR(CGU_PERIPHERAL_SCT, ENABLE); LPC_CCU1->CLK_M4_SCT_CFG |= CCU1_CLK_M4_SCT_CFG_RUN_Msk; while(!(LPC_CCU1->CLK_M4_SCT_STAT & CCU1_CLK_M4_SCT_STAT_RUN_Msk)); scu_pinmux(0x1, 5, GPIO_PUP, FUNC1); // CTOUT_10 LPC_SCT->CONFIG = (1 << 17); LPC_SCT->CTRL_L |= (12-1) << 5; LPC_SCT->MATCHREL[0].L = 100-1; LPC_SCT->MATCHREL[1].L = 1; LPC_SCT->EVENT[0].STATE = 0xFFFFFFFF; LPC_SCT->EVENT[0].CTRL = (1 << 12); LPC_SCT->EVENT[1].STATE = 0xFFFFFFFF; LPC_SCT->EVENT[1].CTRL = (1 << 12) | (1 << 0); LPC_SCT->OUT[10].SET = (1 << 0); LPC_SCT->OUT[10].CLR = (1 << 1); LPC_SCT->CTRL_L &= ~(1 << 2); InitFont(); // Fade in for (int i = 0; i < 100; i++) { LPC_SCT->MATCHREL[1].L = i; delay_ms(10); } }
BYTE Brightness(const IImage* const src) { ATLASSERT(src != NULL); const IRgbImage* const pRgbImage = dynamic_cast<const IRgbImage* const>(src); if(NULL != pRgbImage) return Brightness(pRgbImage); const IGrayImage* const pGrayImage = dynamic_cast<const IGrayImage* const>(src); if(NULL != pGrayImage) return Brightness(pGrayImage); throw image_process_exception("not supported image interface"); }