void isLevelDone() { int i, j; // Verify for (i=0; i!=LEVEL_SIDE; i++) for (j=0; j!=LEVEL_SIDE; j++) if (lvl.map[i][j].state == 1) return; // Increment the instructions counter for (i=0; i!=MATRIX_W; i++) for (j=0; j!=MATRIX_H; j++) if (game.func_matrix[i][j] > 0) game.instructions_count++; setFadeMode(&main_fade,FADE_IN,0); waitFadeDone(); // This was the last level... outro time. if (nextLevel()) { game.state = OUTRO; return; } // Else, reset game state; this is intro time. resetGame(); stopProgram(); clearFuncMatrix(); game.state = GAME_INTRO; }
void Inversa::potenciaRegular(matriz *m, matriz *v, double tolerance){ double lambda=0; double lambdaK; double aux; int h=0; matriz *vk; vk=(matriz*)malloc(sizeof(matriz)); vk->rows=v->rows; vk->columns=v->columns; vk->data=aloca(vk->rows,vk->columns); do{ printf("loop: k = %d.\n",h+1); igualaMatrizes(vk,normaEuclidiana(v)); // normalizando v, e vk <- v normalizado "psi"k igualaMatrizes(v,times(m,vk)); // v+1 printf("autovetor:\n"); showMatriz(v); printf("autovetor normalizado:\n"); showMatriz(normaEuclidiana(v)); lambdaK = times(transposta(vk),v)->data[0][0]; // retorna uma matriz 1x1, ou um escalar printf("autovalor:\n"); printf("%f\n",lambdaK); aux=fabs(lambdaK-lambda)/fabs(lambdaK); printf("tolerancia: %f\n",aux); lambda = lambdaK; h++; printf("==========================\n"); if(h==20) stopProgram(); }while(aux>tolerance); }
void controlUI() { if (game.state == GAME) { if (intrp.running && testButton(PSP_CTRL_CROSS,1)) stopProgram(); } if (game.state != GAME_FUNC_SETTING) return; // Function selector ui.func_selected += testButton(PSP_CTRL_RTRIGGER,1) - testButton(PSP_CTRL_LTRIGGER,1); ui.func_selected += FUNC_NBR * ((ui.func_selected < 0) - (ui.func_selected >= FUNC_NBR)); // Matrix selector ui.matrix_x += testButton(PSP_CTRL_RIGHT,1) - testButton(PSP_CTRL_LEFT,1); ui.matrix_y += testButton(PSP_CTRL_DOWN,1) - testButton(PSP_CTRL_UP,1); ui.matrix_x += MATRIX_W * ((ui.matrix_x < 0) - (ui.matrix_x >= MATRIX_W)); ui.matrix_y += MATRIX_H * ((ui.matrix_y < 0) - (ui.matrix_y >= MATRIX_H)); if (testButton(PSP_CTRL_CROSS,1)) { game.func_matrix[ui.matrix_x][ui.matrix_y] = ui.func_selected + 1; nextInstruction(); } else if (testButton(PSP_CTRL_CIRCLE,1)) game.func_matrix[ui.matrix_x][ui.matrix_y] = 0; else if (testButton(PSP_CTRL_SELECT,1)) clearFuncMatrix(); }
void PrenController::setState(const states state) { cout << state << endl; switch (state) { case END: stopProgram(); break; default: cout << "illegal state used" << endl; } }