void ScrollingSystem::initScrolling(Entity e, ScrollingComponent* sc) { ScrollingElement se; TransformationComponent* ptc = TRANSFORM(e); for (int i=0; i<2; i++) { se.e[i] = theEntityManager.CreateEntity(HASH("scroll/e", 0x4ab48dfd)); ADD_COMPONENT(se.e[i], Transformation); ADD_COMPONENT(se.e[i], Rendering); ADD_COMPONENT(se.e[i], Anchor); TRANSFORM(se.e[i])->size = sc->displaySize; auto* tc = ANCHOR(se.e[i]); tc->parent = e; tc->position = -glm::vec2(sc->direction.x * ptc->size.x, sc->direction.y * ptc->size.y) * (float)i; tc->z = i * 0.001f; RenderingComponent* rc = RENDERING(se.e[i]); se.imageIndex[i] = i % sc->images.size(); rc->texture = sc->images[se.imageIndex[i]]; // rc->color = debugColors[se.imageIndex[i]]; se.hasBeenVisible[i] = false; rc->flags = sc->renderingFlags; } elements[e] = se; }
void setup(AssetAPI*) override { //Creating text entities textToReadContainer = theEntityManager.CreateEntityFromTemplate("rateit/container"); textToRead = theEntityManager.CreateEntityFromTemplate("rateit/text"); TEXT(textToRead)->text = game->gameThreadContext->localizeAPI->text("please_rate_it"); // ?? // TRANSFORM(textToRead)->position.x = TRANSFORM(textToReadContainer)->position.x = 0; std::stringstream a; for (int i = 0; i < 3; i++) { a.str(""); a << "boutonText_" << i; boutonText[i] = theEntityManager.CreateEntityFromTemplate("rateit/button_text"); a.str(""); a << "boutonContainer_" << i; boutonContainer[i] = theEntityManager.CreateEntityFromTemplate("rateit/button"); TRANSFORM(boutonText[i])->position.y = TRANSFORM(boutonContainer[i])->position.y = (float)PlacementHelper::GimpYToScreen(650 + i*183); } TEXT(boutonText[0])->text = game->gameThreadContext->localizeAPI->text("rate_now"); TEXT(boutonText[1])->text = game->gameThreadContext->localizeAPI->text("rate_later"); TEXT(boutonText[2])->text = game->gameThreadContext->localizeAPI->text("rate_never"); }
int add_keyframe(lua_State* state) { int args = lua_gettop(state); if(args != 4 && args != 5 && args != 8) { luaL_error(state, "Invalid number of arguments for adding keyframes"); } if(!lua_isstring(state, 1)) { return luaL_argerror(state, 1, "animation name expected"); } if(!lua_isnumber(state, 2)) { return luaL_argerror(state, 2, "time value expected"); } if(!lua_isnumber(state, 3)) { return luaL_argerror(state, 3, "transition state expected"); } if(!lua_isnumber(state, 4)) { return luaL_argerror(state, 4, "attribute expected"); } if(args == 5 && !lua_isnumber(state, 5)) { return luaL_argerror(state, 5, "tween type expected"); } if(args == 8) { for(int i = 5; i != 8; i++) { if(!lua_isnumber(state, i)) { return luaL_argerror(state, i, "control point coordinate expected"); } } } lua_getglobal(state, "renderer"); OpticRender* render = static_cast<OpticRender*>(lua_touserdata(state, -1)); lua_pop(state, 1); try { if(args == 4) { render->addKeyframe(lua_tostring(state, 1), Keyframe(lua_tointeger(state, 2), lua_tonumber(state, 3)), TRANSFORM(lua_tointeger(state, 4)), LINEAR); } else if(args == 5) { render->addKeyframe(lua_tostring(state, 1), Keyframe(lua_tointeger(state, 2), lua_tonumber(state, 3)), TRANSFORM(lua_tointeger(state, 4)), TWEEN(lua_tointeger(state, 5))); } else { OpticBezier bezier(lua_tonumber(state, 5), lua_tonumber(state, 6), lua_tonumber(state, 7), lua_tonumber(state, 8)); render->addKeyframe(lua_tostring(state, 1), Keyframe(lua_tointeger(state, 2), lua_tonumber(state, 3)), TRANSFORM(lua_tointeger(state, 4)), bezier); } } catch(OpticException& e) { luaL_error(state, e.what()); } return 0; }
static void fft16(FFTComplex *z) { FFTSample t1, t2, t3, t4, t5, t6; fft8(z); fft4(z+8); fft4(z+12); TRANSFORM_ZERO(z[0],z[4],z[8],z[12]); TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf); TRANSFORM(z[1],z[5],z[9],z[13],ff_cos_16[1],ff_cos_16[3]); TRANSFORM(z[3],z[7],z[11],z[15],ff_cos_16[3],ff_cos_16[1]); }
void fft16(FFTComplex *z) { fft8(z); fft4(z+8); fft4(z+12); TRANSFORM_ZERO(z,4); z+=2; TRANSFORM_EQUAL(z,4); z-=1; TRANSFORM(z,4,cPI1_8,cPI3_8); z+=2; TRANSFORM(z,4,cPI3_8,cPI1_8); }
static void fft16(Complex *z) { float t1, t2, t3, t4, t5, t6; fft8(z); fft4(z + 8); fft4(z + 12); const float * const cosTable = getCosineTable(4); TRANSFORM_ZERO(z[0], z[4], z[8], z[12]); TRANSFORM(z[2], z[6], z[10], z[14], sqrthalf, sqrthalf); TRANSFORM(z[1], z[5], z[9], z[13], cosTable[1],cosTable[3]); TRANSFORM(z[3], z[7], z[11], z[15], cosTable[3], cosTable[1]); }
void FFT::fft16(Complex *z) { float t1, t2, t3, t4, t5, t6; fft8(z); fft4(z + 8); fft4(z + 12); assert(_cosTables[0]); const float * const cosTable = _cosTables[0]->getTable(); TRANSFORM_ZERO(z[0], z[4], z[8], z[12]); TRANSFORM(z[2], z[6], z[10], z[14], sqrthalf, sqrthalf); TRANSFORM(z[1], z[5], z[9], z[13], cosTable[1],cosTable[3]); TRANSFORM(z[3], z[7], z[11], z[15], cosTable[3], cosTable[1]); }
void NormalGameModeManager::WillScore(int count, int type, std::vector<BranchLeaf>& out) { int nb = levelToLeaveToDelete(type, count, level+2, level+2 - remain[type], countBranchLeavesOfType(type)); for (unsigned int i=0; nb>0 && i<branchLeaves.size(); i++) { if (type == (int)branchLeaves[i].type) { CombinationMark::markCellInCombination(branchLeaves[i].e); out.push_back(branchLeaves[i]); nb--; } } // move background during delete/spawn sequence (+ fall ?) float deleteDuration = 0.3f; float spawnDuration = 0.2f; // herisson distance float currentPos = TRANSFORM(herisson)->position.x; float newPos = GameModeManager::position((time - timeGain(count, level, time)) / limit); // update herisson and decor at the same time. levelMoveDuration = deleteDuration + spawnDuration; if (theHeriswapGridSystem.sizeToDifficulty() != DifficultyHard) levelMoveDuration *= 2; nextHerissonSpeed = (newPos - currentPos) / levelMoveDuration; SCROLLING(decor1er)->speed = glm::max(0.0f, -nextHerissonSpeed); // SCROLLING(decor2nd)->speed.X = nextHerissonSpeed * DECOR2_SPEED; // SCROLLING(sky)->speed.X = nextHerissonSpeed * SKY_SPEED; }
void GameModeManager::updateHerisson(float dt, float obj, float herissonSpeed) { // default herisson behavior: move to TransformationComponent* tc = TRANSFORM(herisson); float newPos = tc->position.x; if (herissonSpeed == 0) { float targetPosX = position(obj); float distance = targetPosX - tc->position.x; if (distance != 0.f) { herissonSpeed = (distance > 0) ? 1.0f : -1.0f; if (distance < 0) { newPos = glm::max(targetPosX, tc->position.x + herissonSpeed*dt); } else { newPos = glm::min(targetPosX, tc->position.x + herissonSpeed*dt); } } } else { newPos = tc->position.x + herissonSpeed * dt; } //set animation speed float newSpeed = 2.5f; if (dt != 0) newSpeed = 15*(newPos - tc->position.x)/dt; if (newSpeed < 1.4f) newSpeed = 2.5f; if (newSpeed > 4.5f) newSpeed = 4.5f; ANIMATION(herisson)->playbackSpeed = newSpeed; tc->position.x = newPos; if (herissonSpeed <= 0) { ANIMATION(herisson)->playbackSpeed = 0; } }
bool updateLeavesSpawn() { bool fullGridSpawn = (newLeaves.size() == (unsigned)theHeriswapGridSystem.GridSize*theHeriswapGridSystem.GridSize); ADSR(haveToAddLeavesInGrid)->active = true; for ( std::vector<Feuille>::reverse_iterator it = newLeaves.rbegin(); it != newLeaves.rend(); ++it ) { if (it->entity == 0) { it->entity = createCell(*it, fullGridSpawn); } else { HeriswapGridComponent* gc = HERISWAPGRID(it->entity); if (fullGridSpawn) { gc->i = gc->j = -1; } TransformationComponent* tc = TRANSFORM(it->entity); //leaves grow up from 0 to fixed size glm::vec2 s = HeriswapGame::CellSize(theHeriswapGridSystem.GridSize, gc->type); if (ADSR(haveToAddLeavesInGrid)->value == 1){ tc->size = glm::vec2(s.x, s.y); gc->i = it->X; gc->j = it->Y; } else { tc->size = s * ADSR(haveToAddLeavesInGrid)->value; } } } return (ADSR(haveToAddLeavesInGrid)->value == 1); }
static void compute_grids(void) { #ifdef GRID_OPT /* element : . X O x o h a ! */ static const uint32 and_mask[] = { 3, 3, 3, 1, 2, 1, 3, 1 }; static const uint32 val_mask[] = { 0, 2, 1, 0, 0, 0, 0, 0 }; int ll; /* iterate over rotations */ int k; /* iterate over elements */ for (ll=0; ll < 8; ++ll) { for (k=0; k<el; ++k) { int di, dj; TRANSFORM(elements[k].x - ci, elements[k].y - cj, &di, &dj, ll); ++di; ++dj; if (di >= 0 && di < 4 && dj >= 0 && dj < 4) { pattern[patno].and_mask[ll] |= and_mask[elements[k].att] << (30 - di * 8 - dj * 2); pattern[patno].val_mask[ll] |= val_mask[elements[k].att] << (30 - di * 8 - dj * 2); } } } #endif }
///----------------------------------------------------------------------------// ///--------------------- UPDATE SECTION ---------------------------------------// ///----------------------------------------------------------------------------// Scene::Enum update(float) override { //si on bouche les trous if (!newLeaves.empty()) { //tout le monde est en place : quel sera le prochain état ? if (updateLeavesSpawn()) { newLeaves.clear(); return NextState(true); } //sinon si on est en train de remplacer la grille (plus de combinaisons en cours de jeu) } else if (ADSR(replaceGrid)->active) { const float value = ADSR(replaceGrid)->value; std::vector<Entity> feuilles = theHeriswapGridSystem.RetrieveAllEntityWithComponent(); //les feuilles disparaissent (taille tend vers 0) for ( std::vector<Entity>::reverse_iterator it = feuilles.rbegin(); it != feuilles.rend(); ++it ) { const glm::vec2 size = HeriswapGame::CellSize(theHeriswapGridSystem.GridSize, HERISWAPGRID(*it)->type) * HeriswapGame::CellContentScale() * (1 - ADSR(replaceGrid)->value); TRANSFORM(*it)->size = size * (1 - value); } //les feuilles ont disparu, on les supprime et on remplit avec de nouvelles feuilles if (value == ADSR(replaceGrid)->sustainValue) { theHeriswapGridSystem.DeleteAll(); fillTheBlank(newLeaves); LOGI("nouvelle grille de '" << newLeaves.size() << "' elements! "); game->datas->successMgr->gridResetted = true; ADSR(haveToAddLeavesInGrid)->activationTime = 0; ADSR(haveToAddLeavesInGrid)->active = true; } //sinon on regarde dans quel état on arrive avec notre grille actuelle } else { return NextState(false); } return Scene::Spawn; }
const uint8_t* TilesAttackGameModeManager::restoreInternalState(const uint8_t* in, int size) { in = GameModeManager::restoreInternalState(in, size); memcpy(&leavesDone, in, sizeof(leavesDone)); in += sizeof(leavesDone); initPosition(); TRANSFORM(herisson)->position.x = GameModeManager::position(leavesDone); return in; }
Entity GameModeManager::createAndAddLeave(int type, const glm::vec2& position, float rotation) { Entity e = theEntityManager.CreateEntity(HASH("branch/leave", 0x6ac1ed8f)); ADD_COMPONENT(e, Transformation); ADD_COMPONENT(e, Rendering); ADD_COMPONENT(e, Twitch); RENDERING(e)->texture = theRenderingSystem.loadTextureFile(HeriswapGame::cellTypeToTextureNameAndRotation(type, 0)); RENDERING(e)->show = true; RENDERING(e)->flags = RenderingFlags::NonOpaque; TRANSFORM(e)->size = HeriswapGame::CellSize(8, type) * HeriswapGame::CellContentScale(); TRANSFORM(e)->position = position; TRANSFORM(e)->rotation = rotation; TRANSFORM(e)->z = glm::lerp(DL_LeafMin, DL_LeafMax, glm::linearRand(0.f, 1.f)); return e; }
HRESULT D3DVertexCacher::DrawParallelogramAA(float ox11, float oy11, float ox21, float oy21, float ox12, float oy12, float ix11, float iy11, float ix21, float iy21, float ix12, float iy12) { HRESULT res; DECLARE_MATRIX(om); DECLARE_MATRIX(im); GET_INVERTED_MATRIX(im, ix11, iy11, ix21, iy21, ix12, iy12, // inner parallelogram is degenerate // therefore it encloses no area // fill outer return FillParallelogramAA(ox11, oy11, ox21, oy21, ox12, oy12)); GET_INVERTED_MATRIX(om, ox11, oy11, ox21, oy21, ox12, oy12, return D3D_OK); if (SUCCEEDED(res = EnsureCapacity(D3DPT_TRIANGLELIST, 2*3))) { float ox = ox11, oy = oy11; float ow = 0.0f, oh = 0.0f; ADJUST_PGRAM(ox, ox21, ow); ADJUST_PGRAM(oy, oy21, oh); ADJUST_PGRAM(ox, ox12, ow); ADJUST_PGRAM(oy, oy12, oh); float ox11 = floor(ox); float oy11 = floor(oy); float ox22 = ceil(ox + ow); float oy22 = ceil(oy + oh); float ou11, ov11, ou12, ov12, ou21, ov21, ou22, ov22; TRANSFORM(om, ou11, ov11, ox11, oy11); TRANSFORM(om, ou21, ov21, ox22, oy11); TRANSFORM(om, ou12, ov12, ox11, oy22); TRANSFORM(om, ou22, ov22, ox22, oy22); float iu11, iv11, iu12, iv12, iu21, iv21, iu22, iv22; TRANSFORM(im, iu11, iv11, ox11, oy11); TRANSFORM(im, iu21, iv21, ox22, oy11); TRANSFORM(im, iu12, iv12, ox11, oy22); TRANSFORM(im, iu22, iv22, ox22, oy22); ADD_TRIANGLE_XYUVUVC(ox11, oy11, ox22, oy11, ox11, oy22, ou11, ov11, ou21, ov21, ou12, ov12, iu11, iv11, iu21, iv21, iu12, iv12, color); ADD_TRIANGLE_XYUVUVC(ox11, oy22, ox22, oy11, ox22, oy22, ou12, ov12, ou21, ov21, ou22, ov22, iu12, iv12, iu21, iv21, iu22, iv22, color); } return res; }
void TouchInputManager::activateDebug(Entity camera) { for (int i=0; i<MAX_TOUCH_POINT; i++) { debugState[i] = theEntityManager.CreateEntity(HASH("debug_input", 0x0)); ADD_COMPONENT(debugState[i], Transformation); ADD_COMPONENT(debugState[i], Anchor); ANCHOR(debugState[i])->parent = camera; ANCHOR(debugState[i])->z = 0.9999f - TRANSFORM(camera)->z; ADD_COMPONENT(debugState[i], Rendering); RENDERING(debugState[i])->show = 1; } }
static Entity createCell(Feuille& f, bool assignGridPos) { Entity e = theEntityManager.CreateEntityFromTemplate("spawn/cell"); ADD_COMPONENT(e, HeriswapGrid); ADD_COMPONENT(e, Twitch); TRANSFORM(e)->position = HeriswapGame::GridCoordsToPosition(f.X, f.Y, theHeriswapGridSystem.GridSize); TRANSFORM(e)->z = DL_Cell + Random::Float(0.f, 1.f) * 0.001f; RenderingComponent* rc = RENDERING(e); rc->show = true; TRANSFORM(e)->size = glm::vec2(0.f); ADSR(e)->idleValue = HeriswapGame::CellSize(theHeriswapGridSystem.GridSize, f.type).x * HeriswapGame::CellContentScale(); HERISWAPGRID(e)->type = f.type; if (assignGridPos) { HERISWAPGRID(e)->i = f.X; HERISWAPGRID(e)->j = f.Y; } rc->texture = theRenderingSystem.loadTextureFile(HeriswapGame::cellTypeToTextureNameAndRotation(f.type, &TRANSFORM(e)->rotation)); return e; }
static WEBP_INLINE void ConvertRGBToUV_SSE41(const __m128i* const R, const __m128i* const G, const __m128i* const B, __m128i* const U, __m128i* const V) { const __m128i kRG_u = MK_CST_16(-9719, -19081); const __m128i kGB_u = MK_CST_16(0, 28800); const __m128i kRG_v = MK_CST_16(28800, 0); const __m128i kGB_v = MK_CST_16(-24116, -4684); const __m128i kHALF_UV = _mm_set1_epi32(((128 << YUV_FIX) + YUV_HALF) << 2); const __m128i RG_lo = _mm_unpacklo_epi16(*R, *G); const __m128i RG_hi = _mm_unpackhi_epi16(*R, *G); const __m128i GB_lo = _mm_unpacklo_epi16(*G, *B); const __m128i GB_hi = _mm_unpackhi_epi16(*G, *B); TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_u, kGB_u, kHALF_UV, YUV_FIX + 2, *U); TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_v, kGB_v, kHALF_UV, YUV_FIX + 2, *V); }
/* Update the message digest with the contents * of INBUF with length INLEN. */ static void sha1_write( void *context, const void *inbuf_arg, size_t inlen) { const unsigned char *inbuf = inbuf_arg; SHA1_CONTEXT *hd = context; size_t nblocks; if (hd->count == 64) /* Flush the buffer. */ { TRANSFORM( hd, hd->buf, 1 ); _gcry_burn_stack (88+4*sizeof(void*)); hd->count = 0; hd->nblocks++; } if (!inbuf) return; if (hd->count) { for (; inlen && hd->count < 64; inlen--) hd->buf[hd->count++] = *inbuf++; sha1_write (hd, NULL, 0); if (!inlen) return; } nblocks = inlen / 64; if (nblocks) { TRANSFORM (hd, inbuf, nblocks); hd->count = 0; hd->nblocks += nblocks; inlen -= nblocks * 64; inbuf += nblocks * 64; } _gcry_burn_stack (88+4*sizeof(void*)); /* Save remaining bytes. */ for (; inlen && hd->count < 64; inlen--) hd->buf[hd->count++] = *inbuf++; }
static unsigned hash P2C(hash_table_type, table, const_string, key) { unsigned n = 0; /* Our keys aren't often anagrams of each other, so no point in weighting the characters. */ while (*key != 0) n = (n + n + TRANSFORM (*key++)) % table.size; return n; }
int TilesAttackGameModeManager::saveInternalState(uint8_t** out) { uint8_t* tmp; int parent = GameModeManager::saveInternalState(&tmp); int s = sizeof(leavesDone); uint8_t* ptr = *out = new uint8_t[parent + s]; MEMPCPY(uint8_t*, ptr, tmp, parent); MEMPCPY(uint8_t*, ptr, &leavesDone, sizeof(leavesDone)); TRANSFORM(herisson)->position.x = GameModeManager::position(leavesDone); delete[] tmp; return (parent + s); }
const uint8_t* NormalGameModeManager::restoreInternalState(const uint8_t* in, int size) { in = GameModeManager::restoreInternalState(in, size); memcpy(&level, in, sizeof(level)); in += sizeof(level); memcpy(&remain[0], in, sizeof(remain)); in += sizeof(remain); memcpy(&limit, in, sizeof(limit)); in += sizeof(limit); TRANSFORM(herisson)->position.x = GameModeManager::position(time / limit); MUSIC(stressTrack)->volume = 0; ADSR(stressTrack)->active = false; ADSR(stressTrack)->value = 0; return in; }
static WEBP_INLINE void ConvertRGBToY_SSE41(const __m128i* const R, const __m128i* const G, const __m128i* const B, __m128i* const Y) { const __m128i kRG_y = MK_CST_16(16839, 33059 - 16384); const __m128i kGB_y = MK_CST_16(16384, 6420); const __m128i kHALF_Y = _mm_set1_epi32((16 << YUV_FIX) + YUV_HALF); const __m128i RG_lo = _mm_unpacklo_epi16(*R, *G); const __m128i RG_hi = _mm_unpackhi_epi16(*R, *G); const __m128i GB_lo = _mm_unpacklo_epi16(*G, *B); const __m128i GB_hi = _mm_unpackhi_epi16(*G, *B); TRANSFORM(RG_lo, RG_hi, GB_lo, GB_hi, kRG_y, kGB_y, kHALF_Y, YUV_FIX, *Y); }
HRESULT D3DVertexCacher::FillParallelogramAA(float fx11, float fy11, float dx21, float dy21, float dx12, float dy12) { HRESULT res; DECLARE_MATRIX(om); GET_INVERTED_MATRIX(om, fx11, fy11, dx21, dy21, dx12, dy12, return D3D_OK); if (SUCCEEDED(res = EnsureCapacity(D3DPT_TRIANGLELIST, 2*3))) { float px = fx11, py = fy11; float pw = 0.0f, ph = 0.0f; ADJUST_PGRAM(px, dx21, pw); ADJUST_PGRAM(py, dy21, ph); ADJUST_PGRAM(px, dx12, pw); ADJUST_PGRAM(py, dy12, ph); float px1 = floor(px); float py1 = floor(py); float px2 = ceil(px + pw); float py2 = ceil(py + ph); float u11, v11, u12, v12, u21, v21, u22, v22; TRANSFORM(om, u11, v11, px1, py1); TRANSFORM(om, u21, v21, px2, py1); TRANSFORM(om, u12, v12, px1, py2); TRANSFORM(om, u22, v22, px2, py2); ADD_TRIANGLE_XYUVUVC(px1, py1, px2, py1, px1, py2, u11, v11, u21, v21, u12, v12, 5.0, 5.0, 6.0, 5.0, 5.0, 6.0, color); ADD_TRIANGLE_XYUVUVC(px1, py2, px2, py1, px2, py2, u12, v12, u21, v21, u22, v22, 5.0, 6.0, 6.0, 5.0, 6.0, 6.0, color); } return res; }
int NormalGameModeManager::saveInternalState(uint8_t** out) { uint8_t* tmp; int parent = GameModeManager::saveInternalState(&tmp); int s = sizeof(level) + sizeof(remain) + sizeof(limit); uint8_t* ptr = *out = new uint8_t[parent + s]; MEMPCPY(uint8_t*, ptr, tmp, parent); MEMPCPY(uint8_t*, ptr, &level, sizeof(level)); MEMPCPY(uint8_t*, ptr, &remain[0], sizeof(remain)); MEMPCPY(uint8_t*, ptr, &limit, sizeof(limit)); TRANSFORM(herisson)->position.x = GameModeManager::position(time / limit); delete[] tmp; return (parent + s); }
void GameModeManager::Enter() { PROFILE("GameModeManager", "Enter", BeginEvent); RENDERING(herisson)->show = true; RENDERING(herisson)->color.a = 1; RENDERING(branch)->show = true; SCROLLING(decor2nd)->show = true; SCROLLING(decor1er)->show = true; LoadHerissonTexture(bonus+1); uiHelper.show(); theHeriswapGridSystem.ShowAll(true); TRANSFORM(herisson)->position.x = initialHerissonPosition(herisson); PROFILE("GameModeManager", "Enter", EndEvent); }
static unsigned hash (hash_table_type table, const_string key) { unsigned n = 0; /* Our keys aren't often anagrams of each other, so no point in weighting the characters. */ while (*key != 0) #if defined (WIN32) && defined (KPSE_COMPAT_API) if (IS_KANJI(key)) { n = (n + n + (unsigned)(*key++)) % table.size; n = (n + n + (unsigned)(*key++)) % table.size; } else #endif n = (n + n + TRANSFORM (*key++)) % table.size; return n; }
void FFT::fft8(Complex *z) { float t1, t2, t3, t4, t5, t6, t7, t8; fft4(z); BF(t1, z[5].re, z[4].re, -z[5].re); BF(t2, z[5].im, z[4].im, -z[5].im); BF(t3, z[7].re, z[6].re, -z[7].re); BF(t4, z[7].im, z[6].im, -z[7].im); BF(t8, t1, t3, t1); BF(t7, t2, t2, t4); BF(z[4].re, z[0].re, z[0].re, t1); BF(z[4].im, z[0].im, z[0].im, t2); BF(z[6].re, z[2].re, z[2].re, t7); BF(z[6].im, z[2].im, z[2].im, t8); TRANSFORM(z[1], z[3], z[5], z[7], sqrthalf, sqrthalf); }
void GameModeManager::Setup() { herisson = theEntityManager.CreateEntityFromTemplate("gamemode/herisson"); branch = theEntityManager.CreateEntityFromTemplate("gamemode/branch"); decor2nd = theEntityManager.CreateEntityFromTemplate("gamemode/decor2nd"); // HACK TRANSFORM(decor2nd)->size.x = PlacementHelper::ScreenSize.x; SCROLLING(decor2nd)->images.push_back(HASH("decor2nd_0", 0x2da4a4da)); SCROLLING(decor2nd)->images.push_back(HASH("decor2nd_3", 0xb93314de)); SCROLLING(decor2nd)->images.push_back(HASH("decor2nd_2", 0xc2edcdae)); SCROLLING(decor2nd)->images.push_back(HASH("decor2nd_1", 0xe8c9a7d4)); decor1er = theEntityManager.CreateEntityFromTemplate("gamemode/decor1er"); TRANSFORM(decor1er)->size.x = PlacementHelper::ScreenSize.x; SCROLLING(decor1er)->images.push_back(HASH("decor1er_0", 0x3a3efebf)); SCROLLING(decor1er)->images.push_back(HASH("decor1er_1", 0x5ba415d2)); SCROLLING(decor1er)->images.push_back(HASH("decor1er_2", 0x68f8263e)); SCROLLING(decor1er)->images.push_back(HASH("decor1er_3", 0x4d7b9af)); fillVec(); uiHelper.build(); #if SAC_DEBUG _debug = false; for(int i=0; i<8; i++) { debugEntities[2*i] = theEntityManager.CreateEntity(HASH("debug/Entities", 0x15df1b7c)); ADD_COMPONENT(debugEntities[2*i], Rendering); ADD_COMPONENT(debugEntities[2*i], Transformation); RENDERING(debugEntities[2*i])->texture = theRenderingSystem.loadTextureFile(HeriswapGame::cellTypeToTextureNameAndRotation(i, 0)); TRANSFORM(debugEntities[2*i])->z = DL_DebugLayer; TRANSFORM(debugEntities[2*i])->size = glm::vec2((float)PlacementHelper::GimpWidthToScreen(80)); debugEntities[2*i + 1] = theEntityManager.CreateEntity(HASH("debug/Entities", 0x15df1b7c)); ADD_COMPONENT(debugEntities[2*i + 1], Text); TEXT(debugEntities[2*i + 1])->positioning = TextComponent::CENTER; ADD_COMPONENT(debugEntities[2*i + 1], Transformation); TRANSFORM(debugEntities[2*i + 1])->position = TRANSFORM(debugEntities[2*i])->position; TRANSFORM(debugEntities[2*i+1])->z = DL_DebugLayer + 0.01f; TEXT(debugEntities[2*i + 1])->fontName = HASH("typo", 0x5a18f4a9); TEXT(debugEntities[2*i + 1])->charHeight = PlacementHelper::GimpHeightToScreen(25); } #endif }
void ScrollingSystem::DoUpdate(float dt) { FOR_EACH_ENTITY_COMPONENT(Scrolling, a, sc) EltIt iter = elements.find(a); if (iter == elements.end()) { if ( glm::abs(glm::length(sc->direction) - 1) <= 0.001) { initScrolling(a, sc); iter = elements.find(a); } continue; } if (!sc->show) { ScrollingElement& se = iter->second; for (int i=0; i<2; i++) { RENDERING(se.e[i])->show = false; } continue; } LOGF_IF(sc->speed < 0, "Scrolling component '" << sc << "' has a speed < 0"); ScrollingElement& se = iter->second; for (int i=0; i<2; i++) { RENDERING(se.e[i])->show = true; AnchorComponent* tc = ANCHOR(se.e[i]); tc->position += sc->direction * (sc->speed * dt); bool isVisible = theRenderingSystem.isVisible(se.e[i]); if (!se.hasBeenVisible[i] && isVisible) { se.hasBeenVisible[i] = true; } else if (se.hasBeenVisible[i] && !isVisible) { se.imageIndex[i] = (se.imageIndex[i] + 2) % sc->images.size(); RENDERING(se.e[i])->texture = sc->images[se.imageIndex[i]]; const auto* ptc = TRANSFORM(a); tc->position = ANCHOR(se.e[(i+1)%2])->position - glm::vec2(sc->direction.x * ptc->size.x, sc->direction.y * ptc->size.y); se.hasBeenVisible[i] = false; } } END_FOR_EACH() }