本文整理汇总了C++中soundLib::play_sfx方法的典型用法代码示例。如果您正苦于以下问题:C++ soundLib::play_sfx方法的具体用法?C++ soundLib::play_sfx怎么用?C++ soundLib::play_sfx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soundLib
的用法示例。
在下文中一共展示了soundLib::play_sfx方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_item
bool classPlayer::get_item(object_colision &obj_info)
{
if (character::get_item(obj_info)) {
return true;
}
bool res = false;
// deal with non-blocking items
if (obj_info._object != NULL && obj_info._object->finished() == false) {
//std::cout << "classPlayer::get_item" << std::endl;
switch (obj_info._object->get_type()) {
case OBJ_ENERGY_TANK:
if (game_save.items.energy_tanks < 9) {
game_save.items.energy_tanks++;
}
obj_info._object->set_finished(true);
soundManager.play_sfx(SFX_GOT_ITEM);
res = true;
break;
case OBJ_WEAPON_TANK:
if (game_save.items.weapon_tanks == 0) {
game_save.items.weapon_tanks++;
}
obj_info._object->set_finished(true);
soundManager.play_sfx(SFX_GOT_ITEM);
res = true;
break;
case OBJ_LIFE:
game_save.items.lifes++;
if (game_save.items.lifes > 9) {
game_save.items.lifes = 9;
}
obj_info._object->set_finished(true);
soundManager.play_sfx(SFX_GOT_ITEM);
res = true;
break;
case OBJ_WEAPON_PILL_BIG:
obj_info._object->set_finished(true);
recharge(ENERGY_TYPE_WEAPON, ENERGY_ITEM_BIG);
res = true;
break;
case OBJ_WEAPON_PILL_SMALL:
obj_info._object->set_finished(true);
recharge(ENERGY_TYPE_WEAPON, ENERGY_ITEM_SMALL);
res = true;
break;
default:
//std::cout << "classPlayer::get_item - unknown item type: " << obj_info._object->get_type() << std::endl;
break;
}
}
return res;
}
示例2: recharge
void classPlayer::recharge(e_energy_types _en_type, int value)
{
if (_en_type == ENERGY_TYPE_HP) {
character::recharge(_en_type, value);
} else if (_en_type == ENERGY_TYPE_WEAPON) {
if (game_save.items.weapons[selected_weapon] < PLAYER_INITIAL_HP) {
if (game_save.items.weapons[selected_weapon] + value <= PLAYER_INITIAL_HP) {
game_save.items.weapons[selected_weapon] += value;
} else {
game_save.items.weapons[selected_weapon] = PLAYER_INITIAL_HP;
}
soundManager.play_sfx(SFX_GOT_ENERGY);
if (value > ENERGY_ITEM_SMALL) {
soundManager.play_sfx(SFX_GOT_ENERGY);
}
}
}
}
示例3: teleport_stand
void classPlayer::teleport_stand()
{
unsigned int waitTimer = timer.getTimer()+500;
state.animation_state = ANIM_TYPE_TELEPORT;
/*
if (p2Obj) {
p2Obj->sprite->anim_type = ANIM_TELEPORT;
}
*/
soundManager.play_sfx(SFX_TELEPORT);
while (waitTimer > timer.getTimer()) {
draw_lib.update_screen();
show();
/*
if (p2Obj) {
show_sprite(p2Obj->sprite, game_screen);
}
*/
//drawMap3rdLevel(game_screen);
//updateScreen(game_screen);
input.waitTime(20);
}
}
示例4: draw_screen
void key_map::draw_screen()
{
bool finished = false;
st_position config_text_pos;
st_position cursor_pos;
short _pick_pos = 0;
config_text_pos.x = graphLib.get_config_menu_pos().x + 74;
config_text_pos.y = graphLib.get_config_menu_pos().y + 40;
cursor_pos = config_text_pos;
graphLib.clear_area(config_text_pos.x-1, config_text_pos.y-1, 180, 180, 0, 0, 0);
input.clean();
input.waitTime(300);
for (unsigned int i=0; i<_keys_list.size(); i++) {
graphLib.draw_text(config_text_pos.x, config_text_pos.y + i*CURSOR_SPACING, _keys_list[i].c_str());
redraw_line(i);
}
graphLib.draw_text(config_text_pos.x, config_text_pos.y + _keys_list.size()*CURSOR_SPACING, "RETURN");
draw_lib.update_screen();
//cout << "scenesLib::option_picker::START\n";
graphLib.drawCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
while (finished == false) {
input.readInput();
if (input.p1_input[BTN_START]) {
if (_pick_pos == (short)_keys_list.size()) {
std::cout << "key_map::draw_screen - FINISHED #1" << std::endl;
finished = true;
} else {
graphLib.draw_text(config_text_pos.x, config_text_pos.y + _keys_list.size()*CURSOR_SPACING+CURSOR_SPACING*2, "PRESS NEW KEY/BUTTON"); //input code (number)
draw_lib.update_screen();
//format_v_2_1_1::st_key_config new_key = input.get_pressed_key();
graphLib.clear_area(config_text_pos.x, config_text_pos.y + _keys_list.size()*CURSOR_SPACING+CURSOR_SPACING*2-1, 180, CURSOR_SPACING+1, 0, 0, 0);
///@TODO - key_config[_pick_pos].key_type = new_key.key_type;
///@TODO - key_config[_pick_pos].key_number = new_key.key_number;
redraw_line(_pick_pos);
draw_lib.update_screen();
}
}
if (input.p1_input[BTN_DOWN]) {
soundManager.play_sfx(SFX_CURSOR);
graphLib.eraseCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
_pick_pos++;
if (_pick_pos >= (short)_keys_list.size()+1) {
_pick_pos = 0;
}
graphLib.drawCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
}
if (input.p1_input[BTN_UP]) {
soundManager.play_sfx(SFX_CURSOR);
graphLib.eraseCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
_pick_pos--;
if (_pick_pos < 0) {
_pick_pos = _keys_list.size();
}
graphLib.drawCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
}
if (input.p1_input[BTN_QUIT]) {
std::cout << "key_map::draw_screen - FINISHED #2" << std::endl;
finished = true;
}
input.clean();
input.waitTime(10);
draw_lib.update_screen();
}
}
示例5: move_cursor
// column1: normal, ape, daisie, dynamite, mummy, spike
// column2: techno, mage, seahorse, item coil, item jet
// column3: e-tank, w-tank *(must be changed, as currently are two rows)
void class_config::move_cursor(Sint8 x_inc, Sint8 y_inc) {
// left/right: if position exists, just move. if not then go to first item in nexct column or stays in place
bool moved = false;
st_position res;
//std::cout << ">>>>> class_config::move_cursor - xinc: " << x_inc << ", y_inc: " << y_inc << std::endl;
if (ingame_menu_pos.y != 6) { // weapons positions
if (x_inc > 0) {
if (ingame_menu_pos.x == 0) {
res = move_weapon_curstor_right();
if (res.x != -1) {
ingame_menu_pos = res;
moved = true;
}
} else {
res = move_weapon_curstor_left(); // right on right column - move left
if (res.x != -1) {
ingame_menu_pos = res;
moved = true;
}
}
} else if (x_inc < 0 && ingame_menu_pos.y != 0) {
if (ingame_menu_pos.x == 0) {
res = move_weapon_curstor_right(); // left on left column - move right
if (res.x != -1) {
ingame_menu_pos = res;
moved = true;
}
} else {
res = move_weapon_curstor_left();
if (res.x != -1) {
ingame_menu_pos = res;
moved = true;
}
}
}
} else { // energy drinks position
if (x_inc > 0 && ingame_menu_pos.y != 0) {
if (ingame_menu_pos.x < 2) {
ingame_menu_pos.x++;
} else {
ingame_menu_pos.x = 0;
}
moved = true;
} else if (x_inc < 0) {
if (ingame_menu_pos.x == 0) {
ingame_menu_pos.x = 2;
} else {
ingame_menu_pos.x--;
}
moved = true;
}
}
if (y_inc > 0) {
if (ingame_menu_pos.y < 6) {
res = move_weapon_curstor_down();
if (res.y != -1) {
ingame_menu_pos = res;
moved = true;
}
} else {
ingame_menu_pos.x = 0;
ingame_menu_pos.y = 0;
}
moved = true;
} else if (y_inc < 0) {
if ((ingame_menu_pos.x == 0 && ingame_menu_pos.y == 0) || (ingame_menu_pos.x == 1 && ingame_menu_pos.y == 1)) { // when on top, go to energy drinks section
std::cout << "MOVE CURSOR #1" << std::endl;
ingame_menu_pos.y = 6;
} else {
if (ingame_menu_pos.y == 6 && ingame_menu_pos.x == 2) { // just fix x, as there is no third column on weapons section as there is in the energy drinks section
ingame_menu_pos.x = 1;
}
res = move_weapon_curstor_up();
if (res.y != -1) {
ingame_menu_pos = res;
moved = true;
}
}
}
if (moved == true) {
soundManager.play_sfx(SFX_CURSOR);
}
}
示例6: use_tank
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--;
}
}
示例7: execute_projectiles
//.........这里部分代码省略.........
//std::cout << "projectile.move_type: " << (*it)->get_move_type() << std::endl;
/// @TODO projectiles that are tele-guided
if ((*it).get_move_type() == TRAJECTORY_CHAIN) {
(*it).set_y(position.y+frameSize.height/2);
} else if ((*it).get_move_type() == TRAJECTORY_QUAKE) {
damage_ground_npcs();
continue;
}
(*it).draw();
if ((*it).is_reflected == true) {
continue;
}
// check colision agains enemies
std::vector<classnpc*>::iterator enemy_it;
for (enemy_it=map->_npc_list.begin(); enemy_it != map->_npc_list.end(); enemy_it++) {
if ((*it).is_finished == true) {
projectile_list.erase(it);
break;
}
if ((*enemy_it)->is_on_visible_screen() == false) {
continue;
}
if ((*enemy_it)->is_dead() == true) {
continue;
}
//classnpc* enemy = (*enemy_it);
if ((*it).check_colision(st_rectangle((*enemy_it)->getPosition().x, (*enemy_it)->getPosition().y, (*enemy_it)->get_size().width, (*enemy_it)->get_size().height), st_position(moved.width, moved.height)) == true) {
if ((*enemy_it)->is_shielded((*it).get_direction()) == true) { // shielded NPC -> reflects shot
if ((*it).get_trajectory() == TRAJECTORY_CHAIN) {
(*it).consume_projectile();
} else {
(*it).reflect();
}
continue;
}
if ((*enemy_it)->is_invisible() == true) { // invisible NPC -> ignore shot
continue;
}
// check if have hit area, and if hit it
st_rectangle enemy_hit_area = (*enemy_it)->get_hit_area();
st_size enemy_size = (*enemy_it)->get_size();
enemy_hit_area.x += (*enemy_it)->getPosition().x-1;
enemy_hit_area.y += (*enemy_it)->getPosition().y;
//std::cout << ">> PLAYER::execute_projectiles[" << (*enemy_it)->getName() << "] - npc.h: " << enemy_size.height << ", hit_area.h: " << enemy_hit_area.h << std::endl;
if (enemy_hit_area.w != enemy_size.width || enemy_hit_area.h != enemy_size.height) {
//std::cout << ">> PLAYER::execute_projectiles[" << (*enemy_it)->getName() << "] - use hit_area" << std::endl;
if ((*it).check_colision(enemy_hit_area, st_position(moved.width, moved.height)) == false) { // hit body, but not the hit area -> reflect
//std::cout << ">> PLAYER::execute_projectiles[" << (*enemy_it)->getName() << "]Projectile missed - enemy_hit_area.w: " << enemy_hit_area.w << ", enemy_hit_area.h: " << enemy_hit_area.h << std::endl;
(*it).consume_projectile();
continue;
}
//} else {
//std::cout << ">> PLAYER::execute_projectiles[" << (*enemy_it)->getName() << "] - DONT use hit_area" << std::endl;
}
short wpn_id = (*it).get_weapon_id();
//std::cout << "******* wpn_id: " << wpn_id << std::endl;
if (wpn_id < 0) {
wpn_id = 0;
}
//std::cout << ">> player weapon damage #1" << std::endl;
//std::cout << "******* (*enemy_it)->is_using_circle_weapon(): " << (*enemy_it)->is_using_circle_weapon() << ", (*it)->get_trajectory(): " << (*it)->get_trajectory() << ", TRAJECTORY_CHAIN: " << TRAJECTORY_CHAIN << std::endl;
// NPC using cicrcle weapon, is only be destroyed by CHAIN, but NPC won't take damage
if ((*enemy_it)->is_using_circle_weapon() == true ) {
if ((*it).get_trajectory() == TRAJECTORY_CHAIN) {
//std::cout << "PLAYER projectile hit NPC centered-weapon" << std::endl;
(*enemy_it)->consume_projectile();
}
(*it).consume_projectile();
return;
}
if ((*it).get_damage() > 0) {
int multiplier = game_data.game_npcs[(*enemy_it)->get_number()].weakness[wpn_id].damage_multiplier;
if (multiplier <= 0) {
multiplier = 1;
}
(*enemy_it)->damage((*it).get_damage() * multiplier, ignore_hit_timer);
}
if ((*it).get_damage() > 0) {
(*it).consume_projectile();
soundManager.play_sfx(SFX_NPC_HIT);
}
}
}
}
}