//-------------------------------------------------------------- void VideoManager::update(){ mov1.update(); mov2.update(); tweener.step(ofGetElapsedTimeMillis()); //std::swap(from, to); if(!frameRendered){ if(targetFrame > frameNumber && targetFrame != frameNumber){ frameNumber++; from->setFrame(frameNumber); to->setFrame(frameNumber+1); }else if(targetFrame != frameNumber){ frameNumber--; from->setFrame(frameNumber); to->setFrame(frameNumber-1); } if(DEBUG) cout << "from FrameNumber: " << from->getCurrentFrame() << endl; if(DEBUG) cout << "to FrameNumber: " << to->getCurrentFrame() << endl; framesCount = 0; frameRendered = true; }else{ if (framesCount > framesPerFrame && targetFrame != frameNumber) { if(!isTransitioning) startTransition(); } } framesCount++; }
void settingsSetMenuStatus(int * status) { if (*status == menuStatusThemeSelect) { buildThemesList(); char * currentThemeName = getConfigStringForKey("currentTheme", "Default", configTypeMain); updateMenuTicks(&themesMenu, currentThemeName, true); checkReturnToGrid(&themesMenu); updateMenuIconPositions(&themesMenu); if (animatedGrids) { startTransition(transitionDirectionDown, themeSettingsMenu.pagePosition, &themeSettingsMenu); } } else if (*status == menuStatusWaterSettings) { initWaterMenu(); updateMenuIconPositions(&waterMenu); gotoFirstIcon(&waterMenu); if (animatedGrids) { startTransition(transitionDirectionDown, settingsMenu.pagePosition, &settingsMenu); } } else if (*status == menuStatusThemeSettings) { initThemeSettingsMenu(); updateMenuIconPositions(&themeSettingsMenu); gotoFirstIcon(&themeSettingsMenu); if (animatedGrids) { startTransition(transitionDirectionDown, settingsMenu.pagePosition, &settingsMenu); } } else if (*status == menuStatusGridSettings) { initGridSettingsMenu(); updateMenuIconPositions(&gridSettingsMenu); gotoFirstIcon(&gridSettingsMenu); if (animatedGrids) { startTransition(transitionDirectionDown, settingsMenu.pagePosition, &settingsMenu); } } else if (*status == menuStatusOpenTitleFiltering) { if (titleLoadPaused) { cancelTitleLoading(); } } setMenuStatus(*status); }
void EndingState::onMousePress(Uint8 button, bool down, int x, int y) { if (down) { startTransition(); } }
void CloudsTransitionController::transitionFromClusterMap(float transitionDuration){ confirmEmpty("transitionFromClusterMap"); queueState(TRANSITION_CLUSTERMAP_OUT, transitionDuration); startTransition(); }
void CloudsTransitionController::transitionToFirstVisualSystem(float duration){ confirmEmpty("transitionToFirstVisualSystem"); queueState(TRANSITION_VISUALSYSTEM_IN, duration); startTransition(); }
void EndingState::onKeyPress(SDLKey sym, bool down) { if (down) { startTransition(); } }
void CloudsTransitionController::transitionFromIntro(float outDuration){ confirmEmpty("transitionFromIntro"); queueState(TRANSITION_INTRO_OUT, outDuration); startTransition(); }
void CloudsTransitionController::transitionFromInterlude(float inDuration){ confirmEmpty("transitionFromInterlude"); queueState(TRANSITION_INTERLUDE_OUT, inDuration); startTransition(); }
void CloudsTransitionController::transitionToFirstInterview(float duration){ confirmEmpty("transitionToFirstInterview"); queueState(TRANSITION_INTERVIEW_IN, duration); startTransition(); }
void CloudsTransitionController::transitionWithQuestion(float outDuration, float portalDuration){ confirmEmpty("transitionWithQuestion"); queueState(TRANSITION_INTERVIEW_OUT, outDuration); //queueState(TRANSITION_QUESTION_IN, portalDuration); startTransition(); }
void CloudsTransitionController::transitionToVisualSystem(float outDuration, float inDuration){ confirmEmpty("transitionToVisualSystem"); cout << "TRANSITION POINTCLOUD --> VISUAL SYSTEM" << endl; queueState(TRANSITION_INTERVIEW_OUT, outDuration); queueState(TRANSITION_VISUALSYSTEM_IN, inDuration); startTransition(); }
void CloudsTransitionController::transitionToInterview(float outDuration, float inDuration){ confirmEmpty("transitionToInterview"); cout << "TRANSITION VISUAL SYSTEM --> POINTCLOUD" << endl; queueState(TRANSITION_VISUALSYSTEM_OUT, outDuration); queueState(TRANSITION_INTERVIEW_IN, inDuration); startTransition(); }
void settingsShowColours() { if (colourSelectMenuNeedsInit) { initColourSelectMenu(); } updateMenuIconPositions(&colourSelectMenu); gotoFirstIcon(&colourSelectMenu); setMenuStatus(menuStatusColourSettings); if (animatedGrids) { startTransition(transitionDirectionDown, themeSettingsMenu.pagePosition, &themeSettingsMenu); } }
void gamePause(SDL_Surface* screen) { startTransition(screen, TRANSITION_TYPE_ROLL_IN,500); restartConfirm=0; //If we are in the editor, we want to jump back to last menu state //But otherwise we want to see the main menu. if(!player()->inEditor) { setMenu(menuStatePaused); setMenuPosY(1); } }
int lostLifeMsg( cursorType* cur, playField* pf, SDL_Surface* screen, const char* strmsg, const char* straction ) { draw(cur,pf, screen); //drawUi(screen); countdown-=getTicks(); txtWriteCenter(screen, GAMEFONTMEDIUM, strmsg, HSCREENW,HSCREENH-24); if(countdown < 1000) { txtWriteCenter(screen, GAMEFONTSMALL, STR_MENU_PRESS_B, HSCREENW,HSCREENH+12); //Wait for anykey if(getButton(C_BTNB) || countdown < -6000 || getInpPointerState()->isDown ) { resetBtn(C_BTNB); resetMouseBtn(); //Subtract lives if(!player()->inEditor) { if(player()->lives != -1) { player()->lives--; } if(player()->lives==0) { setGameOver(); } else { //Lost a life, but did not get gameover, upload the death statsUpload(player()->level, player()->hsEntry.time, player()->hsEntry.moves,player()->hsEntry.combos,player()->hsEntry.score, straction,0, NULL); setMenu(menuStateNextLevel); } } //Clear score player()->hsEntry.score=0; //Goto cleanup, then menu cleanUpGame(); startTransition(screen, TRANSITION_TYPE_ROLL_IN, 700); return(1); } } return(0); }
void CloudsTransitionController::transitionToIntro(float inDuration){ confirmEmpty("transitionToIntro"); if(previousState == TRANSITION_INTERLUDE_IN){ queueState(TRANSITION_INTERLUDE_OUT, inDuration); } else if(previousState == TRANSITION_INTERVIEW_IN){ queueState(TRANSITION_INTERVIEW_OUT, inDuration); } else if(previousState == TRANSITION_VISUALSYSTEM_IN){ queueState(TRANSITION_VISUALSYSTEM_OUT, inDuration); } queueState(TRANSITION_INTRO_IN, inDuration); startTransition(); }
void CloudsTransitionController::transitionToInterlude(float inDuration,float outDuration){ confirmEmpty("transitionToInterlude"); //we are in a visual system if(getPreviousState() == TRANSITION_VISUALSYSTEM_IN){ cout<<"VISUAL SYSTEM --> INTERLUDE MAP"<<endl; currentState = TRANSITION_VISUALSYSTEM_IN; queueState(TRANSITION_VISUALSYSTEM_OUT, outDuration); queueState(TRANSITION_INTERLUDE_IN, inDuration); } //we are in an interview else if(getPreviousState() == TRANSITION_INTERVIEW_IN){ cout<<"INTERVIEW --> INTERLUDE MAP"<<endl; queueState(TRANSITION_INTERVIEW_OUT, outDuration); queueState(TRANSITION_INTERLUDE_IN, inDuration); } startTransition(); }
int runGame(SDL_Surface* screen) { if(gameState==GAMESTATEPLAYING) { getInpPointerState()->escEnable=1; //Handle input int lim=1; //Limit cursor travel... int goUp=0, goDown=0, goLeft=0, goRight=0; if( getButton( C_UP ) ) { restartConfirm=0; if( getBtnTime( C_UP ) > REPEATDELAY ) { goUp=1; } else if(getBtnTime(C_UP)==0) { goUp=1; lim=0; } } if( getButton( C_DOWN ) ) { restartConfirm=0; if( getBtnTime( C_DOWN ) > REPEATDELAY ) { goDown=1; } else if(getBtnTime(C_DOWN)==0) { goDown=1; lim=0; } } if( getButton( C_LEFT ) ) { restartConfirm=0; if( getBtnTime( C_LEFT ) > REPEATDELAY ) { goLeft=1; } else if(getBtnTime(C_LEFT)==0) { goLeft=1; lim=0; } } if( getButton( C_RIGHT ) ) { restartConfirm=0; if( getBtnTime( C_RIGHT ) > REPEATDELAY ) { goRight=1; } else if(getBtnTime(C_RIGHT)==0) { goRight=1; lim=0; } } //Pause ? if( getButton( C_BTNMENU ) || isPointerEscapeClicked() ) { resetBtn( C_BTNMENU ); gamePause(screen); return(STATEMENU); } //Retry if( getButton( C_BTNSELECT ) || (getInpPointerState()->timeSinceMoved<POINTER_SHOW_TIMEOUT && isBoxClicked(&ptrRestartRect)) ) { resetBtn( C_BTNSELECT ); resetMouseBtn(); if(!restartConfirm) { restartConfirm=1; } else if(restartConfirm) { gameRestart(screen); } } //Handle mouse input if( getInpPointerState()->timeSinceMoved==0 && !cur.lock ) { setCursor(&cur, getInpPointerState()->curX,getInpPointerState()->curY ); } if(!getInpPointerState()->isDown) { mouseGrab=0; //Allow moving the cursor around with the input device when no brick is below, just for effect } else { brickType* b=brickUnderCursor(&pf, cur.x,cur.y); //We're over a brick, tell curser it's position, it will be locked later because we grab it now if( b ) { getInpPointerState()->startX=b->dx; getInpPointerState()->startY=b->dy; if( !cur.lock ) { mouseGrab=1; getInpPointerState()->startX=getInpPointerState()->curX; getInpPointerState()->startY=getInpPointerState()->curY; } else { if( b->dx > getInpPointerState()->curX ) { //Drag Left if( b->dx == b->sx && getInpPointerState()->startX != getInpPointerState()->curX ) { goLeft=1; } } else if( b->dx < getInpPointerState()->curX ) { //Drag Right if( b->dx == b->sx && getInpPointerState()->startX != getInpPointerState()->curX ) { goRight=1; } } } } else { mouseGrab=0; } } // printf("x:%i\n", getInpPointerState()->curX ); //Drag if( getButton( C_BTNX ) || getButton( C_BTNB ) || mouseGrab || isPointerClicked() ) { //Remove "Restart" question restartConfirm=0; //Magnet to brick if it's moving brickType* b=brickUnderCursor(&pf, cur.dx, cur.dy); if( !cur.lock && b ) { //Attach cursor cur.lock=1; b->curLock=1; cur.x=cur.dx; cur.y=cur.dy; cur.px = b->pxx-4; cur.py = b->pxy-4; sndPlay( SND_BRICKGRAB, cur.px ); } int movedBrick=0; //We're holding a brick, and it's not falling if( b ) { if( (goRight && curMoveBrick(&pf,b, DIRRIGHT)) || (goLeft && curMoveBrick(&pf,b, DIRLEFT)) ) { movedBrick=1; b->curLock=1; cur.lock=1; } } //Moved brick if(movedBrick) { player()->hsEntry.moves++; sndPlay(SND_BRICKMOVE, cur.px); ps.layer=PSYS_LAYER_TOP; ps.x=b->pxx; ps.y=b->pxy+18; ps.vel=50; ps.life=500; ps.lifeVar=250; ps.gravity=1; ps.srcImg=stealGfxPtr()->tiles[b->type-1]->img; ps.srcRect=stealGfxPtr()->tiles[b->type-1]->clip; ps.srcRect.y += 18; ps.srcRect.h = 2; spawnParticleSystem(&ps); } } else { cur.lock=0; } if(!cur.lock) { if( goLeft ) moveCursor(&cur, DIRLEFT, 0, lim); if( goRight ) moveCursor(&cur, DIRRIGHT, 0, lim); if( goUp ) moveCursor(&cur, 0, DIRUP, lim); if( goDown ) moveCursor(&cur, 0, DIRDOWN, lim); } //Sim first, so moving blocks get evaluated before getting moved again simField(&pf, &cur); //Do rules int ret=doRules(&pf); //Draw scene draw(&cur,&pf, screen); //Draw a path to show where we are pulling the brick if( mouseGrab ) drawPath( screen, getInpPointerState()->startX,getInpPointerState()->startY,getInpPointerState()->curX,getInpPointerState()->startY,1 ); //If no more bricks, countdown time left. if(ret == NOBRICKSLEFT) { if( !justWon ) { sndPlay(SND_WINNER,160); } justWon++; pf.levelInfo->time -= 1000; player()->hsEntry.score +=1; if(getButton(C_BTNX) || getButton(C_BTNB) || isPointerClicked() ) { resetBtn(C_BTNX); resetBtn(C_BTNB); resetMouseBtn(); while(pf.levelInfo->time > 0) { player()->hsEntry.score +=1; pf.levelInfo->time -= 1000; } } if(justWon > 50) { sndPlayOnce(SND_SCORECOUNT, 160); } if(pf.levelInfo->time < 1) { //Completed level player()->timeouts=0; pf.levelInfo->time=0; sndPlay(SND_VICTORY, 160); if(!player()->inEditor) { //Don't submit if it was from the leveleditor statsSubmitBest(); setMenu(menuStateFinishedLevel); if(pf.levelInfo->stopImg) { gameState=GAMESTATESTOPIMAGE; return(STATEPLAY); } } else { setLevelCompletable(pf.levelInfo->file, 1); } cleanUpGame(); startTransition(screen, TRANSITION_TYPE_ROLL_IN, 700); return(STATEMENU); } } else if(ret > 0) //Player destroyed bricks. { if(ret > 2) //Check for combo's { ///TODO: Some nice text effect? How about dissolving an image into a particle system? printf("%i Combo!\n",ret); player()->hsEntry.combos++; } player()->hsEntry.score += ret*ret*11*(player()->level+1); } //if ret > -1 then ret == number of bricks destroyed if(ret>-1) { //Update time: pf.levelInfo->time -= getTicks(); player()->hsEntry.time += getTicks(); if(pf.levelInfo->time < 1 && ret!=NOBRICKSLEFT ) { countdown=4000; gameState=GAMESTATEOUTOFTIME; if( !player()->inEditor ) { player()->timeouts++; } sndPlay(SND_TIMEOUT, 160); } } //Check if level is unsolvable. if(ret==UNSOLVABLE) { countdown=2000; gameState=GAMESTATEUNSOLVABLE; if( !player()->inEditor ) { player()->timeouts++; } sndPlay(SND_LOSER, 160); } else if(ret==LIFELOST) { countdown=2000; gameState=GAMESTATELIFELOST; if( !player()->inEditor ) { player()->timeouts++; } sndPlay(SND_LOSER, 160); } //Draw question if(restartConfirm) { sprintf(buf,STR_GAME_RESTARTWARNING); txtWriteCenter(screen, GAMEFONTMEDIUM, buf, HSCREENW, HSCREENH-20); sprintf(buf,STR_GAME_RESTARTCONFIRM); txtWriteCenter(screen, GAMEFONTSMALL, buf, HSCREENW, HSCREENH); } else { //Draw text drawUi(screen); } //Show the restart icon if(getInpPointerState()->timeSinceMoved<POINTER_SHOW_TIMEOUT && getInpPointerState()->escEnable) { SDL_Rect ptrRestartRectC = ptrRestartRect; SDL_BlitSurface( ptrRestart,NULL, screen, &ptrRestartRectC ); } } else if(gameState==GAMESTATECOUNTDOWN) { draw(&cur,&pf, screen); countdown -=getTicks(); if( getButton( C_BTNMENU ) ) { resetBtn( C_BTNMENU ); countdownSeconds=0; countdown=0; } if( (getButton( C_BTNX ) || getButton( C_BTNB ) || getInpPointerState()->isDown ) && countdownSeconds ) { countdownSeconds=0; countdown=500; } drawShowCountDown(screen, countdownSeconds); drawUi(screen); if(countdown < 1) { countdown=1000; countdownSeconds--; if(countdownSeconds == -1) { gameState=GAMESTATEPLAYING; return(STATEPLAY); } if(countdownSeconds==0) { countdown=500; sndPlay(SND_START, 160); } else { sndPlay(SND_COUNTDOWNTOSTART, 160); } } } else if(gameState==GAMESTATEOUTOFTIME) //Menu was last in "Entering level" so it will return to that if timeout { draw(&cur,&pf, screen); //drawUi(screen); countdown-=getTicks(); //Offer to skip after dying twice on same level, but only if it is not the last level in the pack. if( player()->timeouts > 1 && player()->level+1 < getNumLevels() ) { int skipLevel = skipLevelDialog(screen); if( skipLevel==1 ) { gameState=GAMESTATESKIPLEVEL; countdown=500; } txtWriteCenter(screen, GAMEFONTMEDIUM, STR_GAME_OUTOFTIME, HSCREENW,HSCREENH-24-31); } else { if( lostLifeMsg(&cur, &pf, screen, STR_GAME_OUTOFTIME, "lostlife-timeout" ) ) { return(STATEMENU); } } } else if(gameState==GAMESTATEUNSOLVABLE) //The same as out-of-time, but with another graphics. { draw(&cur,&pf, screen); //drawUi(screen); countdown-=getTicks(); //Offer to skip after dying twice on same level, but only if it is not the last level in the pack. if( player()->timeouts > 1 && player()->level+1 < getNumLevels() ) { int skipLevel = skipLevelDialog(screen); if( skipLevel==1 ) { gameState=GAMESTATESKIPLEVEL; countdown=500; } txtWriteCenter(screen, GAMEFONTMEDIUM, buf, HSCREENW,HSCREENH-24-31); } else { if( lostLifeMsg(&cur, &pf, screen, STR_GAME_UNSOLVABLE, "lostlife-unsolvable" ) ) { return(STATEMENU); } } } else if(gameState==GAMESTATELIFELOST) { if( lostLifeMsg(&cur, &pf, screen, STR_GAME_LOSTLIFE, "lostlife-evilbrick" ) ) { return(STATEMENU); } } else if(gameState==GAMESTATESTARTIMAGE) { if(!startStopImg) { startStopImgCounter=0; startStopImg = loadImg( packGetFile("themes/", pf.levelInfo->startImg) ); if(!startStopImg) { printf("Couldn't load '%s'\n",packGetFile("themes/", pf.levelInfo->startImg)); } } startStopImgCounter+=getTicks(); if((startStopImgCounter > 500 && ( getButton(C_BTNB) || isPointerClicked() ) ) || !startStopImg) { if(startStopImg) SDL_FreeSurface(startStopImg); startStopImg=0; resetBtn(C_BTNB); resetMouseBtn(); gameState=GAMESTATECOUNTDOWN; } SDL_BlitSurface( startStopImg, 0, screen, &(setting()->bgPos) ); if(startStopImgCounter>4000) txtWriteCenter(screen, GAMEFONTSMALL, STR_GAME_PRESSB, HSCREENW,HSCREENH+80); } else if(gameState==GAMESTATESTOPIMAGE) { if(!startStopImg) { startStopImgCounter=0; startStopImg = loadImg( packGetFile("themes/", pf.levelInfo->stopImg) ); if(!startStopImg) { printf("Couldn't load '%s'\n",packGetFile("themes/", pf.levelInfo->stopImg)); } } startStopImgCounter+=getTicks(); if((startStopImgCounter > 500 && (getButton(C_BTNB) || isPointerClicked() ) ) || !startStopImg) { if(startStopImg) SDL_FreeSurface(startStopImg); startStopImg=0; resetBtn(C_BTNB); resetMouseBtn(); cleanUpGame(); startTransition(screen, TRANSITION_TYPE_ROLL_IN, 700); return(STATEMENU); } SDL_BlitSurface( startStopImg, 0, screen, &(setting()->bgPos) ); if(countdownSeconds>4000) txtWriteCenter(screen, GAMEFONTSMALL, STR_GAME_PRESSB, HSCREENW,HSCREENH+80); } else if(gameState==GAMESTATESKIPLEVEL) { doRules(&pf); simField(&pf, &cur); draw(&cur,&pf, screen); countdown-=getTicks(); if( countdown < 1 ) { countdown=500; if( boardDestroyNextBrick(&pf) == 0 ) { //Tell that we chose to skip level statsUpload(player()->level, player()->hsEntry.time, player()->hsEntry.moves,player()->hsEntry.combos,player()->hsEntry.score, "skip-level",0, NULL); pf.levelInfo->time=0; player()->hsEntry.score=0; cleanUpGame(); startTransition(screen, TRANSITION_TYPE_ROLL_IN, 700); clearParticles(); setMenu(menuStatePrepareNextLevel); return(STATEMENU); } } drawUi(screen); } return(STATEPLAY); }
int runEditor(SDL_Surface* screen) { SDL_Rect selBrickRect; getInpPointerState()->escEnable=1; if( editorState == EDITOR_MAIN ) { if(getButton(C_BTNMENU) || isPointerEscapeClicked() ) { resetBtn( C_BTNMENU ); resetMouseBtn(); changed++; //If it was 0 then it will become 1 (saved) exit. If it was 1 it becomes 2 (not saved). if( changed != 2 ) { editorCleanUp(); startTransition(screen, TRANSITION_TYPE_ROLL_IN, 500 ); return(STATEMENU); } } //We detect if the "preview" brick on the left is clicked, we do this now so we can reset the click so that it does not hit the board selBrickRect.x = HSCREENW-125; selBrickRect.y = HSCREENH-85; selBrickRect.w = selBrickRect.x+20; selBrickRect.h = selBrickRect.y+20; //Also, we can only click it if a teleport destination is not being placed. if( isBoxClicked(&selBrickRect) && teleState==0 ) { editorState=EDITOR_BRICKS_SELECTION; resetMouseBtn(); } //We detect mouse-save input here so it won't hit the board. selBrickRect.x = HSCREENW-145; selBrickRect.y = HSCREENH+42; selBrickRect.w = selBrickRect.x+59; selBrickRect.h = selBrickRect.y+24; if( isBoxClicked(&selBrickRect) && changed>0) { changed=EDITOR_SAVEBTN_CLICKED; resetMouseBtn(); } //We check if the cursor is in the field (if it is not, brick-placement is blocked so we don't place bricks when clicking outside of the field). if( isPointerInBox(&fieldRect) || getInpPointerState()->timeSinceMoved > POINTER_SHOW_TIMEOUT ) { allowBrickToBePlaced=1; } else { allowBrickToBePlaced=0; } //Handle movement if(getButton(C_UP)) { resetBtn(C_UP); moveCursor(&cur, 0,DIRUP, 0); } if(getButton(C_DOWN)) { resetBtn(C_DOWN); moveCursor(&cur, 0,DIRDOWN,0); } if(getButton(C_LEFT)) { resetBtn(C_LEFT); moveCursor(&cur, DIRLEFT,0, 0); } if(getButton(C_RIGHT)) { resetBtn(C_RIGHT); moveCursor(&cur, DIRRIGHT,0, 0); } //Handle mouse input if( getInpPointerState()->timeSinceMoved==0 && !cur.lock ) { setCursor(&cur, getInpPointerState()->curX,getInpPointerState()->curY ); } if(getButton(C_BTNB)) { resetBtn(C_BTNB); selBrick++; if(selBrick==RESERVED) selBrick++; if(selBrick>NUMTILES) selBrick=1; } if(getButton(C_BTNA)) { resetBtn(C_BTNA); selBrick--; if(selBrick==RESERVED) selBrick--; if(selBrick<1) selBrick=NUMTILES; } //Is place brick button being pressed, and if it is, are we allowed to place the brick? if( (getButton(C_BTNX) || getInpPointerState()->isDown ) && selBrick != RESERVED && allowBrickToBePlaced ) { //We remove the brick before placing a new one if it's not a teleport or if it's a switch (not switch-target). if( selBrick!=TELESRC && !((editIsSwitch(selBrick)&&teleState==1) ) ) { editorRemoveBrickUnderCursor(); } if(selBrick==TELESRC || editIsSwitch(selBrick) ) { resetMouseBtn(); resetBtn(C_BTNX); if(teleState==0) { //Save source pos teleSrcPos[0] = cur.x; teleSrcPos[1] = cur.y; teleState++; } else { //Add to list if(editIsSwitch(selBrick)) { teleAddToList( pf.levelInfo->switchList, teleSrcPos[0], teleSrcPos[1], cur.x, cur.y ); //printf("Number of members in switchList: %i\n", listSize(pf.levelInfo->switchList) ); cur.x = teleSrcPos[0]; cur.y = teleSrcPos[1]; editAddToBoard(selBrick); } else { teleAddToList( pf.levelInfo->teleList, teleSrcPos[0], teleSrcPos[1], cur.x, cur.y ); } //Reset state teleState=0; } } else { editAddToBoard(selBrick); } //Not a teleport changed=1; } if( getButton(C_BTNY) ) { //If we are trying to remove an empty teleport if(telePresent(pf.levelInfo->teleList, cur.x, cur.y) && selBrick!=TELESRC) { resetBtn(C_BTNY); selBrick=TELESRC; } else { if(selBrick!=RESERVED) { editorPickBrickUnderCursor(); } editorRemoveBrickUnderCursor(); } } if( getInpPointerState()->isDown && selBrick==RESERVED ) { editorRemoveBrickUnderCursor(); } if(getButton(C_BTNSELECT) || changed==EDITOR_SAVEBTN_CLICKED) { resetBtn(C_BTNSELECT); FILE *f = fopen(fileName, "w"); int x,y; sprintf(buf, "#Author of level\nauthor=%s\n\n", pf.levelInfo->author); fputs(buf,f); sprintf(buf, "#Name of the level\nlevelname=%s\n\n", pf.levelInfo->levelName); fputs(buf,f); sprintf(buf, "#Seconds to complete level\nseconds=%i\n\n", pf.levelInfo->time); fputs(buf,f); sprintf(buf, "bgfile=%s\n", pf.levelInfo->bgFile); fputs(buf,f); sprintf(buf, "tilebase=%s\n", pf.levelInfo->tileBase); fputs(buf,f); sprintf(buf, "explbase=%s\n", pf.levelInfo->explBase); fputs(buf,f); sprintf(buf, "wallbase=%s\n", pf.levelInfo->wallBase); fputs(buf,f); sprintf(buf, "sounddir=%s\n", pf.levelInfo->soundDir); fputs(buf,f); sprintf(buf, "charbase=%s\n", pf.levelInfo->fontName); fputs(buf,f); sprintf(buf, "cursorfile=%s\n", pf.levelInfo->cursorFile); fputs(buf,f); sprintf(buf, "startimage=%s\n", (pf.levelInfo->startImg)?pf.levelInfo->startImg:"none"); fputs(buf,f); sprintf(buf, "stopimage=%s\n", (pf.levelInfo->stopImg)?pf.levelInfo->stopImg:"none"); fputs(buf,f); sprintf(buf, "showtelepath=%i\n", (pf.levelInfo->showTelePath) ); fputs(buf,f); sprintf(buf, "showswitchpath=%i\n", (pf.levelInfo->showSwitchPath) ); fputs(buf,f); //Teleports char* str = teleMkStrings(pf.levelInfo->teleList, "teleport"); if(str) //Returns 0 if there's no teleports { fputs("\n#Teleports\n",f); fputs(str,f); free(str); } //Switches str = teleMkStrings(pf.levelInfo->switchList, "switch"); if(str) //Returns 0 if there's no teleports { fputs("\n#Switches\n",f); fputs(str,f); free(str); } fputs("\n#The level-data block\n[data]",f); if(f) { for(y=0; y < FIELDSIZE; y++) { fputc('\n',f); for(x=0; x < FIELDSIZE; x++) { if(pf.board[x][y]) { fprintf(f,"%02i", pf.board[x][y]->type); } else { fprintf(f,"00"); } } } fputc('\n',f); changed=0; fclose(f); //Refresh the list of userLevels. addUserLevel(fileName); } } } //Editor in main state, don't ignore input draw(&cur, &pf, screen); if(changed==2) { txtWriteCenter(screen, FONTMEDIUM, STR_EDIT_NOT_SAVED_WARNING, HSCREENW,HSCREENH-20); txtWriteCenter(screen, FONTSMALL, STR_EDIT_PRESS_EXIT_TO_EXIT, HSCREENW,HSCREENH); txtWriteCenter(screen, FONTSMALL, STR_EDIT_PRESS_SAVE_TO_SAVE, HSCREENW,HSCREENH+10); } txtWriteCenter(screen, FONTSMALL,STR_EDIT_STATUS, HSCREENW-115,HSCREENH+80); txtWriteCenter(screen, FONTSMALL, (changed)?STR_EDIT_UNSAVED:STR_EDIT_SAVED, HSCREENW-115,HSCREENH+89); txtWriteCenter(screen, FONTSMALL,fileName, HSCREENW,HSCREENH+110); txtWriteCenter(screen, FONTSMALL,STR_EDIT_CONTROLS, HSCREENW,HSCREENH-120); //Write which keys are used to cycle selected brick. txtWriteCenter(screen, FONTSMALL,STR_EDIT_PREVBRICK_KEY,HSCREENW-142,HSCREENH-80); txtWriteCenter(screen, FONTSMALL,STR_EDIT_NEXTBRICK_KEY,HSCREENW-88,HSCREENH-80); //Draw the currently selected brick. drawBrick(screen, selBrick,HSCREENW-125,HSCREENH-85); //Write brick name. txtWriteCenter(screen, FONTSMALL, str_brick_names[selBrick], HSCREENW-116,HSCREENH-56 ); //Tell if we're placing teleport source or destination if(selBrick==TELESRC && teleState==0) { txtWriteCenter(screen, FONTSMALL, "(From)", HSCREENW-115,HSCREENH-41); } else if(teleState) { if(selBrick==TELESRC) { txtWriteCenter(screen, FONTSMALL, "(To)", HSCREENW-115,HSCREENH-41); } else { txtWriteCenter(screen, FONTSMALL, "(Target)", HSCREENW-115,HSCREENH-41); } drawPath(screen, teleSrcPos[0], teleSrcPos[1], cur.x, cur.y, 1); } //Draw all the telepaths. drawAllTelePaths(screen, pf.levelInfo->teleList); //Draw switchpath we hover above listItem* t = &pf.levelInfo->switchList->begin; while( LISTFWD(pf.levelInfo->switchList, t) ) { telePort_t* tp=(telePort_t*)t->data; if(cur.x == tp->sx && cur.y == tp->sy) { drawTelePath( screen, tp, 1 ); } } //Draw all switchpaths drawAllTelePaths(screen, pf.levelInfo->switchList); if( (getInpPointerState()->timeSinceMoved < POINTER_SHOW_TIMEOUT) && (changed > 0) ) { drawSprite(screen, saveBtnSprite, HSCREENW-145, HSCREENH+42 ); } //Draw brick-selection if( editorState == EDITOR_BRICKS_SELECTION ) { SDL_BlitSurface(selBrickBG , NULL, screen, &(setting()->bgPos) ); //Draw bricks in a 6*4 grid int px,py,bnum=BRICKSBEGIN; static int brickSelOfX = HSCREENW - 78 + 8; static int brickSelOfY = HSCREENH - 54 + 8; for(py=0;py < 4; py++) { for(px=0; px < 6; px++) { if( bnum > NUMTILES ) break; selBrickRect.x = brickSelOfX+(24*px); selBrickRect.y = brickSelOfY+(24*py); selBrickRect.w = selBrickRect.x+20; selBrickRect.h = selBrickRect.y+20; //We set bricks on mouseover, this way we get the description too (maybe punch a hole in the dots where the text is?) if( isPointerInBox(&selBrickRect) ) { selBrick=bnum; } //We continue back to the main editor if( isPointerClicked() ) { resetMouseBtn(); editorState=EDITOR_MAIN; } drawBrick(screen, bnum, selBrickRect.x, selBrickRect.y ); bnum++; } } } return(STATEEDIT); }
//------------------------------------------------------------------------------------- // This is the update callback function and is called at each update frame // before rendering. You should update the game logic here. // //------------------------------------------------------------------------------------- void GameApp::Update() { JGE* engine = JGE::GetInstance(); float dt = engine->GetDelta(); if (dt > 35.0f) // min 30 FPS ;) dt = 35.0f; scroller->Update(dt); timer+=dt; if (timer > 15) { startTransition(); timer = 0; }; transition+=(int)(dt * 300); if (transition > 255) endTransition(); if (gameToExtract.size()) { if (!subMenu) { switch(currentGameState) { case GAME_STATE_EXTRACTING_DONE: subMenu = new SimpleMenu(1, this,mFont,10,200, "installed to " + extractFolder); subMenu->Add(MENU_NO, "OK","", true); break; default: //TODO Check contents of file to see if it matches the zip format. subMenu = new SimpleMenu(1, this,mFont,10,200, "Do you want to install this homebrew?"); subMenu->Add(MENU_YES, "yes"); subMenu->Add(MENU_NO, "Cancel"); break; } } subMenu->Update(dt); switch(currentGameState) { case GAME_STATE_EXTRACTING: SAFE_DELETE(subMenu); ensureExtractFilesList(); if (extractError) { extractError = 0; currentGameState = GAME_STATE_EXTRACTING_CANCEL; return; } extractOneFile(); if (zipFiles.empty()) { currentZipFile.close(); loadFiles(base.c_str()); //reload menu to update folders currentGameState = GAME_STATE_EXTRACTING_DONE; } break; case GAME_STATE_EXTRACTING_CANCEL: SAFE_DELETE(subMenu); gameToExtract = ""; currentGameState = GAME_STATE_MENU; break; case GAME_STATE_EXTRACTING_DONE: break; default: break; } return; } menu->Update(dt); if (gameSelected == -2) { loadFiles(base.c_str()); gameSelected = -1; } if (gameSelected > -1) { engine->End(); return; } // exit when the TRIANGLE button is pressed if ( engine->GetButtonState(JGE_BTN_CANCEL)) { strcpy((char *)ebootPath, "quit"); engine->End(); return; } if ( engine->GetButtonState(JGE_BTN_PRI)) { JRenderer::GetInstance()->ScreenShot("ms0:/picture/wMenu.png"); } if ( engine->GetButtonState(JGE_BTN_PREV)) { base = "ms0:/PSP/SAVEDATA"; loadFiles(base.c_str()); return; } if ( engine->GetButtonState(JGE_BTN_NEXT)) { base = "ms0:/PSP/GAME"; loadFiles(base.c_str()); return; } }
void SceneManager::changeScene() { if(m_nextScene != NO_SCENE) { //delete the current scene if(m_currentScene) { if(m_g.isBuffering()) { startTransition(); } #ifdef CGE_MOBILE m_keyMan->hideKeyboard(); #endif m_currentScene->sceneEnd(); m_currentScene->deinitBaseScene(); #ifdef CGE_MOBILE m_keyMan->setScene(NULL); m_currentScene->getGui().removeTapListener(m_keyMan); #endif delete m_currentScene; m_currentScene = NULL; Log::write("Scene Manager","Scene Ended"); } m_currentSceneType = m_nextScene; //instance the requested scene switch(m_nextScene) { case SceneManagerMessage::GAME: m_currentScene = new GameScene(); Log::write("Scene Manager","Changed to Game Scene"); break; case SceneManagerMessage::LOBBY: m_currentScene = new LobbyScene(); Log::write("Scene Manager","Changed to Lobby Scene"); break; case SceneManagerMessage::LOGIN: m_currentScene = new LoginScene(); Log::write("Scene Manager","Changed to Login Scene"); break; } m_needFirstRender = true; m_nextScene = NO_SCENE; //set some class pointers m_currentScene->setGraphics(&m_g); m_currentScene->setDeviceManager(m_devices); m_currentScene->setDynamicUIManager(m_dynamicUI); m_currentScene->setGuiImageManager(&m_guiImageManager); m_currentScene->setSceneMessenger(this); m_currentScene->setGameTimer(m_gameTimer); m_currentScene->initBaseScene(); #ifdef CGE_MOBILE m_keyMan->setScene(m_currentScene); m_currentScene->getGui().addTapListener(m_keyMan); m_currentScene->getGui().setFocusEnabled(false); #endif m_currentScene->sceneBegin(); m_currentScene->resizeEvent( m_devices->getDisplay()->getResolution().getX(), m_devices->getDisplay()->getResolution().getY()); m_currentScene->initialResizeCompleted(); m_currentScene->sceneLogic(); m_currentScene->logic(); if(m_appResumed) { m_currentScene->appHasReturned(m_wasSignedIn); m_wasSignedIn = false; m_appResumed = false; } } }