void runloadscreen(){ Display d=newDisplay(); startFrame(d); LoadScreen(d); quit(d); }
// Testing display.c int TEST_newDisplay() { Display *d; d=newDisplay(); if(d==NULL){ printf("%25s %s\n",__func__, FAIL ); return ERROR; } else{ printf("%25s %s\n",__func__, PASS ); return SUCCESS; } }
int TEST_input() { int value=0; Display *d; d=newDisplay(); value = input(d); if(value!=0){ printf("%25s %s\n",__func__, FAIL ); return ERROR; } else{ printf("%25s %s\n",__func__, PASS ); return SUCCESS; } }
void run() { display *d = newDisplay(); Button *buttons[NUM_BUTTONS]; int i, j, stop = 0, leave = 1, which_alien, money = 0, which_screen = 0; char result, **compare, *input_instruction; int user_input, wins = 0; compare = createAndFillArraywiththeInstuctions(ALIENS, INSTRUCTION); input_instruction = (char*)calloc(1, ALIENS); errorForAllocation(input_instruction); buttons[0] = createButton(940, 580, 40, 70, "WORKS");//x,y,w,h buttons[1] = createButton(280, 430, 40, 70, "WORKS"); Text grid; fillGrid(grid); Cursor *cursor = malloc(sizeof(Cursor)); cursor->r = 0; //------------------------------------ cursor->c = 0; //--------------------------- Money *moneyP = malloc(sizeof(Money)); moneyP->moneyNum = 5; while (!stop && wins < GAMES) { drawEnity(d, 0, 0, 0); result = getEvent(d, buttons); if (result == QUIT) { stop = 1;; } user_input = 0; printf("in main"); fflush(stdout); i = POSITION1, j = POSITION2; //aline location which_alien = rand() % 4 + 1; delayUntilNextAlien(1000); //Animation loop with logic while ((i > POSITION2 || j < POSITION1) && !stop) { drawFrame(d, buttons); result = getEvent(d, buttons); drawEnity(d, which_screen, 0, 0); drawGrid(d, grid, cursor->r, cursor->c); DrawMoney(moneyP, d); if (result == QUIT) { stop = 1;; } else if (result == ENTER) { // if (strcmp(&input_instruction[which_alien], compare[i]) == 0) { money += 100; leave = 1; wins++; // }; } if (i > POSITION2 && result != QUIT) { drawEnity(d, which_alien, 300, i); i--; leave = 0; } if (leave == 0 && i == POSITION2 && result != QUIT) { drawEnity(d, which_alien, 300, POSITION2); result = getEvent(d, buttons); if (result == CLICK1) { leave = 1; } else if (result == HINT) { writeTextToSurface(d, "PLEASW WORK!!!", 255, 255, 255); drawEnity(d, which_alien + ALIENS, 100, 200); } } if (isalpha(result)) { input_instruction[user_input] = result; if (user_input < ALIENS) { user_input++; } else { printf("You are trying to write something to long\n"); } } else if (result == DEL) { if (user_input >= 0) { user_input--; } } if (j < POSITION1 && leave == 1 && result != QUIT) { drawEnity(d, which_alien, 300, j); j++; result = getEvent(d, buttons); } if (result == QUIT) { stop = 1;; } else if ((result != NONE )&&( result!=CLICK1 )&&(result!=HINT)) { action(grid, cursor, result); } } } QuitGame(d); }
int main(void) { Display *d = newDisplay(); cell grid[H][W]; entity *player, *door1, *door2; int in,gamesPlayed[2]; srand(time(NULL)); gamesPlayed[0]=gamesPlayed[1]=0; mediaLoad(d); intro(d); initGrid(grid); // place player player = grid[10][2].foreground = newEntity(passable,P_R1 ,2,10); // Creates the boundary walls makeBoundariesLobby(grid); door1 = grid[4][W-6].background = newEntity(passable,DOORINVIS, W-6,4); door2 = grid[7][W-11].background = newEntity(passable,DOORINVIS ,W-11,7); /* layer of floortiles - must be the last entity placement*/ fillGrid(grid); while(in!=10){ if(gamesPlayed[0]!=MAXPLAYTIMES||gamesPlayed[1]!=MAXPLAYTIMES){ lobbyDraw(d, grid); in=input(d); if( (in > 0) && (in < 5) ){ /*checks for arrowkeys */ move(&grid[player->y][player->x],player->x,player->y,(direction)in,grid); printGrid(grid); } } else{ GameOver(d,&in); if(in!=10){ gamesPlayed[0]=gamesPlayed[1]=0; } else{ /*in==10 the same as d->finished=true;*/ in=10; d->finished=(SDL_bool)true; } } if (grid[player->y][player->x].background == door1&&gamesPlayed[0]<MAXPLAYTIMES) { bgame(d); gamesPlayed[0]++; move(&grid[player->y][player->x],player->x,player->y,DOWN,grid); changeEntity(player, P_DOWN1); } if (grid[player->y][player->x].background == door2&&gamesPlayed[1]<MAXPLAYTIMES) { quizGame(d); gamesPlayed[1]++; move(&grid[player->y][player->x],player->x,player->y,DOWN,grid); changeEntity(player, P_DOWN1); } } freeEntityMem(grid); /* free memory */ closeDisplay(d); d->finished=(SDL_bool)true; fprintf(OUTPUT, "\n\n"); return(0); }