void process_readings(t_kala *data) { int i; i = -1; check_if_y(data); while (*(data->buff.read_buff + ++i)) { check_clear(data, &i); write_in_term(data, i); if ((data->buff.x_idx == 104 || *(data->buff.read_buff + i) == '\n') && data->buff.y_idx < 1000) { *(*(data->buff.term_buff + data->buff.y_idx) + data->buff.x_idx + 1) = 0; data->buff.x_idx = -1; max_length_case(data); check_if_y(data); } ++data->buff.x_idx; } }
void Game::hit_invaders() { for(unsigned int i = 0; i < tank_bullets.size(); i++) { bool hit = false; for(int column = 0; column < invader_group->get_number_per_row(); column++) { for(int row = 0; row < invader_group->get_number_per_column(); row++) { if((!invader_group->get_invader(row,column).isDead()) && tank_bullets[i].hit_object(invader_group->get_invader(row,column))) { invader_group->get_invader(row,column).damage(1); if(invader_group->get_invader(row,column).isDead()) { theTank.increaseScore(column, invader_group->get_invader(row,column).get_score()); //Assignment 4 if (tank_step_time != 0) { if(theTank.getCurrentScore()>=250) tank_step_time = 0; else if (theTank.getCurrentScore()>=100) tank_step_time = 250; } invader_group->increase_death_number(1); } tank_bullets.erase(tank_bullets.begin() + i); i = i - 1; hit = true; break; } } if(hit) break; } } check_clear(); }
/* 게임 */ void scr_Game() { int lastcount; // 이전 초 int currentcount; // 현재 초 PA_Init(); PA_InitVBL(); AS_SoundDefaultPlay((u8*) bgm, (u32) bgm_size, 127, 64, TRUE, 0); while (1) { int i; lastcount = currentcount = 0; stageTime = 30; // 스테이지 제한시간 memoryTime = 10; UnLoad_Screen(); PA_LoadBackground(UP_SCREEN, BG3, &up); // 상단 디스플레이-타이틀화면 설정. PA_LoadBackground(DOWN_SCREEN, BG3, &down); // 하단 디스플레이-타이틀화면 설정. PA_InitText(UP_SCREEN, BG2); PA_SetTextTileCol(UP_SCREEN, TEXT_RED); userBlock_init(); scr_Stage(uinfo.userStage); Memory_info(); PA_LoadSpritePal(UP_SCREEN, BLOCKPAL, (void*) Block_Pal); // 블럭 정보 스프라이트 팔레트 PA_LoadSpritePal(DOWN_SCREEN, BLOCKPAL, (void*) Block_Pal); // 게임 블럭 스프라이트 팔레트 for (i = 0; i < 5; i++) { // 위 화면에 블럭의 변화를 보여주는 sprite 생성 PA_CreateSprite(UP_SCREEN, i, (void*) Block_Sprite, OBJ_SIZE_32X32, 1, BLOCKPAL, (40 * i) + 32, 135); PA_SetSpriteAnim(UP_SCREEN, i, i); } view_block(); PA_VBLCountersReset(); // 카운터 초기화. PA_VBLCounterStart(0); // 카운터 시작. while (1) { currentcount = (PA_VBLCounter[0] / 60); if (lastcount != currentcount) { // 메모리 타임 체크 memoryTime -= (currentcount - lastcount); lastcount = currentcount; Memory_info(); } if (memoryTime == 0) { // 0이하가 되면 본게임으로 AS_SoundDefaultPlay((u8*) blind, (u32) blind_size, 80, 64, FALSE,0); PA_DeleteSprite(DOWN_SCREEN, BLOCKPAL); block_init(); // 블럭 초기화 break; } if (NDS_SWITCH() == KEY_START) memoryTime = 0; PA_WaitForVBL(); } Gaming_info(); while (1) { currentcount = (PA_VBLCounter[0] / 60); if (lastcount != currentcount) { // 게임 시간 체크 stageTime -= (currentcount - lastcount); lastcount = currentcount; Gaming_info(); } if (stageTime <= 0) { //게임 나가기 UnLoad_Sound(); return; } if (Stylus.Newpress) { for (i = 0; i < BLOCKS_NUM; i++){ if (PA_SpriteTouched(i)) block_reload(i); } } if (check_clear()) { // 게임 진행 상태 체크 uinfo.userStage++; // 스테이지 업 AS_SoundDefaultPlay((u8*) stageup, (u32) stageup_size, 45, 64, FALSE,0); break; } PA_WaitForVBL(); } } }