本文整理汇总了C++中sound函数的典型用法代码示例。如果您正苦于以下问题:C++ sound函数的具体用法?C++ sound怎么用?C++ sound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sound函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: twall
/**
* Tunnel through wall. Assumes valid location.
*
* Note that it is impossible to "extend" rooms past their
* outer walls (which are actually part of the room).
*
* Attempting to do so will produce floor grids which are not part
* of the room, and whose "illumination" status do not change with
* the rest of the room.
*/
static bool twall(int y, int x)
{
/* Paranoia -- Require a wall or door or some such */
if (!(square_isdiggable(cave, y, x) || square_iscloseddoor(cave, y, x)))
return (false);
/* Sound */
sound(MSG_DIG);
/* Forget the wall */
square_forget(cave, y, x);
/* Remove the feature */
square_tunnel_wall(cave, y, x);
/* Update the visuals */
player->upkeep->update |= (PU_UPDATE_VIEW | PU_MONSTERS);
/* Fully update the flow */
player->upkeep->update |= (PU_FORGET_FLOW | PU_UPDATE_FLOW);
/* Result */
return (true);
}
示例2: main
void main()
{
node*root,*root1;
clrscr();
gotoxy(1,25);
cout<<"enter the tree";
root=new node;
gettree(root,40,1);
cout<<"the tree loaded";
sound(200);
delay(1000);
nosound();
getch();
getch();
clrscr();
showtree(root,40,10);
getch();
root1=new node;
createig(root,root1);
clrscr();
showtree(root1,40,10);
getch();
}
示例3: run_bute_defeated
static bool run_bute_defeated(Object *o, int hp)
{
if (o->hp <= (1000 - hp))
{
if (o->type == OBJ_MESA)
{
o->ChangeType(OBJ_MESA_DYING);
}
else
{
o->x -= (4 << CSF);
o->y -= (4 << CSF);
o->ChangeType(OBJ_BUTE_DYING);
sound(SND_ENEMY_SQUEAK);
XMOVE(-0x100);
}
ai_bute_dying(o);
return 1;
}
return 0;
}
示例4: r_touch
void r_touch()
{
//gedict_t* stemp;
//float best;
if ( strneq( other->s.v.classname, "player" ) )
return;
if ( other->s.v.health <= 0 )
return;
self->mdl = self->s.v.model;
sound( other, CHAN_VOICE, self->s.v.noise, 1, ATTN_NORM );
stuffcmd( other, "bf\n" );
self->s.v.solid = SOLID_NOT;
other->s.v.items = ( ( int ) other->s.v.items ) | IT_INVISIBILITY;
self->s.v.model = "";
// do the apropriate action
other->invisible_time = 1;
other->invisible_finished = self->cnt;
G_bprint( PRINT_LOW, "%s recovered a Ring with %d seconds remaining!\n",
other->s.v.netname,
( int ) ( other->invisible_finished - g_globalvars.time ) );
/*s=ftos(rint(other->invisible_finished - time));
trap_BPrint (PRINT_LOW, other->s.v.netname);
trap_BPrint (PRINT_LOW, " recovered a Ring with ");
trap_BPrint (PRINT_LOW, s);
trap_BPrint (PRINT_LOW, " seconds remaining!\n"); */
activator = other;
SUB_UseTargets(); // fire all targets / killtargets
}
示例5: android_main
void android_main(android_app *app) {
app_dummy();
flatbuffers::FlatBufferBuilder builder;
auto name = builder.CreateString("Dog");
auto sound = builder.CreateString("Bark");
auto animal_buffer = sample::CreateAnimal(builder, name, sound);
builder.Finish(animal_buffer);
// We now have a FlatBuffer that can be stored on disk or sent over a network.
// ...Code to store on disk or send over a network goes here...
// Instead, we're going to access it immediately, as if we just recieved this.
auto animal = sample::GetAnimal(builder.GetBufferPointer());
assert(animal->name()->str() == "Dog");
assert(animal->sound()->str() == "Bark");
(void)animal; // To silence "Unused Variable" warnings.
__android_log_print(ANDROID_LOG_INFO, "FlatBufferSample",
"FlatBuffer successfully created and verified.");
}
示例6: beep
void QGCAudioWorker::noticeTips(int noticeType, int severity)
{
if (!muted)
{
// Prepend high priority text with alert beep
/*if (severity < GAudioOutput::AUDIO_SEVERITY_CRITICAL) {
beep();
}*/
QString soundPath = "";
getSoundFromType(noticeType,soundPath);
if ("" == soundPath)return;
QSound sound(QString(":res/")+soundPath);
sound.play();
// Wait for the last sound to finish
while (!sound.isFinished()) {
QGC::SLEEP::msleep(100);
}
}
}
示例7: switch
void OmegaBoss::Run(void)
{
Object *&o = game.stageboss.object;
if (omg.defeated)
return;
switch(o->state)
{
case 0: break; // waiting for trigger by script
case OMG_WAIT: // waits for a moment then go to omg.nextstate
{
o->state++;
omg.timer = 0;
}
case OMG_WAIT+1:
{
if (++omg.timer >= OMEGA_WAIT_TIME)
{
omg.timer = 0;
o->state = omg.nextstate;
}
}
break;
case OMG_APPEAR:
{
omg.timer = 0;
o->frame = 0;
o->state = OMG_MOVE;
omg.movedir = -OMEGA_SPEED;
o->flags |= FLAG_SOLID_MUSHY;
}
case OMG_MOVE: // rising up/going back into ground
{
o->frame = 0;
o->y += omg.movedir;
game.quaketime = 2;
omg.timer++;
if ((omg.timer & 3) == 0) sound(SND_QUAKE);
if (omg.timer >= omg.movetime)
{
if (omg.movedir < 0)
{ // was rising out of ground
omg.nextstate = OMG_JAWS_OPEN;
o->state = OMG_WAIT;
}
else
{ // was going back into ground
omg.timer = 0;
o->state = OMG_UNDERGROUND;
o->flags &= ~(FLAG_SOLID_MUSHY | FLAG_SOLID_BRICK);
}
}
}
break;
case OMG_JAWS_OPEN: // jaws opening
{
o->state++;
omg.animtimer = 0;
sound(SND_JAWS);
o->sprite = SPR_OMG_OPENED; // select "open" bounding box
}
case OMG_JAWS_OPEN+1:
{
omg.animtimer++;
if (omg.animtimer > 2)
{
omg.animtimer = 0;
o->frame++;
if (o->frame==3)
{
o->state = OMG_FIRE;
omg.firecounter = 0;
o->flags |= FLAG_SHOOTABLE;
}
}
}
break;
case OMG_FIRE: // throwing out red stuff
{
omg.firecounter++;
if (omg.firecounter > omg.startfiring && omg.firecounter < omg.stopfiring)
{
if ((omg.firecounter % omg.firefreq)==0)
{
Object *shot;
sound(SND_EM_FIRE);
shot = SpawnObjectAtActionPoint(o, OBJ_OMEGA_SHOT);
shot->xinertia = random(-omg.shotxspd, omg.shotxspd);
shot->yinertia = -0x333;
//.........这里部分代码省略.........
示例8: sound
void Buzzer::soundIfSilence(Buzzer::SoundType s)
{
if(sound_ == Off)
sound(s);
}
示例9: Execute
virtual void Execute(const DataObject &object)
{
wxASSERT(1 <= object.numItems());
wxInt32 thisTile, corner;
boost::tie(thisTile, corner) =
Utility::decodeSel(object.read<wxInt32>());
//determine other sides
wxInt32 tile2, tile3;
wxInt32 corner2, corner3;
Utility::otherTiles(GetGame(), thisTile, corner, tile2, corner2, tile3,
corner3);
bool bPort = false;
wxInt32 portTile = -1, port = -1;
DataObject input(thisTile), output;
RULE.Decide(shLogicTileIsPort, input, output);
//check for a port tile
if(true == output.read<bool>())
{
portTile = thisTile; port = corner;
}
//check for a port tile
input = DataObject(tile2);
output.reset();
RULE.Decide(shLogicTileIsPort, input, output);
if(true == output.read<bool>())
{
portTile = tile2; port = corner2;
}
//check for a port tile
input = DataObject(tile3);
output.reset();
RULE.Decide(shLogicTileIsPort, input, output);
if(true == output.read<bool>())
{
portTile = tile3; port = corner3;
}
//see if they have built on a port
if( (-1 < portTile) &&
(
(port == tile<wxInt32>(shPort1, portTile)) ||
(port == tile<wxInt32>(shPort2, portTile))
)
)
{
bPort = true;
}
DataObject sound(
bPort ? SOUND_PLACE_SETTLEMENT_ON_PORT : SOUND_PLACE_SETTLEMENT);
RULE.Execute(shRulePlaySound, sound);
}
示例10: inven_drop
/**
* Drop (some of) a non-cursed inventory/equipment item "near" the current
* location
*
* There are two cases here - a single object or entire stack is being dropped,
* or part of a stack is being split off and dropped
*/
void inven_drop(struct object *obj, int amt)
{
int py = player->py;
int px = player->px;
struct object *dropped;
bool none_left = false;
bool quiver = false;
char name[80];
char label;
/* Error check */
if (amt <= 0)
return;
/* Check it is still held, in case there were two drop commands queued
* for this item. This is in theory not ideal, but in practice should
* be safe. */
if (!object_is_carried(player, obj))
return;
/* Get where the object is now */
label = gear_to_label(obj);
/* Is it in the quiver? */
if (object_is_in_quiver(player, obj))
quiver = true;
/* Not too many */
if (amt > obj->number) amt = obj->number;
/* Take off equipment, don't combine */
if (object_is_equipped(player->body, obj))
inven_takeoff(obj);
/* Get the object */
dropped = gear_object_for_use(obj, amt, false, &none_left);
/* Describe the dropped object */
object_desc(name, sizeof(name), dropped, ODESC_PREFIX | ODESC_FULL);
/* Message */
msg("You drop %s (%c).", name, label);
/* Describe what's left */
if (dropped->artifact) {
object_desc(name, sizeof(name), dropped,
ODESC_FULL | ODESC_SINGULAR);
msg("You no longer have the %s (%c).", name, label);
} else if (none_left) {
/* Play silly games to get the right description */
int number = dropped->number;
dropped->number = 0;
object_desc(name, sizeof(name), dropped, ODESC_PREFIX | ODESC_FULL);
msg("You have %s (%c).", name, label);
dropped->number = number;
} else {
object_desc(name, sizeof(name), obj, ODESC_PREFIX | ODESC_FULL);
msg("You have %s (%c).", name, label);
}
/* Drop it near the player */
drop_near(cave, &dropped, 0, py, px, false);
/* Sound for quiver objects */
if (quiver)
sound(MSG_QUIVER);
event_signal(EVENT_INVENTORY);
event_signal(EVENT_EQUIPMENT);
}
示例11: setForm
// ---
void PacmanGame::ballEated (QGAMES::Tile* t)
{
t -> setForm (t -> form (), __BALLEATEDFRAME); // It is turned off to background...
_points -> add (__POINTSBALLEATED);
sound (__SOUNDCHOMP) -> play (-1);
}
示例12: ProcessMySensorsMessage
//.........这里部分代码省略.........
goto mqttinvaliddata;
std::string switchcmd = root["switchcmd"].asString();
if ((switchcmd != "On") && (switchcmd != "Off") && (switchcmd != "Toggle") && (switchcmd != "Set Level"))
goto mqttinvaliddata;
int level = 0;
if (!root["level"].empty())
{
if (root["level"].isString())
level = atoi(root["level"].asString().c_str());
else
level = root["level"].asInt();
}
if (!m_mainworker.SwitchLight(idx, switchcmd, level, -1, false, 0) == true)
{
_log.Log(LOG_ERROR, "MQTT: Error sending switch command!");
}
return;
}
else if (szCommand == "switchscene")
{
if (root["switchcmd"].empty())
goto mqttinvaliddata;
if (!root["switchcmd"].isString())
goto mqttinvaliddata;
std::string switchcmd = root["switchcmd"].asString();
if ((switchcmd != "On") && (switchcmd != "Off"))
goto mqttinvaliddata;
if (!m_mainworker.SwitchScene(idx, switchcmd) == true)
{
_log.Log(LOG_ERROR, "MQTT: Error sending scene command!");
}
return;
}
else if (szCommand == "setuservariable")
{
if (root["value"].empty())
goto mqttinvaliddata;
if (!root["value"].isString())
goto mqttinvaliddata;
std::string varvalue = root["value"].asString();
m_sql.SetUserVariable(idx, varvalue, true);
return;
}
else if (szCommand == "addlogmessage")
{
if (root["message"].empty())
goto mqttinvaliddata;
if (!root["message"].isString())
goto mqttinvaliddata;
std::string msg = root["message"].asString();
_log.Log(LOG_STATUS, "MQTT MSG: %s", msg.c_str());
return;
}
else if (szCommand == "sendnotification")
{
std::string subject(""), body(""), sound("");
int priority = 0;
if (!root["subject"].empty())
{
if (!root["subject"].isString())
goto mqttinvaliddata;
subject = root["subject"].asString();
}
if (!root["body"].empty())
{
if (!root["body"].isString())
goto mqttinvaliddata;
body = root["body"].asString();
}
if (!root["priority"].empty())
{
if (!root["priority"].isInt())
goto mqttinvaliddata;
priority = root["priority"].asInt();
}
if (!root["sound"].empty())
{
if (!root["sound"].isString())
goto mqttinvaliddata;
sound = root["sound"].asString();
}
m_notifications.SendMessageEx(NOTIFYALL, subject, body, "", priority, sound, true);
std::string varvalue = root["value"].asString();
m_sql.SetUserVariable(idx, varvalue, true);
return;
}
else if (szCommand == "getdeviceinfo")
{
int HardwareID = atoi(result[0][0].c_str());
SendDeviceInfo(HardwareID, idx, "request device", NULL);
return;
}
else
{
_log.Log(LOG_ERROR, "MQTT: Unknown command received: %s", szCommand.c_str());
return;
}
mqttinvaliddata:
_log.Log(LOG_ERROR, "MQTT: Invalid data received!");
}
示例13: effect_do
//.........这里部分代码省略.........
return TRUE;
}
case EF_REMOVE_CURSE:
{
if (remove_curse())
{
if (!p_ptr->timed[TMD_BLIND])
msg("The air around your body glows blue for a moment...");
else
msg("You feel as if someone is watching over you.");
*ident = TRUE;
}
return TRUE;
}
case EF_REMOVE_CURSE2:
{
remove_all_curse();
*ident = TRUE;
return TRUE;
}
case EF_LIGHT:
{
if (light_area(damroll(2, 8), 2)) *ident = TRUE;
return TRUE;
}
case EF_SUMMON_MON:
{
int i;
sound(MSG_SUM_MONSTER);
for (i = 0; i < randint1(3); i++)
{
if (summon_specific(py, px, p_ptr->depth, 0, 1))
*ident = TRUE;
}
return TRUE;
}
case EF_SUMMON_UNDEAD:
{
int i;
sound(MSG_SUM_UNDEAD);
for (i = 0; i < randint1(3); i++)
{
if (summon_specific(py, px, p_ptr->depth,
S_UNDEAD, 1))
*ident = TRUE;
}
return TRUE;
}
case EF_TELE_PHASE:
{
teleport_player(10);
*ident = TRUE;
return TRUE;
}
case EF_TELE_LONG:
{
示例14: auto_alloc
int running_machine::run(bool firstrun)
{
int error = MAMERR_NONE;
// use try/catch for deep error recovery
try
{
// move to the init phase
m_current_phase = MACHINE_PHASE_INIT;
// if we have a logfile, set up the callback
if (options().log())
{
m_logfile = auto_alloc(*this, emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
file_error filerr = m_logfile->open("error.log");
assert_always(filerr == FILERR_NONE, "unable to open log file");
add_logerror_callback(logfile_callback);
}
// then finish setting up our local machine
start();
// load the configuration settings and NVRAM
bool settingsloaded = config_load_settings(*this);
nvram_load(*this);
sound().ui_mute(false);
// display the startup screens
ui_display_startup_screens(*this, firstrun, !settingsloaded);
// perform a soft reset -- this takes us to the running phase
soft_reset();
// run the CPUs until a reset or exit
m_hard_reset_pending = false;
while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE)
{
g_profiler.start(PROFILER_EXTRA);
// execute CPUs if not paused
if (!m_paused)
m_scheduler.timeslice();
// otherwise, just pump video updates through
else
m_video->frame_update();
// handle save/load
if (m_saveload_schedule != SLS_NONE)
handle_saveload();
g_profiler.stop();
}
// and out via the exit phase
m_current_phase = MACHINE_PHASE_EXIT;
// save the NVRAM and configuration
sound().ui_mute(true);
nvram_save(*this);
config_save_settings(*this);
}
catch (emu_fatalerror &fatal)
{
mame_printf_error("%s\n", fatal.string());
error = MAMERR_FATALERROR;
if (fatal.exitcode() != 0)
error = fatal.exitcode();
}
catch (emu_exception &)
{
mame_printf_error("Caught unhandled emulator exception\n");
error = MAMERR_FATALERROR;
}
catch (std::bad_alloc &)
{
mame_printf_error("Out of memory!\n");
error = MAMERR_FATALERROR;
}
// call all exit callbacks registered
call_notifiers(MACHINE_NOTIFY_EXIT);
zip_file_cache_clear();
// close the logfile
auto_free(*this, m_logfile);
return error;
}
示例15: cplay
//Continous play without stopping previous sound
void cplay(int tone, int del){
sound(tone);
delay(del);
}