int main() { char userInput[100]; char *firstWord; char *secondWord; long numInput; int boundsCheck; myStruct * ptrName; ptrName = malloc(sizeof(myStruct)); initscr(); drawInterface(); ptrName->yPos = 13; //This is the center of the interface ptrName->xPos = 37; ptrName->angle = 0; ptrName->pd = 1; //Pen is down ptrName->tStatus = 1; //Turtle is not hidden mvaddch(ptrName->yPos,ptrName->xPos,'@'); do { mvwprintw(stdscr, 27, 47, "Message Board "); mvwprintw(stdscr, 27, 8, "Input? "); getstr(userInput); mvwprintw(stdscr, 30, 40,"You entered: %s",userInput); /*Splitting the user input*/ firstWord = strtok(userInput, " "); secondWord = strtok(NULL, " "); if (secondWord!=NULL) { numInput = atol(secondWord); //converting to integer } clearLine(27,8); boundsCheck = checkBounds(ptrName); //checking the bounds (DOES NOT WORK YET) if (boundsCheck == 1) { movement(firstWord, numInput, ptrName); } refresh(); }while (strcmp(userInput,"quit")!=0); refresh(); endwin(); free(ptrName); return 0; }
void Interface::draw() { drawMap(); drawInterface(); }
void BmsPlayer::bmsPlay(){ ChronoTimer calcflame; // メディアロード開始 SetUseASyncLoadFlag(TRUE); setSoundToMem(); setGraphToMem(); SetUseASyncLoadFlag(FALSE); while (ProcessMessage() == 0 && GetASyncLoadNum() != 0){ if (calcflame.GetLapTime() >= (1.0 / GetRefreshRate()) * 100000){ system_graph.drawsystembg(); system_graph.drawsystem(); DrawFormatString(450, 60, GetColor(255, 255, 255), "GENRE : %s", parser->getHeader("GENRE").c_str()); DrawFormatString(450, 75, GetColor(255, 255, 255), "TITLE : %s", parser->getHeader("TITLE").c_str()); DrawFormatString(450, 90, GetColor(255, 255, 255), "ARTIST: %s", parser->getHeader("ARTIST").c_str()); DrawFormatString(450, 105, GetColor(255, 255, 255), "BPM : %s", parser->getHeader("BPM").c_str()); DrawFormatString(450, 120, GetColor(255, 255, 255), "Loading..."); ScreenFlip(); ClearDrawScreen(); calcflame.ResetTime(); } } // ゲーム用タイマー input.ResetTime(); // 入力関係 Result score; int grph_i = 0; while (ProcessMessage() == 0) { // プレー処理 play_channel_sound(1, input.GetLapTime()); for (int j = 11; j < 20; j++){ play_channel_sound(j, input.GetLapTime()); } input.inputUpdate(); checkJudge(input.GetLapTime()); // 描画ブロック if (calcflame.GetLapTime() >= (1.0 / GetRefreshRate()) * 100000){ system_graph.drawsystembg(); SetDrawMode(DX_DRAWMODE_BILINEAR); grph_i += play_channel_graph(4, grph_i, input.GetLapTime()); SetDrawMode(DX_DRAWMODE_NEAREST); drawInterface(input.GetLapTime()); system_graph.drawsystem(); DrawFormatString(150, 300, GetColor(255, 255, 255), "PERFECT %d", combo_debug); ScreenFlip(); ClearDrawScreen(); calcflame.ResetTime(); } } // リザルトクラス呼び出しとか InitSoundMem(); }
void Visualization::drawFrame() { drawCameraFrame(); drawInterface(); glfwSwapBuffers(); }
int main(int argc, char* argv[]) { int width = 1024, height = 768; if(argc == 5 && strcmp(argv[2], "-r") == 0 ){ width = atoi(argv[3]); height = atoi(argv[4]); } else if(argc == 4 && strcmp(argv[1], "-r") == 0 ){ width = atoi(argv[2]); height = atoi(argv[3]); } /*Initialisation SDL, OpenGL etc */ if( initWindow(width, height) == EXIT_FAILURE){ perror("Impossible d'initialiser la fenêtre SDL, le programme va fermer.\n"); exit(-1); } /* initialisation de SDL_TTF*/ if(TTF_Init()== -1){ printf("Error loading TTF: %s\n",TTF_GetError()); exit(1); } bool askedForQuit = false; World world; world.towersList = NULL; world.map.name = NULL; world.map.tabXYConstruct = NULL; world.map.image = NULL; world.map.pathNodeList = NULL; Interface interface; interface.lstButtons = NULL; char* mapName= NULL; BUTTON_OF_MENU.lstMapName = NULL; BUTTON_OF_MENU.lstMapButton = NULL; BUTTON_OF_MENU.lstMapTextureIndex = NULL; bool play = false; List* lstMaps = createEmptyList(); readDirectory(lstMaps); /* selection d'une carte en ligne de commande*/ if (argc >= 2 && strcmp(argv[1], "-r") != 0){ char* curMap = NULL; while( (curMap = (char*) nextData(lstMaps)) != NULL){ if (strcmp(argv[1],curMap)==0){ mapName = (char*) malloc(strlen(argv[1])*sizeof(char)); if(mapName == NULL){ fprintf(stderr, "Erreur fatale : impossible d'allouer la mémoire nécessaire.\n"); exit(EXIT_FAILURE); } strcpy(mapName,argv[1]); play = true; break; } } if(! play) fprintf(stderr, "Erreur le nom donné en paramètre ne correspond à aucun fichier map\n"); } freeListComplete(lstMaps); /*-------------- GESTION DU MENU --------------------*/ do{ interface.lstButtons = NULL; /* chargement des polices */ int playIsPush = 0; int menuOpen = 0; int aideOpen = 0; initMenuGraphics(); /* ouverture du répertoire data */ while(!play && askedForQuit == false) { /* Récupération du temps au début de la boucle */ Uint32 startTime = SDL_GetTicks(); /* Placer ici le code de dessin du menu */ drawMenu(&menuOpen,&aideOpen,&playIsPush,mapName); /* Echange du front et du back buffer : mise à jour de la fenêtre */ SDL_GL_SwapBuffers(); /* Renvoie une chaine de caractère contenant le nom du fichier ITD choisi par l'utilisateur ou NULL si rien n'a encore été choisi */ askedForQuit = handleMenuActions(&mapName,&playIsPush, &menuOpen,&aideOpen); if(playIsPush == 2) play = true; /* Calcul du temps écoulé */ Uint32 elapsedTime = SDL_GetTicks() - startTime; /* Si trop peu de temps s'est écoulé, on met en pause le programme */ if(elapsedTime < FRAMERATE_MILLISECONDS) { SDL_Delay(FRAMERATE_MILLISECONDS - elapsedTime); } } /*-------------- GESTION DU JEU --------------------*/ bool gameFinished = false; //Surtout à appeler APRES avoir initialisé la SDL char mapPath[50] = "data/"; float width = .15;//10% de largeur float height = 1.; //Toute la hauteur float positionX = 0.85; //A 90% de la largeur float positionY = .0; //A 100% de la hauter if(!askedForQuit){ strcat(mapPath, mapName); world = initWorld(mapPath); initGameGraphics(); GAME_TEXTURES_ID.MAP_ID = makeTextureFromSurface(world.map.image); //Initialisation interface interface = initGameInterface(width, height, positionX, positionY); startWorld(&world); } while(!gameFinished && !askedForQuit) { /* Récupération du temps au début de la boucle */ Uint32 startTime = SDL_GetTicks(); /* On tente un nouveau cycle de tours de jeu si besoin. Le temps est géré par la fonction. La plupart du temps plusieurs tours de jeu sont joués d'affilé. */ worldNewStep(&world); drawWorld(&world); drawInterface(&interface, &world); /* Calcul du temps écoulé, si temps < 10 ms, on ne passe pas au tour suivant. */ Uint32 elapsedTime = SDL_GetTicks() - startTime; /* Si trop peu de temps s'est écoulé, on ne dessine rien. */ if(elapsedTime < FRAMERATE_MILLISECONDS) { /* Echange du front et du back buffer : mise à jour de la fenêtre */ SDL_GL_SwapBuffers(); SDL_Delay(FRAMERATE_MILLISECONDS - elapsedTime); } /* Boucle traitant les evenements */ askedForQuit = handleGameActions(&world, &interface, &gameFinished); } play = false; mapName = NULL; cleanWorld(&world); cleanInterface(&interface); }while(! askedForQuit); /* Liberation des ressources */ cleanExit(&world, &interface); return EXIT_SUCCESS; }