int help_calc(Uint32 steps) { if ( spGetInput()->touchscreen.pressed ) { help_was_pressed = 1; int mx = spGetInput()->touchscreen.x; int my = spGetInput()->touchscreen.y; int i = 3; while (i --> 0 ) { if ( help_button[i].x + help_button[i].w >= mx && help_button[i].x <= mx && help_button[i].y + help_button[i].h >= my && help_button[i].y <= my ) { switch (i) { case 0: spMapSetByID(MAP_JUMP,1); break; case 1: spGetInput()->axis[1] = -1; break; case 2: spGetInput()->axis[1] = +1; break; } break; } } } else if (help_was_pressed) { help_was_pressed = 0; spGetInput()->axis[1] = 0; } if (spMapGetByID(MAP_JUMP) || spMapGetByID(MAP_CHAT) || spMapGetByID(MAP_MENU)) { spMapSetByID(MAP_JUMP,0); spMapSetByID(MAP_CHAT,0); spMapSetByID(MAP_MENU,0); spGetInput()->touchscreen.pressed = 0; spGetInput()->axis[1] = 0; return 1; } if (spGetInput()->axis[1] > 0) { help_scroll += steps * 32; if (help_scroll > SP_ONE) help_scroll = SP_ONE; } if (spGetInput()->axis[1] < 0) { help_scroll -= steps * 32; if (help_scroll < 0) help_scroll = 0; } return 0; }
void calc_music(int steps) { int i; for (i = 0;i<steps;i++) { show_music--; if (show_music < 0) show_music = 0; volume_wait--; if (volume_wait < 0) volume_wait = 0; if (spGetInput()->button[SP_BUTTON_VOLPLUS] && volume_wait<=0) { if (volume<100) volume++; set_volume(volume); volume_wait = 25; show_music = 1000; } if (spGetInput()->button[SP_BUTTON_VOLMINUS] && volume_wait<=0) { if (volume>0) volume--; set_volume(volume); volume_wait = 25; show_music = 1000; } } }
void calc_sprites(int steps) { if ( spGetInput()->button[SP_BUTTON_A] ) { spGetInput()->button[SP_BUTTON_A] = 0; sprites_z = 1-sprites_z; } spUpdateSprite( sprite, steps ); }
void calc_primitives() { if ( spGetInput()->button[SP_BUTTON_A] ) { spGetInput()->button[SP_BUTTON_A] = 0; primitives_z = 1-primitives_z; } if ( spGetInput()->button[SP_BUTTON_B] ) { spGetInput()->button[SP_BUTTON_B] = 0; primitives_blending = 1-primitives_blending; } }
int calc_splash(Uint32 steps) { splash_rotation+=steps*32; splash_counter -= steps; if (splash_counter <=0) return 1; PspInput engineInput = spGetInput(); if ((engineInput->button[SP_BUTTON_START] || engineInput->button[SP_BUTTON_A] || engineInput->button[SP_BUTTON_B] || engineInput->button[SP_BUTTON_X] || engineInput->button[SP_BUTTON_Y])) { engineInput->button[SP_BUTTON_START] = 0; engineInput->button[SP_BUTTON_A] = 0; engineInput->button[SP_BUTTON_B] = 0; engineInput->button[SP_BUTTON_X] = 0; engineInput->button[SP_BUTTON_Y] = 0; return 1; } //Update Rotation int i; for (i = 0; i < MESH_SIZE*2; i ++) { Sint32 rotation = -(splash_rotation*3 + i*SP_PI/MESH_SIZE/8); sparrow_mesh->texPoint[i].x = saved_points[i][0]; sparrow_mesh->texPoint[i].y = spMul(spCos(rotation),saved_points[i][1]) + spMul(spSin(rotation),saved_points[i][2]); sparrow_mesh->texPoint[i].z = spMul(spSin(rotation),saved_points[i][1]) + spMul(spCos(rotation),saved_points[i][2]); rotation += SP_PI; logo_mesh->texPoint[i].x = saved_points[i][0]; logo_mesh->texPoint[i].y = spMul(spCos(rotation),saved_points[i][1]) + spMul(spSin(rotation),saved_points[i][2]); logo_mesh->texPoint[i].z = spMul(spSin(rotation),saved_points[i][1]) + spMul(spCos(rotation),saved_points[i][2]); } return 0; }
int calc_function( Uint32 steps ) { rotation += steps * 32; if ( spGetInput()->button[SP_BUTTON_START] ) return 1; return 0; }
int StateScore::update( Uint32 delta ) { StateBase::update( delta ); if ( caretTimer.stopped() && state == 0 ) { caret = !caret; caretTimer.start( SCORE_CARET_BLINK_TIME ); } if ( spGetInput()->button[SP_BUTTON_START] #ifdef MOBILE_DEVICE || spGetInput()->button[SP_BUTTON_B] || spGetInput()->button[SP_BUTTON_Y] #endif || name[strlen(name)-1] == '\n' // Enter key was pressed ) { if ( state == 0 && name[0] != 0 ) { spResetButtonsState(); spStopKeyboardInput(); state = 1; caret = false; if (name[strlen(name)-1] == '\n') name[strlen(name)-1] = '\0'; file.addScore( name, score, run->info.timecode ); if ( run ) { run->info.name = name; run->info.score = score; run->saveToFile( FOLDER_REPLAY "/" + Utility::numToStr( run->info.timecode ) + EXTENSION_REPLAY ); } } else { spResetButtonsState(); spStopKeyboardInput(); return stMenu; } } return 0; }
int calc_function(Uint32 steps) { //update rotation counter rotation+=steps*32; //if "Start" (or "Menu" for Wiz or "Home" for Caanoo or "Return" at the P) is //pressed: exit if (spGetInput()->button[SP_BUTTON_START]) return 1; return 0; }
int do_control_stuff() { //Controls and some Logic (more in feedback.c) if (spGetInput()->button[get_next_button()]) { spGetInput()->button[get_next_button()] = 0; level->choosenPlayer = level->choosenPlayer->prev; } if (spGetInput()->button[get_prev_button()]) { spGetInput()->button[get_prev_button()] = 0; level->choosenPlayer = level->choosenPlayer->next; } if (spGetInput()->button[get_push_button()]) { spGetInput()->button[get_push_button()] = 0; pPhysicsElement element = getFirstMoveableElement(); if (element) do { if (element->type == SWITCH && element->had_collision_with_choosen_player) { element->levelObject->state = 1-element->levelObject->state; if (element->levelObject->state) spSelectSprite(element->levelObject->animation,"on"); else spSelectSprite(element->levelObject->animation,"off"); } element = element->next; } while (element != getFirstMoveableElement()); } if (spGetInput()->axis[1] < 0) { spGetInput()->axis[1] = 0; pPhysicsElement element = getFirstMoveableElement(); if (element) do { if (element->type == DOOR && element->had_collision_with_choosen_player) { printf("Sprich Freund und tritt ein!\n"); sprintf(get_saved_level(),"./level/%s",element->levelObject->some_char); return 1; } element = element->next; } while (element != getFirstMoveableElement()); } return 0; }
int StateMenu::update(Uint32 delta) { StateBase::update( delta ); if ( inputLag.isStopped() ) { if ( spGetInput()->axis[1] > 0 ) choice = std::min( --choice, entries.size()-1 ); else if ( spGetInput()->axis[1] < 0 ) { ++choice; if ( choice > entries.size()-1 ) choice = 0; } inputLag.start( MENU_INPUT_LAG ); } if ( spGetInput()->axis[1] == 0 ) { inputLag.stop(); } if ( spGetInput()->button[SP_BUTTON_B] || spGetInput()->button[SP_BUTTON_Y] || spGetInput()->button[SP_BUTTON_START] ) { spResetButtonsState(); if ( entries[choice].targetState == stWave ) message = "waves/test.txt"; return entries[choice].targetState; } return 0; }
int StateHighscores::update(Uint32 delta) { StateBase::update( delta ); if ( inputLag.stopped() ) { if ( spGetInput()->axis[1] > 0 && selOffset > 0 ) { --selOffset; --selectionIter; if ( selOffset - drawOffset < HIGHS_ENTRIES_ON_SCREEN / 2 && drawOffset > 0 ) { --drawOffset; --offsetIter; } } else if ( spGetInput()->axis[1] < 0 && selOffset < (int)file.scores.size()-1 ) { ++selOffset; ++selectionIter; if ( selOffset - drawOffset > HIGHS_ENTRIES_ON_SCREEN / 2 && drawOffset < (int)file.scores.size() - HIGHS_ENTRIES_ON_SCREEN ) { ++drawOffset; ++offsetIter; } } inputLag.start( lagTime ); } if ( spGetInput()->axis[1] == 0 ) { inputLagSwitch.stop(); inputLag.stop(); } else { if ( inputLagSwitch.stopped() ) inputLagSwitch.start(); else lagTime = std::max( HIGHS_MIN_INPUT_LAG, HIGHS_MAX_INPUT_LAG - inputLagSwitch.getTime() / HIGHS_LAG_TIMER * HIGHS_STEP_INPUT_LAG ); } if ( spGetInput()->button[ SP_BUTTON_START ] ) { return stMenu; } if ( (spGetInput()->button[ SP_BUTTON_B ] || spGetInput()->button[ SP_BUTTON_Y ]) && !file.scores.empty() ) { message = FOLDER_REPLAY "/" + Utility::numToStr( selectionIter->timestamp ) + EXTENSION_REPLAY; return stReplay; } return 0; }
int calc_schizo( Uint32 steps ) { //Finish? if ( spGetInput()->button[SP_BUTTON_START] ) return 1; //Ingame controls if (do_control_stuff()) //result is non zero => level change levelFade = -FADE_TIME; if ( levelFade > 0 ) //Fade in { levelFade -= steps; if (levelFade < 0) levelFade = 0; else return 0; } if ( levelFade < 0 ) //Fade out { levelFade += steps; if (levelFade > 0) { levelFade = FADE_TIME; clearPhysics(); deleteLevel((*levelPointer)); (*levelPointer) = loadLevel(get_saved_level()); createPhysicsFromLevel((*levelPointer)); } else return 0; } //Physics int i; for (i = 0; i < steps; i++) doPhysics(*levelPointer); //Visualization stuff rotation+=steps*16; updateLevelObjects(); updateLevelSprites((*levelPointer),steps); calcCamera((*levelPointer),steps); return 0; }
int calc_function( Uint32 steps ) { //update rotation counter rotation += steps * 32; //if "Start" (or "Menu" for Wiz or "Home" for Caanoo or "Return" at the P) is //pressed: exit if ( spGetInput()->button[SP_BUTTON_START] ) return 1; //Update the sprite (next picture) spUpdateSprite( sprite, steps ); //rotozoom the sprite (without rotozoom it's faster): sprite->zoomX = spSin( rotation * 8 ) / 2 + ( 3 << SP_ACCURACY - 1 ); sprite->zoomY = spCos( rotation * 6 ) / 2 + ( 3 << SP_ACCURACY - 1 ); sprite->rotation = rotation * 4; return 0; }
void yHit( pPhysicsElement element,int pos) { if (element->levelObject == level->choosenPlayer) { //Other half of the Y-Movement stuff if (pos == -1) { if (spGetInput()->button[get_jump_button()]) { if ( element->player.in_jump == 0 && element->player.can_jump) // start the jump element->player.in_jump = 1; } else element->player.in_jump = 0; } if (pos == 1 && element->player.can_jump) //collision on top { // start turn-around element->player.in_jump = JUMP_UPWARDS_TIME; element->player.can_jump = 0; } } }
int calc_account(Uint32 steps) { blink+=steps; if (spNetC4AGetStatus() > 0) { right_after_status = 1; return 0; } if (right_after_status) { if (spNetC4AGetTaskResult() == 0) { mode = nextMode; askMode = last_task+7; } else { askMode = 6; spStopKeyboardInput(); } } right_after_status = 0; if (askMode) { switch ( askMode ) { case 1: if ( spGetInput()->button[SP_BUTTON_START_NOWASD] ) { spGetInput()->button[SP_BUTTON_START_NOWASD] = 0; if (spNetC4ADeleteAccount(&profile,1,TIME_OUT) == 0) { right_after_status = 1; last_task = 2; } nextMode = 0; sprintf(longName,""); sprintf(shortName,""); sprintf(password,""); sprintf(mail,""); askMode = 0; switch (line) { case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break; case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break; } } if ( spGetInput()->button[SP_PRACTICE_CANCEL_NOWASD] ) { spGetInput()->button[SP_PRACTICE_CANCEL_NOWASD] = 0; askMode = 0; switch (line) { case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break; case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break; } } break; default: if ( spGetInput()->button[SP_PRACTICE_OK_NOWASD] ) { spGetInput()->button[SP_PRACTICE_OK_NOWASD] = 0; askMode = 0; switch (line) { case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break; case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break; } } } return 0; } if ( spGetInput()->button[SP_PRACTICE_CANCEL_NOWASD] ) { spGetInput()->button[SP_PRACTICE_CANCEL_NOWASD] = 0; spStopKeyboardInput(); return 1; } int i; for (i = 0; shortName[i] != 0; i++) { if ('a' <= shortName[i] && shortName[i] <= 'z') shortName[i] += 'A'-'a'; } if ((spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS && spGetInput()->button[SP_BUTTON_R_NOWASD]) || (spGetVirtualKeyboardState() != SP_VIRTUAL_KEYBOARD_ALWAYS && spGetInput()->axis[1] > 0)) { line = (line + 1) % 4; spGetInput()->button[SP_BUTTON_R_NOWASD] = 0; if (spGetVirtualKeyboardState() != SP_VIRTUAL_KEYBOARD_ALWAYS) spGetInput()->axis[1] = 0; blink = 0; switch (line) { case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break; case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break; } } if ((spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS && spGetInput()->button[SP_BUTTON_L_NOWASD]) || (spGetVirtualKeyboardState() != SP_VIRTUAL_KEYBOARD_ALWAYS && spGetInput()->axis[1] < 0)) { line = (line + 3) % 4; spGetInput()->button[SP_BUTTON_L_NOWASD] = 0; if (spGetVirtualKeyboardState() != SP_VIRTUAL_KEYBOARD_ALWAYS) spGetInput()->axis[1] = 0; blink = 0; switch (line) { case 0: spPollKeyboardInput(shortName,3,SP_PRACTICE_OK_NOWASD_MASK); break; case 1: spPollKeyboardInput(longName,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 2: spPollKeyboardInput(password,256,SP_PRACTICE_OK_NOWASD_MASK); break; case 3: spPollKeyboardInput(mail,256,SP_PRACTICE_OK_NOWASD_MASK); break; } } if ( spGetInput()->button[SP_BUTTON_START_NOWASD] ) { spGetInput()->button[SP_BUTTON_START_NOWASD] = 0; if (check_shortname()) { askMode = 2; spStopKeyboardInput(); } else if (check_longname()) { askMode = 3; spStopKeyboardInput(); } else if (check_password()) { askMode = 4; spStopKeyboardInput(); } else if (check_mail()) { askMode = 5; spStopKeyboardInput(); } else { if (mode == 0) { if (spNetC4ACreateProfile(&profile,longName,shortName,password,mail,TIME_OUT) == 0) { right_after_status = 1; last_task = 0; } nextMode = 1; } else { if (spNetC4AEditProfile(&profile,longName,shortName,password,mail,TIME_OUT) == 0) { right_after_status = 1; last_task = 1; } nextMode = 1; } } } if ( mode == 1 && spGetInput()->button[SP_BUTTON_SELECT_NOWASD] ) { spGetInput()->button[SP_BUTTON_SELECT_NOWASD] = 0; askMode = 1; spStopKeyboardInput(); } return 0; }
void setSpeed( pPhysicsElement element ) { if (element->levelObject == NULL) return; if (element->type == PLATFORM) { //is platform enabled? int was_enabled = element->platform_enabled; element->platform_enabled = 1; pLevelObject groupElement = element->levelObject->group->firstObject; if (groupElement) do { if (groupElement->type == BUTTON || groupElement->type == SWITCH) { if (groupElement->kind) //negative { if (groupElement->state == ON) { element->platform_enabled = 0; break; } } else { if (groupElement->state == OFF) { element->platform_enabled = 0; break; } } } groupElement = groupElement->next; } while (groupElement != element->levelObject->group->firstObject); if (element->levelObject->kind == 1) { if (element->platform_enabled) { if (element->had_collision) element->levelObject->direction = 1 - element->levelObject->direction; if (element->levelObject->direction == 0) { element->speed.x += element->levelObject->speed.v1.x; element->speed.y += element->levelObject->speed.v1.y; } else { element->speed.x = element->levelObject->speed.v2.x; element->speed.y = element->levelObject->speed.v2.y; } } } else { if (element->platform_enabled != was_enabled) element->paterNoster_is_on = 1; if (element->paterNoster_is_on) { if (element->platform_enabled) { element->speed.x += element->levelObject->speed.v1.x; element->speed.y += element->levelObject->speed.v1.y; } else { element->speed.x = element->levelObject->speed.v2.x; element->speed.y = element->levelObject->speed.v2.y; } } } } else if (element->type == PLAYER) { if (element->levelObject == level->choosenPlayer) { //Half of the Y-Movement stuff if ( !spGetInput()->button[get_jump_button()] ) { if ( element->player.in_jump >= JUMP_MIN_TIME && element->player.can_jump ) // start turn-around { element->player.in_jump = JUMP_UPWARDS_TIME; element->player.can_jump = 0; } if ( element->player.in_jump == 0 ) // allow another jump only after another press of the button element->player.can_jump = 1; } //Moving the player X if (spGetInput()->axis[0] < 0) { if (element->player.last_run >= 0) element->player.last_run = 0; element->player.last_run-=1; if (element->player.last_run > -(MAX_MOVEMENT_FORCE / MOVEMENT_ACCEL)) element->speed.x = element->player.last_run*MOVEMENT_ACCEL; else element->speed.x = -MAX_MOVEMENT_FORCE; } else if (spGetInput()->axis[0] > 0) { if (element->player.last_run <= 0) element->player.last_run = 0; element->player.last_run+=1; if (element->player.last_run < (MAX_MOVEMENT_FORCE / MOVEMENT_ACCEL)) element->speed.x = element->player.last_run*MOVEMENT_ACCEL; else element->speed.x = MAX_MOVEMENT_FORCE; } } //For every player: if (element->player.in_jump) { if (element->player.in_jump < JUMP_UPWARDS_TIME) // moving upwards { element->player.in_jump++; element->speed.y-=JUMP_FORCE; element->freeFallCounter = 0; } else if (element->player.in_jump < JUMP_END_TIME) // smooth turn-around (peak of jump) { element->player.in_jump++; element->speed.y-=GRAVITY_MAX*(JUMP_END_TIME-element->player.in_jump)/(JUMP_END_TIME-JUMP_UPWARDS_TIME); element->freeFallCounter = 0; element->player.can_jump = 0; } else // end jump { element->player.in_jump = 0; element->player.can_jump = 0; } } selectCorrectSprite(element); } if (element->type == BUTTON) { if (element->had_collision) { if (element->levelObject->state == OFF) spSelectSprite(element->levelObject->animation,"on"); element->levelObject->state = ON; } else { if (element->levelObject->state == ON) spSelectSprite(element->levelObject->animation,"off"); element->levelObject->state = OFF; } } }