void PlayerCommand::setBomb() { if (!arguments.empty()) { Log::get() << "Invalid arguments for \"" << OBJ_PLAYER << "." << MSG_SETBOMB << "()\"" << LogLevel::error; } if (tileMap->bombCount() < player->maxBombs() && !tileMap->tileHasBomb(player->position())) { tileMap->addBomb(Bomb(player->position())); } }
BombManager::BombManager( Vertex2f __point, float __side, Vertex3f __color, uint __w, uint __h, const std::shared_ptr<Map>& __map, const std::shared_ptr<PlayerManager>& __pm) { for (uint i = 0; i < numOfBombs; i++) { bombVec.push_back(Bomb(__point, __side, __color, __w, __h, __map, __pm)); } setCorVec(); }
void FixBrick() { int i; for (i=0;i<4;i++) { board[Brick.pos.x+Shape[Brick.type][Brick.rotation][i].x][Brick.pos.y+Shape[Brick.type][Brick.rotation][i].y].type=BRICK; board[Brick.pos.x+Shape[Brick.type][Brick.rotation][i].x][Brick.pos.y+Shape[Brick.type][Brick.rotation][i].y].color=Brick.type; } brink=0; DisplayBrick(Brick,TRUE); printf("\a"); if(item) Bomb(); if(CheckBrick()) MoveAll(); }
void GameLogic_delaycreate::updateCreateGems(float dt){ CCObject* obj; CCArray* toRmove = CCArray::create(); CCARRAY_FOREACH(m_delay_create_gems, obj){ DelayGemCreate* create_gem = (DelayGemCreate*)obj; create_gem->delayTime-=dt; create_gem->delayTime = MAX(0, create_gem->delayTime); if (create_gem->delayTime == 0) { toRmove->addObject(create_gem); m_gems[create_gem->pos]->create(create_gem->new_id); m_gems[create_gem->pos]->m_IsNewCreated = false; if (create_gem->bomb_delay>=-1) { Bomb(create_gem->pos,create_gem->bomb_delay); } } }
TEST_F(BlastTest, calculateRange) { unsigned long int ref = 990*990+990*990+990*990; blst->calculateRange(); EXPECT_EQ(ref, blst->rangeMax); std::vector<Bomb> v2; v2.push_back(Bomb(500, 500, 500)); Blast *blst2 = new Blast(v2); blst2->calculateRange(); EXPECT_EQ(500*500+500*500+500*500, blst2->rangeMax); delete blst2; }
bool GameLogic_match::matchColors(int pos,bool ishelp){ m_match_ignore_pos.clear(); m_match_clear_pos.clear(); m_match_new_gem_type.clear(); int color = m_gems[pos]->getColor(); matchColor(pos); bool hasBombs = false; if (m_match_clear_pos.size()>0) { if (!ishelp) { Combo(); } hasBombs = true; } if (m_match_new_gem_type.size()>1) { vector<NewSpcialGemInfos*>::iterator it; for ( it= m_match_new_gem_type.begin();it<m_match_new_gem_type.end();it++) { NewSpcialGemInfos* infos = *it; if (infos->gem_area_count==0) { m_match_new_gem_type.erase(it); it--; } } } for (unsigned int i=0; i<m_match_clear_pos.size();i++) { if (ishelp) { m_gems[m_match_clear_pos[i]]->showHelpAnim(); }else{ Bomb(m_match_clear_pos[i]); } } // if (m_match_clear_pos.size()>0) { // CCLOG("clear_count %ld",m_match_clear_pos.size()); // } // // for (int i=0; i<m_match_new_gem_type.size(); i++) { // cout<<"gem_v_count "<<m_match_new_gem_type[i]->gem_v_count // <<" gem_h_count "<<m_match_new_gem_type[i]->gem_h_count // <<" gem_area_count "<<m_match_new_gem_type[i]->gem_area_count // <<" gem_magic_count "<<m_match_new_gem_type[i]->gem_magic_count // <<" pos "<<m_match_new_gem_type[i]->pos; // } // return hasBombs; if (ishelp) { return hasBombs; } for (unsigned int i=0; i< m_match_new_gem_type.size(); i++) { NewSpcialGemInfos* infos = m_match_new_gem_type[i]; if (!m_gems[infos->pos]->isEmpty()) { continue; } if (!m_blocks[infos->pos]->canInsertGem()) { continue; } for (int j=0; j<infos->gem_area_count; j++) { int _p; if (m_gems[infos->pos]->isEmpty()) { _p = infos->pos; }else{ _p = getEmptyPosRound(infos->pos); } if (_p!=-1) { m_gems[_p]->create(GEM_AREA*10+color); showSeaHurt(200, _p); if (G::g_game_mode == GAMEMODE_SEA) { G::G_Add_Achievement_Complete(35); } achieve_count->combine_count++; } } for (int j=0; j<infos->gem_magic_count; j++) { int _p; if (m_gems[infos->pos]->isEmpty()) { _p = infos->pos; }else{ _p = getEmptyPosRound(infos->pos); } if (_p!=-1) { m_gems[_p]->create(GEM_MAGIC*10+GEM_COLOR_NOCOLOR); G::G_Add_Achievement_Complete(8); achieve_count->create_magic_count++; achieve_count->combine_count++; showSeaHurt(200, _p); if (G::g_game_mode == GAMEMODE_SEA) { G::G_Add_Achievement_Complete(35); } } } for (int j=0; j<infos->gem_h_count; j++) { int _p; if (m_gems[infos->pos]->isEmpty()) { _p = infos->pos; }else{ _p = getEmptyPosRound(infos->pos); } if (_p!=-1) { m_gems[_p]->create(GEM_H*10+color); showSeaHurt(200, _p); if (G::g_game_mode == GAMEMODE_SEA) { G::G_Add_Achievement_Complete(35); } achieve_count->combine_count++; } } for (int j=0; j<infos->gem_v_count; j++) { int _p; if (m_gems[infos->pos]->isEmpty()) { _p = infos->pos; }else{ _p = getEmptyPosRound(infos->pos); } if (_p!=-1) { m_gems[_p]->create(GEM_V*10+color); showSeaHurt(200, _p); if (G::g_game_mode == GAMEMODE_SEA) { G::G_Add_Achievement_Complete(35); } achieve_count->combine_count++; } } } m_match_ignore_pos.clear(); m_match_clear_pos.clear(); m_match_new_gem_type.clear(); return hasBombs; }
// 게임 시작. // 커서가 가리키는 위치의 유니코드 배경 색 바꾸기. // 0,0일때 8 + 2*x, +2* y +3 위치에 배경색 설정 후 printf("유니"); 스위치문 갖다 넣기 int StartGame() { int i, j, A, B; ConfirmBoard(); BackColor(' '); color(15); SetCursors(50, 8); printf("Level:%d", level); SetCursors(50, 9); printf("Time: %d", timer); SetCursors(50, 10); printf("score:%d", score); SetCursors(50, 11); printf("fever: %2d", fev_lev); while (1) { B = 0; for (i = 0; i < BOARD_WIDTH; i++) { for (j = 0; j < BOARD_HEIGHT; j++) { Sleep(50); A = Bomb(i, j, 1); drop(); B += A; } } if (B == 0)break; } int x = 0, y = 0, x1 = 0, y1 = 0, x2 = -1, y2 = -1, sel = F, count = 0; char ip = '\0'; BackColor('G'); DrawBoard(x, y); work = 1; while (1) { if (start > end) fevt = fevt + (start - end) / 2; if (TEST == T) { SetCursors(50, 14); printf("%03d", (end - fevt) / CLOCKS_PER_SEC); } if ((end - fevt) / CLOCKS_PER_SEC == 10) { fever(0); } end = clock(); timer = -((start - end) / CLOCKS_PER_SEC); BackColor(' '); color(15); SetCursors(56, 9); printf("%02d", timer); if (timer > t_limit) { BackColor(' '); color(15); SetCursors(50, 7); printf("Game Over"); Sleep(2000); system("cls"); record_W(); exit(1); } if (_kbhit()) { if (sel != T) { if (x1 == x2 && y1 == y2) BackColor('W'); else BackColor(' '); DrawBoard(x1, y1); } BackColor('G'); ip = _getch(); switch (ip) { case LEFT: sel = F; if (x > 0) x -= 1; DrawBoard(x, y); break; case RIGHT: sel = F; if (x < BOARD_WIDTH - 1) x += 1; DrawBoard(x, y); break; case UP: ; sel = F; if (y > 0) y -= 1; DrawBoard(x, y); break; case DOWN: sel = F; if (y < BOARD_HEIGHT - 1) y += 1; DrawBoard(x, y); break; case SPACE: sel = T; if ((x1 == x2 + 1 && y1 == y2) || (x1 == x2&&y1 == y2 + 1) || (x1 == x2 - 1 && y1 == y2) || (x1 == x2&&y1 == y2 - 1) || count == 0)BackColor('W'); DrawBoard(x, y); count++; if (count == 1) { x2 = x; y2 = y; } if (count >= 2) { BackColor(' '); color(15); SetCursors(50, 8); printf("Level:%d", level); BackColor(' '); if ((x1 == x2 + 1 && y1 == y2) || (x1 == x2&&y1 == y2 + 1) || (x1 == x2 - 1 && y1 == y2) || (x1 == x2&&y1 == y2 - 1)) { swap(&board[x][y], &board[x2][y2], x, y, x2, y2); ConfirmBoard(); } BackColor(' '); DrawBoard(x, y); //DrawBoard(x2, y2); count = 0; x2 = -1; y2 = -1; } break; case ESC: sel = F; system("cls"); exit(1); break; } x1 = x; y1 = y; sel = F; SetCursors(0, 0); if (TEST == T) printf("%d %d\n%d %d %d \n %d", x1, y1, x2, y2, count, sel); } } }
void ConfirmBoard() { int i, j, n = 0; int tmp; char ip = '\0'; for (i = 0; i<BOARD_HEIGHT; i++) { for (j = 0; j<BOARD_WIDTH; j++) { tmp = board[j][i]; board[j][i] = board[j][i + 1]; board[j][i + 1] = tmp; n += Bomb(i, j, 0); tmp = board[j][i]; board[j][i] = board[j][i + 1]; board[j][i + 1] = tmp; } } for (i = 0; i<BOARD_HEIGHT; i++) { for (j = 0; j<BOARD_WIDTH; j++) { tmp = board[j][i]; board[j][i] = board[j + 1][i]; board[j + 1][i] = tmp; n += Bomb(i, j, 0); tmp = board[j][i]; board[j][i] = board[j + 1][i]; board[j + 1][i] = tmp; } } if (TEST == T) { SetCursors(20, 23); printf("%d", n); } if (n < 2) { SetCursors(5, 20); printf("더 이상 게임진행이 어렵습니다."); SetCursors(5, 21); printf("게임을 계속하려면 space,그만둘려면 esc를 눌러주세요."); ip = _getch(); switch (ip) { case ESC: system("cls"); exit(1); break; case UP: case DOWN: case LEFT: case RIGHT: case SPACE: { SetCursors(5, 20); printf(" "); SetCursors(5, 21); printf(" \n"); CreateBoard(); StartGame(); break; } } } }
// by 한나 void swap(int *a, int*b, int x, int y, int x2, int y2) { int tmp, X, Y; int i, j, A, B = 0; tmp = *a; *a = *b; *b = tmp; DrawBoard(x, y); DrawBoard(x2, y2); X = Bomb(x, y, 1); Y = Bomb(x2, y2, 1); if (X + Y == 0) { BackColor('I'); DrawBoard(x, y); DrawBoard(x2, y2); Sleep(300); tmp = *a; *a = *b; *b = tmp; BackColor(' '); DrawBoard(x, y); DrawBoard(x2, y2); } else { /* end = clock(); timer = -((start - end) / CLOCKS_PER_SEC); BackColor(' '); color(15); SetCursors(50, 9); printf(" "); SetCursors(50, 9); printf("Time: %02d", timer); SetCursors(56, 9); printf("%02d", timer); */ //Sleep(800); drop(); while (1) { B = 0; for (i = 0; i < BOARD_WIDTH; i++) { for (j = 0; j < BOARD_HEIGHT; j++) { Sleep(10); A = Bomb(i, j, 1); drop(); B += A; } } if (B == 0) break; } } }