Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GPC Online Library
- // bejeweled_2_endless_mode_auto-play.gpc
- /* =====================================================================
- * BEJEWELED 2 ENDLESS MODE AUTO-PLAY
- *
- * Authors: BuckSatan
- *
- * Version: 1.0
- *
- * Overview:
- * Automates gameplay so that you can complete Endless Mode with the
- * click of a single button. Probably not fast or smart enough for
- * other modes.
- *
- * Details:
- * Clicking Right-Stick will toggle auto-play mode on/off. Auto-play
- * begins by moving the game cursor to a bottom corner position. It
- * will then try swapping the current jewel with both the adjacent
- * jewel and the one above before moving to the adjacent position.
- * When the end of the row is reached, auto-play attempts to swap
- * only with the jewel above, then moves up and reverses direction.
- * When all moves have been exhausted, auto-play returns to a bottom-
- * corner position and the whole process repeats. This pattern
- * ensures the whole board will be thoroughly checked for moves and
- * tends to find moves closer to the bottom first for the possiblity
- * of better cascades.
- *
- * Please note--clicking Right-Stick to disable Auto-Play will only
- * take effect once the current row is completely processed.
- * ===================================================================== */
- //
- // DEFINES
- // --------------------------------------------------------------------
- // Bejeweled Board Dimensions
- define NUM_ROWS = 8; // Rows on Bejeweled Board
- define LAST_ROW = 7; // Last Row Number
- define NUM_COLS = 8; // Columns on Bejeweled Board
- define LAST_COL = 7; // Last Column Number
- // Movement Control
- define LEFT_TO_RIGHT = 0; // Traverse Row Left->Right
- define RIGHT_TO_LEFT = 1; // Traverse Row Right->Left
- // Timings
- define THOLD_MOVE = 40; // Time to hold move active
- define TWAIT_MOVE = 40; // Time to wait between moves
- define THOLD_SWAP = 40; // Time to hold swap active
- define TWAIT_SWAP = 800; // Time to wait between swaps
- //
- // DATA SEGMENT
- // --------------------------------------------------------------------
- // (none required)
- //
- // REMAPPINGS
- // --------------------------------------------------------------------
- // (none required)
- //
- // VARIABLES
- // --------------------------------------------------------------------
- int auto_play = 0; // Toggle Auto-Play
- int curr_row = NUM_ROWS; // Current Row Position
- int curr_col = NUM_COLS; // Current Column Position
- int direction = LEFT_TO_RIGHT; // Direction to move/match
- int h_button = XB360_LEFT; // Button to use for horizonal
- int v_button = XB360_DOWN; // Button to use for vertical
- //
- // INITIALIZATION
- // --------------------------------------------------------------------
- // (none required)
- //
- // MAIN
- // --------------------------------------------------------------------
- main {
- // Toggle Activate Auto-Play
- if (event_press(XB360_RS)) {
- auto_play = !auto_play;
- // De-Activate AutoPlay if already running
- if (combo_running(AutoPlay)) {
- combo_stop(AutoPlay)
- }
- }
- // Activate when toggle set
- if (auto_play) {
- combo_run(AutoPlay)
- }
- }
- //
- // COMBOS
- // --------------------------------------------------------------------
- // Move One Position to the Left or Right
- combo MoveHorizontal {
- set_val(h_button, 100);
- wait(THOLD_MOVE);
- set_val(h_button, 0);
- wait(TWAIT_MOVE);
- }
- // Move One Position Up or Down
- combo MoveVertical {
- set_val(v_button, 100);
- wait(THOLD_MOVE);
- set_val(v_button, 0);
- wait(TWAIT_MOVE);
- }
- // Swap Current Jewel to the Left or Right
- combo SwapHorizontal {
- set_val(XB360_A, 100);
- wait(THOLD_SWAP);
- set_val(h_button, 100);
- wait(THOLD_SWAP);
- set_val(XB360_A, 0);
- set_val(h_button, 0);
- wait(TWAIT_SWAP);
- }
- // Swap Current Jewel with Above
- combo SwapUp {
- set_val(XB360_A, 100);
- wait(THOLD_SWAP);
- set_val(XB360_UP, 100);
- wait(THOLD_SWAP);
- set_val(XB360_A, 0);
- set_val(XB360_UP, 0);
- wait(TWAIT_SWAP);
- }
- // Traverse Middle or Bottom Row
- combo TraverseRow {
- // Reset Horizontal Direction
- if (direction == LEFT_TO_RIGHT) {
- h_button = XB360_RIGHT;
- } else {
- h_button = XB360_LEFT;
- }
- // Column 1
- call (SwapHorizontal);
- call (SwapUp);
- call (MoveHorizontal);
- // Column 2
- call (SwapHorizontal);
- call (SwapUp);
- call (MoveHorizontal);
- // Column 3
- call (SwapHorizontal);
- call (SwapUp);
- call (MoveHorizontal);
- // Column 4
- call (SwapHorizontal);
- call (SwapUp);
- call (MoveHorizontal);
- // Column 5
- call (SwapHorizontal);
- call (SwapUp);
- call (MoveHorizontal);
- // Column 6
- call (SwapHorizontal);
- call (SwapUp);
- call (MoveHorizontal);
- // Column 7
- call (SwapHorizontal);
- call (SwapUp);
- call (MoveHorizontal);
- // Column 8
- call (SwapUp);
- call (MoveVertical);
- // Reverse Direction
- if (direction == LEFT_TO_RIGHT) {
- direction = RIGHT_TO_LEFT;
- } else {
- direction = LEFT_TO_RIGHT;
- }
- }
- // Traverse Top Row
- combo TraverseTopRow {
- // Reset Horizontal Direction
- if (direction == LEFT_TO_RIGHT) {
- h_button = XB360_RIGHT;
- } else {
- h_button = XB360_LEFT;
- }
- // Column 1
- call (SwapHorizontal);
- call (MoveHorizontal);
- // Column 2
- call (SwapHorizontal);
- call (MoveHorizontal);
- // Column 3
- call (SwapHorizontal);
- call (MoveHorizontal);
- // Column 4
- call (SwapHorizontal);
- call (MoveHorizontal);
- // Column 5
- call (SwapHorizontal);
- call (MoveHorizontal);
- // Column 6
- call (SwapHorizontal);
- call (MoveHorizontal);
- // Column 7
- call (SwapHorizontal);
- call (MoveHorizontal);
- // Column 8
- // (nothing left to do)
- }
- // Main Auto-Play Sequence
- combo AutoPlay {
- // ------------------------------
- // Return Home
- // ------------------------------
- // Set Horizontal Direction
- if (direction == LEFT_TO_RIGHT) {
- h_button = XB360_LEFT;
- } else {
- h_button = XB360_RIGHT;
- }
- // Set Vertical Direction
- v_button = XB360_DOWN;
- // Return Horizontal
- call (MoveHorizontal); // 1
- call (MoveHorizontal); // 2
- call (MoveHorizontal); // 3
- call (MoveHorizontal); // 4
- call (MoveHorizontal); // 5
- call (MoveHorizontal); // 6
- call (MoveHorizontal); // 7
- // Return Vertical
- call (MoveVertical); // 1
- call (MoveVertical); // 2
- call (MoveVertical); // 3
- call (MoveVertical); // 4
- call (MoveVertical); // 5
- call (MoveVertical); // 6
- call (MoveVertical); // 7
- // Reset Vertical Direction
- v_button = XB360_UP;
- // ------------------------------
- // Traverse Rows
- // ------------------------------
- call (TraverseRow); // Row 1
- call (TraverseRow); // Row 2
- call (TraverseRow); // Row 3
- call (TraverseRow); // Row 4
- call (TraverseRow); // Row 5
- call (TraverseRow); // Row 6
- call (TraverseRow); // Row 7
- call (TraverseTopRow); // Row 8
- }
- //
- // FUNCTIONS
- // --------------------------------------------------------------------
- // (none required)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement