コード例 #1
0
ファイル: class_config.cpp プロジェクト: eduardok/rockbot
void class_config::draw_ingame_menu()
{
    ingame_menu_pos = convert_stage_n_to_menu_pos(player_ref->get_selected_weapon());
    graphLib.draw_weapon_menu_bg(player_ref->get_current_hp(), player_ref->get_char_frame(ANIM_DIRECTION_RIGHT, ANIM_TYPE_ATTACK, 0));
    graphLib.draw_weapon_icon(convert_menu_pos_to_weapon_n(ingame_menu_pos), ingame_menu_pos, true);
    graphLib.draw_weapon_cursor(ingame_menu_pos, player_ref->get_weapon_value(convert_menu_pos_to_weapon_n(ingame_menu_pos)), player_ref->get_number());
}
コード例 #2
0
ファイル: class_config.cpp プロジェクト: eduardok/rockbot
bool class_config::execute_ingame_menu()
{
    st_position old_pos;


    if (input.p1_input[BTN_START] == 1) {
        input.clean();
        input.waitTime(300);
        // leaving menu, removes pause
        if (ingame_menu_active == true) {
            timer.unpause();
        }
        ingame_menu_active = !ingame_menu_active;

        if (ingame_menu_active) {
            timer.pause();
            generate_weapons_matrix();
            draw_ingame_menu();
        } else {
            // change player color/weapon
            if (ingame_menu_pos.y != 6) {
                player_ref->set_weapon(convert_menu_pos_to_weapon_n(ingame_menu_pos));
            } else {
                // use item
                use_tank(ingame_menu_pos.x);
                ingame_menu_active = !ingame_menu_active; // keep itself inside the menu
                generate_weapons_matrix();
                draw_ingame_menu();
            }
        }
    }

    if (ingame_menu_active) {
        old_pos.x = ingame_menu_pos.x;
        old_pos.y = ingame_menu_pos.y;
        if (input.p1_input[BTN_UP] == 1) {
            move_cursor(0, -1);
        } else if (input.p1_input[BTN_DOWN] == 1) {
            move_cursor(0, 1);
        } else if (input.p1_input[BTN_LEFT] == 1) {
            move_cursor(-1, 0);
        } else if (input.p1_input[BTN_RIGHT] == 1) {
            move_cursor(1, 0);
        } else if (input.p1_input[BTN_R] == 1) {
            if (gameControl.show_config(game_save.stages[gameControl.currentStage]) == true) { // player picked "leave stage" option
                ingame_menu_active = false;
                timer.unpause();
                return true;
            }
            draw_ingame_menu();
        }
        if (old_pos.x != ingame_menu_pos.x || old_pos.y != ingame_menu_pos.y) {
            //std::cout << ">> old_pos.y: " << old_pos.y << ", ingame_menu_pos.y: " << ingame_menu_pos.y << std::endl;
            if (old_pos.y != 6) {
                graphLib.draw_weapon_cursor(old_pos, player_ref->get_weapon_value(convert_menu_pos_to_weapon_n(old_pos)), -1);
                graphLib.draw_weapon_icon(convert_menu_pos_to_weapon_n(old_pos), old_pos, false);
            } else {
                graphLib.erase_menu_item(old_pos.x);
            }
            if (ingame_menu_pos.y != 6) {
                graphLib.draw_weapon_cursor(ingame_menu_pos, player_ref->get_weapon_value(convert_menu_pos_to_weapon_n(ingame_menu_pos)), player_ref->get_number());
                graphLib.draw_weapon_icon(convert_menu_pos_to_weapon_n(ingame_menu_pos), ingame_menu_pos, true);
                change_player_frame_color();
            } else {
                graphLib.draw_menu_item(ingame_menu_pos.x);
            }
        }
        input.clean();
        input.waitTime(MENU_CHANGE_DELAY);
    }
    return ingame_menu_active;
}
コード例 #3
0
ファイル: class_config.cpp プロジェクト: eduardok/rockbot
void class_config::use_tank(int tank_type)
{
	int n = 0;

    // check tank number
    if (tank_type == TANK_ENERGY && game_save.items.energy_tanks == 0) {
        return;
    }
    if (tank_type == TANK_WEAPON && game_save.items.weapon_tanks == 0) {
        return;
    }
    if (tank_type == TANK_SPECIAL && game_save.items.special_tanks == 0) {
        return;
    }

	// no need for tank usage
	if (tank_type == TANK_ENERGY && player_ref->get_hp().current == player_ref->get_hp().total) {
		return;
	}
	if (tank_type == TANK_ENERGY || tank_type == TANK_SPECIAL) {
		while (player_ref->get_hp().current < player_ref->get_hp().total) {
			player_ref->set_current_hp(1);
			if (n == 0 || n % 6 == 0) {
				soundManager.play_sfx(SFX_GOT_ENERGY);
			}
			n++;
			//graphLib.draw_horizontal_hp_bar(WPN_COLUMN_Y, 2, player_ref->get_hp().current);
			graphLib.draw_weapon_cursor(st_position(0, 0), player_ref->get_hp().current, -1);
            draw_lib.update_screen();
			input.waitTime(50);
		}
	}
	if (tank_type == TANK_SPECIAL || tank_type == TANK_WEAPON) {
		st_position weapon_pos(0, 0);
		for (int i=0; i<WEAPON_COUNT; i++) {
			n = 0;
			short unsigned int value = player_ref->get_weapon_value(i);
			if (value < player_ref->get_hp().total) {
				while (value < player_ref->get_hp().total) {
					value++;
					player_ref->set_weapon_value(i, value);
					if (n == 0 || n % 6 == 0) {
						soundManager.play_sfx(SFX_GOT_ENERGY);
					}
					n++;
					graphLib.draw_weapon_cursor(weapon_pos, player_ref->get_weapon_value(i), -1);
                    draw_lib.update_screen();
					input.waitTime(50);
				}
			}
			weapon_pos.y = weapon_pos.y+1;
			if (weapon_pos.y > 5) {
				weapon_pos.y = 1;
				weapon_pos.x = 1;
			}
		}
	}
    // consume tank
    if (tank_type == TANK_ENERGY) {
        game_save.items.energy_tanks--;
    }
    if (tank_type == TANK_WEAPON) {
        game_save.items.weapon_tanks--;
    }
    if (tank_type == TANK_SPECIAL) {
        game_save.items.special_tanks--;
    }
}