/** * @brief Notifies this entity that it has just attacked an enemy. * * This function is called even if this attack was not successful. * * @param attack the attack * @param victim the enemy just hurt * @param result indicates how the enemy has reacted to the attack * @param killed indicates that the attack has just killed the enemy */ void Hookshot::notify_attacked_enemy(EnemyAttack attack, Enemy& victim, EnemyReaction::Reaction& result, bool killed) { if (result.type != EnemyReaction::IGNORED && !is_going_back()) { go_back(); } }
G_MODULE_EXPORT void go_up (GtkToolButton *toolbutton, gpointer user_data) { go_back(mainwindow); }
/** * @brief Updates this entity. */ void Hookshot::update() { MapEntity::update(); if (suspended) { return; } uint32_t now = System::now(); if (now >= next_sound_date) { Sound::play("hookshot"); next_sound_date = now + 150; } if (entity_reached == NULL) { if (!going_back) { if (has_to_go_back) { going_back = true; Movement *movement = new TargetMovement(&get_hero(), 192, true); clear_movement(); set_movement(movement); } else if (get_distance(get_hero()) >= 120) { go_back(); } } else if (get_distance(get_hero()) == 0 || (get_movement() != NULL && get_movement()->is_finished())) { remove_from_map(); get_hero().start_state_from_ground(); } } }
/** * @brief This function is called when a crystal detects a collision with this entity. * @param crystal the crystal * @param collision_mode the collision mode that detected the event */ void Hookshot::notify_collision_with_crystal(Crystal& crystal, CollisionMode collision_mode) { if (is_flying()) { crystal.activate(*this); if (!is_going_back()) { go_back(); } } }
/** * \brief This function is called when a crystal detects a collision with this entity. * \param crystal the crystal * \param collision_mode the collision mode that detected the event */ void Boomerang::notify_collision_with_crystal(Crystal &crystal, CollisionMode collision_mode) { if (collision_mode == COLLISION_RECTANGLE) { crystal.activate(*this); if (!is_going_back()) { go_back(); } } }
/** * \brief This function is called when a switch detects a collision with this entity. * \param sw the switch * \param collision_mode the collision mode that detected the event */ void Hookshot::notify_collision_with_switch(Switch& sw, CollisionMode collision_mode) { if (is_flying() && collision_mode == COLLISION_OVERLAPPING) { sw.try_activate(); if (!is_going_back()) { go_back(); Sound::play("sword_tapping"); } } }
/** * \brief This function is called when the movement of the entity is finished. */ void Boomerang::notify_movement_finished() { if (!is_going_back()) { // the maximum distance is reached go_back(); } else { // the boomerang is back remove_from_map(); } }
/** * \brief This function is called when a switch detects a collision with this entity. * \param sw the switch * \param collision_mode the collision mode that detected the event */ void Boomerang::notify_collision_with_switch(Switch& sw, CollisionMode collision_mode) { if (collision_mode == COLLISION_RECTANGLE) { sw.try_activate(); if (!is_going_back()) { go_back(); Sound::play("sword_tapping"); } } }
/** * @brief Notifies this entity that it has just failed to change its position * because of obstacles. */ void Hookshot::notify_obstacle_reached() { if (is_flying()) { if (!get_map().test_collision_with_border( get_movement()->get_last_collision_box_on_obstacle())) { // play a sound unless the obstacle is the map border Sound::play("sword_tapping"); } go_back(); } }
/** * \copydoc MapEntity::notify_attacked_enemy */ void Boomerang::notify_attacked_enemy( EnemyAttack attack, Enemy& victim, const Sprite* victim_sprite, EnemyReaction::Reaction& result, bool killed) { if (result.type != EnemyReaction::IGNORED && !is_going_back()) { go_back(); } }
/** * \copydoc Entity::notify_attacked_enemy */ void Boomerang::notify_attacked_enemy( EnemyAttack /* attack */, Enemy& /* victim */, const Sprite* /* victim_sprite */, EnemyReaction::Reaction& result, bool /* killed */) { if (result.type != EnemyReaction::ReactionType::IGNORED && !is_going_back()) { go_back(); } }
/** * @brief This function is called when a destructible item detects a non-pixel precise collision with this entity. * @param destructible the destructible item * @param collision_mode the collision mode that detected the event */ void Hookshot::notify_collision_with_destructible(Destructible& destructible, CollisionMode collision_mode) { if (destructible.is_obstacle_for(*this) && is_flying()) { if (destructible.can_explode()) { destructible.explode(); go_back(); } else { attach_to(destructible); } } }
void recipe_select::on_pushButtonBack_clicked() { /* we are at main level, go to the previous page */ if (strcmp(_recipe_dir_to_browse, RECIPE_DIR) == 0) { go_back(); } /* we aren't at main level, go to previus level */ else { strcpy(_recipe_dir_to_browse, RECIPE_DIR); reload(); } }
/* @history_funcs{"back"} */ static JSBool history_back(JSContext *ctx, unsigned int argc, jsval *rval) { struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx); struct document_view *doc_view = interpreter->vs->doc_view; struct session *ses = doc_view->session; go_back(ses); /* history_back() must return 0 for onClick to cause displaying previous page * and return non zero for <a href="javascript:history.back()"> to prevent * "calculating" new link. Returned value 2 is changed to 0 in function * spidermonkey_eval_boolback */ JS_SET_RVAL(ctx, rval, JSVAL_NULL); return 2; }
Destroy_frame() { static int i; for (i=frame; i<maxframe; i++) { periods[frame] = periods[frame+1]; indices[frame] = indices[frame+1]; perind[frame] = perind[frame+1]; a_minimums[frame] = a_minimums[frame+1]; b_minimums[frame] = b_minimums[frame+1]; a_maximums[frame] = a_maximums[frame+1]; b_maximums[frame] = b_maximums[frame+1]; } if (maxframe) maxframe--; go_back(); }
int fm_snippet(fm_index *s, ulong row, ulong plen, ulong clen, uchar *dest, ulong *snippet_length) { ulong back, forw, i; /* --- get clen chars preceding the current position --- */ back = go_back(s, row, clen, dest+clen); assert(back <= clen); /* --- get plen+clen chars from the current position --- */ forw = go_forw(s, row, clen+plen, dest+back); assert(forw <= clen+plen); if(forw<plen) return FM_GENERR; *snippet_length = back+forw; return FM_OK; }
/*! Scrolls the credits text up the screen. \author jfpatry \date Created: 2000-09-27 \date Modified: 2000-09-27 */ static void draw_credits_text( scalar_t time_step ) { int w = getparam_x_resolution(); int h = getparam_y_resolution(); font_t* font; coord_t text_coord; int i, string_w, asc, desc; scalar_t y; y_offset += time_step * winsys_scale(CREDITS_SPEED + time_step*joystick_y*CREDITS_JOYSTICK_SPEED); if (y_offset<0) { y_offset=0; } y = CREDITS_MIN_Y+y_offset; text_coord.x=w/2; text_coord.y=y; text_coord.x_coord_type=ABSOLUTE_COORD; text_coord.y_coord_type=ABSOLUTE_COORD; text_coord.x_just=text_coord.y_just=CENTER_JUST; for (i=0; i<sizeof( credit_lines ) / sizeof( credit_lines[0] ); i++) { credit_line_t line = credit_lines[i]; if ( !get_font_binding( line.binding, &font ) ) { print_warning( IMPORTANT_WARNING, "Couldn't get font for binding %s", line.binding ); } else { get_font_metrics( font, line.text, &string_w, &asc, &desc ); text_coord.y -= asc+desc; GameMenu_draw_text( line.text, 0, text_coord, line.binding ); } } if ( text_coord.y > h+CREDITS_MAX_Y ) { go_back(); } }
/** * \brief Updates this entity. */ void Hookshot::update() { MapEntity::update(); if (is_suspended()) { return; } uint32_t now = System::now(); if (now >= next_sound_date) { Sound::play("hookshot"); next_sound_date = now + 150; } if (entity_reached == nullptr) { if (!going_back) { if (has_to_go_back) { going_back = true; std::shared_ptr<Movement> movement = std::make_shared<TargetMovement>( std::static_pointer_cast<Hero>(get_hero().shared_from_this()), 0, 0, 192, true ); clear_movement(); set_movement(movement); } else if (get_distance(get_hero()) >= 120) { go_back(); } } else if (get_distance(get_hero()) == 0 || (get_movement() != nullptr && get_movement()->is_finished())) { remove_from_map(); get_hero().start_state_from_ground(); } } }
static HRESULT WINAPI InternetExplorer_GoBack(IWebBrowser2 *iface) { InternetExplorer *This = impl_from_IWebBrowser2(iface); TRACE("(%p)\n", This); return go_back(&This->doc_host->doc_host); }
/****************************************************************** * Main-function */ int main(void) { /************************************** * Set the clock to run at 80 MHz */ SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); /************************************** * Enable the floating-point-unit */ FPUEnable(); // We also want Lazystacking, so enable that too FPULazyStackingEnable(); // We also want to put numbers close to zero to zero FPUFlushToZeroModeSet(FPU_FLUSH_TO_ZERO_EN); /************************************** * Init variables */ uint16_t mapData[MAP_DATA_SIZE]; uint8_t stepDir = 0; /************************************** * Init peripherals used */ bluetooth_init(); init_stepper(); // Init the GPIOs used for the stepper and loading LED InitI2C1(); // Init the communication with the lidar-unit through I2C InitPWM(); setupTimers(); /************************************** * State 2 */ // Disable the timers that are used disableTimer(TIMER1_BASE); disableTimer(TIMER2_BASE); // Enable all interrupts IntMasterEnable(); /************************************** * State 3 */ // Indicate we should start with a scan regardless of what other things we have already got // from UART-interrupt // This means setting the appropriate bit in the status vector stat_vec |= TAKE_MEAS; /************************************** * State 4 */ // Contains main-loop where decisions should be made for ( ; ; ) { /********************************** * Decision tree */ // Highest priority case first // Check both interrupts at each iteration in the loop if ( int_vec & UART_INT ) { // Reset the indication int_vec &= ~UART_INT; // Remove drive-stop flag to enable movement stat_vec &= ~DRIVE_STOP; // Init data array uint8_t dataArr[MAX_UART_MSG_SIZE]; // Collect the message if ( readUARTMessage(dataArr, MAX_UART_MSG_SIZE) < SUCCESS ) { // If we have recieved more data than fits in the vector we should simply // go in here again and grab data int_vec |= UART_INT; } // We have gathered a message // and now need to determine what the message is parseMsg(dataArr, MAX_UART_MSG_SIZE); } // Checking drive (movement) interrupt if ( int_vec & TIMER2_INT ) { int_vec &= ~TIMER2_INT; // Disable TIMER2 disableTimer(TIMER2_BASE); // Set drive-stop in status vector stat_vec |= DRIVE_STOP; } // Checking measure interrupt if ( int_vec & TIMER1_INT ) { int_vec &= ~TIMER1_INT; // Disable TIMER1 disableTimer(TIMER1_BASE); // Take reading from LIDAR mapData[stepCount++] = readLidar(); SysCtlDelay(2000); // Take step // Note: We need to take double meas at randvillkor (100) !!!!! if ( stepCount > 0 && stepCount < 100 ) { stepDir = 1; } else if ( stepCount >= 100 && stepCount < 200) { stepDir = 0; } else { stepDir = 1; stepCount = 0; // Reset busy-flag stat_vec &= ~TAKE_MEAS; } step = takeStep(step, stepDir); // Request reading from LIDAR reqLidarMeas(); if ( stat_vec & TAKE_MEAS ) { // Restart TIMER1 enableTimer(TIMER1_BASE, (SYSCLOCK / MEASUREMENT_DELAY)); } else { sendUARTDataVector(mapData, MAP_DATA_SIZE); stat_vec &= ~BUSY; } } // Check the drive_stop flag, which always should be set unless we should move if ( stat_vec & DRIVE_STOP ) { // Stop all movement SetPWMLevel(0,0); halt(); // MAKE SURE all drive-flags are not set stat_vec &= ~(DRIVE_F | DRIVE_L | DRIVE_R | DRIVE_LL | BUSY); } // Should we drive? else if ( stat_vec & DRIVE ) { // Remove drive flag stat_vec &= ~DRIVE; // Increase PWM increase_PWM(0,MAX_FORWARD_SPEED,0,MAX_FORWARD_SPEED); if ( stat_vec & DRIVE_F ) { enableTimer(TIMER2_BASE, DRIVE_FORWARD_TIME); } else if ( stat_vec & DRIVE_LL ) { enableTimer(TIMER2_BASE, DRIVE_TURN_180_TIME); } else { enableTimer(TIMER2_BASE, DRIVE_TURN_TIME); } } if ( !(stat_vec & BUSY) ) { // Tasks switch ( stat_vec ) { case ((uint8_t)DRIVE_F) : // Call drive function go_forward(); // Set the drive flag & BUSY stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_L) : // Call drive-left function go_left(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_R) : // Call drive-right function go_right(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_LL) : // Call turn 180-degrees function go_back(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)TAKE_MEAS) : // Request reading from LIDAR reqLidarMeas(); // Start TIMER1 enableTimer(TIMER1_BASE, (SYSCLOCK / MEASUREMENT_DELAY)); // if sysclock = 1 s, 1/120 = 8.3 ms // We are busy stat_vec |= BUSY; break; default: break; } } } }
void alarms_history::on_pushButtonBack_clicked() { go_back(); }
void display_settings::on_pushButtonBack_clicked() { go_back(); }
/*! Joystick button event callback \author nopoe \date Created: 2013-10-08 \date Modified: 2013-10-08 */ void credits_joystick_button_func(int button) { go_back(); }
void move() { int i; /*variable to use in figuring out the "best" option*/ int max_q_score = 0; /*what do we do next? store it here*/ /*we init to -1 as an error*/ int next_movement = -1; /*Where we started.*/ /*We don't use ROTATION_2 all the way through in case it changes.*/ int initial_angle = norm_rotation(ROTATION_2); /*Where we ended up.*/ int new_angle; /*Show the current angle*/ cputc_native_user(CHAR_A, CHAR_N, CHAR_G, CHAR_L); // ANGL msleep(200); lcd_int(initial_angle); msleep(500); /* * Most of the time, we do the "correct" thing * by finding the best q_score of our possible options. * On the off chance that norm_random() is low (or EPSILON is high ;) * we then "explore" by choosing a random movement. */ if(norm_random() > EPSILON_CURRENT) { /*We are doing what the table tells us to.*/ cputc_native_user(CHAR_r, CHAR_e, CHAR_a, CHAR_l); // real msleep(500); for(i=0; i<MOVEMENTS; i++) { if(q_score[initial_angle][i] > max_q_score) { max_q_score = q_score[initial_angle][i]; next_movement = i; } } } else { double temp; /*We are just picking something at random.*/ cputc_native_user(CHAR_r, CHAR_a, CHAR_n, CHAR_d); // rand msleep(500); /*pick one. Any one.*/ temp = norm_random(); next_movement = temp*MOVEMENTS; /*show what we do next*/ lcd_int(next_movement); sleep(1); } /*what happens if next_movement never gets changed?*/ /*we'd hate to do HARD_LEFT over and over again*/ /*so we choose randomly*/ if(-1==next_movement) { double temp; temp = norm_random(); next_movement = temp*MOVEMENTS; } /*having chosen a movement, lets do it*/ switch(next_movement) { case HARD_LEFT: cputc_native_user(CHAR_H, CHAR_L, 0, 0); // HL hard_left(); break; case SOFT_LEFT: cputc_native_user(CHAR_S, CHAR_L, 0, 0); // SL soft_left(); break; case FORWARD: cputc_native_user(CHAR_F, CHAR_W, CHAR_W, CHAR_D); // FWD go_forward(); break; case SOFT_RIGHT: cputc_native_user(CHAR_S, CHAR_R, 0, 0); // SR soft_right(); break; case HARD_RIGHT: cputc_native_user(CHAR_H, CHAR_R, 0, 0); // HR hard_right(); break; case REVERSE: cputc_native_user(CHAR_R, CHAR_E, CHAR_V, 0); // REV go_back(); break; default: /*this is an error and should never be reached*/ cputc_native_user(CHAR_E, CHAR_R, CHAR_R, 0); // ERR stop_motors(); sleep(1); break; } /*Once we've started, we'd better stop*/ stop_motors(); /*Allows us to read direction*/ msleep(500); /*This is here just to make the next function cleaner*/ new_angle = norm_rotation(ROTATION_2); /*Where are we now?*/ cputc_native_user(CHAR_N, CHAR_E, CHAR_W, CHAR_W); // NEW msleep(200); lcd_int(new_angle); msleep(500); /* * Since we know that "next_movement" took us from "initial_angle" * to new_angle (ROTATION_2), we store that increased probability. */ steering_results[initial_angle][next_movement][new_angle] += ALPHA; /*here we re-norm so that the sum of the probabilities is still 1*/ for(i=0; i<ANGLES; i++) { steering_results[initial_angle][next_movement][i] /= (1+ALPHA); } /*The last thing we do is reduce Epsilon*/ if(EPSILON_CURRENT > EPSILON_MIN) { EPSILON_CURRENT-=EPSILON_DECAY; } }
void buzzer_settings::on_pushButtonBack_clicked() { go_back(); }
/*! mouse callback \author jfpatry \date Created: 2000-09-27 \date Modified: 2000-09-27 */ void mouse_cb( int button, int state, int x, int y ) { if ( state == WS_MOUSE_DOWN ) { go_back(); } }