/** * Représente une case en fonction de la chaîne tapée en paramètre de main. * @param grid Grille à remplir * @param nb_bonus Nombre de bonus lettre et mot dans la grille * @param gridStr Chaîne de caractère passé en paramètre * @param strIndex Indice courant de la chaîne passée en paramètre */ void getCaseFromStr(t_Case grid[N][N], int nb_bonus[], char gridStr[], int strIndex){ int line = 0, col = 0; // Conversion en minuscule pour le traitement if(gridStr[strIndex] < 97){ gridStr[strIndex] += 32; } strIndex = getIChar(gridStr[strIndex]); while(grid[line][col].pts !=0){ col++; } while(grid[line][col].pts !=0){ line++; } grid[line][col].let = alpha[strIndex].let; grid[line][col].pts = alpha[strIndex].pts; getBonus(grid[line][col].boL, grid[line][col].boM, &nb_bonus[0], &nb_bonus[1]); printf(" %c %i %s %s", grid[line][col].let - 32, grid[line][col].pts, grid[line][col].boL, grid[line][col].boM ); if(grid[line][col].pts < 10){ printf(" |"); }else{ printf(" |"); } }
void Bonus::move() { pos.x += vel.x; pos.y += vel.y; vel.x -= vel.x / 50; if (pos.x > fieldLimitX) { pos.x = fieldLimitX; if (vel.x > 0) vel.x = -vel.x; } else if (pos.x < -fieldLimitX) { pos.x = -fieldLimitX; if (vel.x < 0) vel.x = -vel.x; } if (isDown) { vel.y += (-speed - vel.y) / 50; if (pos.y < -fieldLimitY) { isDown = false; pos.y = -fieldLimitY; vel.y = speed; } } else { vel.y += (speed - vel.y) / 50; if (pos.y > fieldLimitY) { missBonus(); isExist = false; return; } } ++cnt; if (cnt < RETRO_CNT) return; float d = pos.dist(ship->pos); if (d < ACQUIRE_WIDTH * (1 + static_cast<float>(inhaleCnt) * 0.2) && ship->cnt >= -Ship::INVINCIBLE_CNT) { getBonus(); isExist = false; return; } if (isInhaled) { ++inhaleCnt; float ip = (INHALE_WIDTH - d) / 48; if (ip < 0.025) ip = 0.025; vel.x += (ship->pos.x - pos.x) * ip; vel.y += (ship->pos.y - pos.y) * ip; if (ship->cnt < -Ship::INVINCIBLE_CNT) { isInhaled = false; inhaleCnt = 0; } } else { if (d < INHALE_WIDTH && ship->cnt >= -Ship::INVINCIBLE_CNT) isInhaled = true; } }
// Função para começar o jogo void Tela::showGame() { fillUndo(); // guarda as telas em um pilha para uso da função Undo applySurface( 0, 0, fundo, screen ); if( SDL_Flip( screen ) == -1 ) return; std::string str = user->getNome(); const char *c = str.c_str(); //Transforma a string em um vetor de char switch(level) { case 1: applySurface( 57.938, 184.812, fase1, screen ); nomeJogador = TTF_RenderText_Solid( font, c, textColor ); applySurface( 20, 120, nomeJogador, screen ); showPontuacao(); break; case 2: applySurface( 57.938, 184.812, fase2, screen ); nomeJogador = TTF_RenderText_Solid( font, c, textColor ); applySurface( 20, 120, nomeJogador, screen ); showPontuacao(); break; case 3: applySurface( 57.938, 184.812, fase3, screen ); nomeJogador = TTF_RenderText_Solid( font, c, textColor ); applySurface( 20, 120, nomeJogador, screen ); showPontuacao(); break; case 4: applySurface( 57.938, 184.812, fase4, screen ); nomeJogador = TTF_RenderText_Solid( font, c, textColor ); applySurface( 20, 120, nomeJogador, screen ); showPontuacao(); } if( SDL_Flip( screen ) == -1 ) return; SDL_Rect my_rects[8]; int qtd; for(int i = 0; i < linhasMatriz; i++) { qtd = 0; for(int j = 0; j < colunasMatriz; j++) { apply_surface(i, j, gems, screen); my_rects[qtd].x = matriz[i][j].celula.x; my_rects[qtd].y = matriz[i][j].celula.y; my_rects[qtd].w = matriz[i][j].celula.w; my_rects[qtd++].h = matriz[i][j].celula.h; } SDL_UpdateRects(screen, 8, my_rects); SDL_Delay(100); } getBonus(); if( SDL_Flip( screen ) == -1 ) return; }
/** * Représente une case aléatoirement. * @param grid Grille à remplir * @param line Ligne de la case à remplir * @param col Colonne de la case à remplir * @param nb_bonus Nombre de bonus lettre et mot dans la grille */ void getCase(t_Case grid[N][N], int line, int col, int nb_bonus[]){ int randLet; randLet = randCase(); grid[line][col].let = alpha[randLet].let; grid[line][col].pts = alpha[randLet].pts; getBonus(grid[line][col].boL, grid[line][col].boM, &nb_bonus[0], &nb_bonus[1]); printf(" %c %i %s %s", grid[line][col].let - 32, grid[line][col].pts, grid[line][col].boL, grid[line][col].boM); if(grid[line][col].pts < 10){ printf(" |"); }else{ printf(" |"); } }
bool BonusManager::canApply(Player *player, BonusType type, SNTypes::tier tier) { return getBonus(type, tier)->canApply(player); }