本文整理汇总了C++中sound函数的典型用法代码示例。如果您正苦于以下问题:C++ sound函数的具体用法?C++ sound怎么用?C++ sound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sound函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Chillbon,项目名称:angband,代码行数:34,代码来源:cmd-cave.c
示例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();
}
开发者ID:akreddysoft,项目名称:CollegeCode,代码行数:24,代码来源:TREEIMAG.CPP
示例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;
}
开发者ID:Angluca,项目名称:nxengine-libretro,代码行数:24,代码来源:hell.cpp
示例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
}
开发者ID:angeld29,项目名称:qwprogs-qvm,代码行数:36,代码来源:items.c
示例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.");
}
开发者ID:007gzs,项目名称:flatbuffers,代码行数:24,代码来源:main.cpp
示例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);
}
}
}
开发者ID:hangzhouzhikuntech,项目名称:zhikunground,代码行数:24,代码来源:QGCAudioWorker.cpp
示例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;
//.........这里部分代码省略.........
开发者ID:Fordi,项目名称:nxengine-evo,代码行数:101,代码来源:omega.cpp
示例8: sound
void Buzzer::soundIfSilence(Buzzer::SoundType s)
{
if(sound_ == Off)
sound(s);
}
开发者ID:89c2051,项目名称:cheali-charger,代码行数:5,代码来源:Buzzer.cpp
示例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);
}
开发者ID:Dangr8,项目名称:Cities3D,代码行数:61,代码来源:RulePlaySettlementSound.cpp
示例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);
}
开发者ID:fe051,项目名称:angband,代码行数:78,代码来源:obj-gear.c
示例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);
}
开发者ID:Commnets,项目名称:QGAMES,代码行数:7,代码来源:Game.cpp
示例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!");
}
开发者ID:interxis,项目名称:domoticz,代码行数:101,代码来源:MQTT.cpp
示例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:
{
开发者ID:konijn,项目名称:angband,代码行数:67,代码来源:effects.c
示例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;
}
开发者ID:bdidier,项目名称:MAME-OS-X,代码行数:88,代码来源:machine.c
示例15: cplay
//Continous play without stopping previous sound
void cplay(int tone, int del){
sound(tone);
delay(del);
}
开发者ID:iamareebjamal,项目名称:CompLab_amu,代码行数:5,代码来源:AIRTEL.C
示例16: GrappleAnchor
void GrappleAnchor()
{
gedict_t *owner = PROG_TO_EDICT( self->s.v.owner );
if (other == owner)
return;
// DO NOT allow the grapple to hook to any projectiles, no matter WHAT!
// if you create new types of projectiles, make sure you use one of the
// classnames below or write code to exclude your new classname so
// grapples will not stick to them.
if ( streq(other->s.v.classname, "rocket") ||
streq(other->s.v.classname, "grenade") ||
streq(other->s.v.classname, "spike" ) ||
streq(other->s.v.classname, "hook" ))
return;
if ( other->ct == ctPlayer )
{
// grappling players in prewar is annoying
if ( match_in_progress != 2 || (tp_num() == 4 && streq(getteam(other), getteam(owner))) )
{
GrappleReset( self );
return;
}
sound ( self, CHAN_WEAPON, "player/axhit1.wav", 1, ATTN_NORM );
// previously 10 damage per hit, but at close range that could be exploited
other->deathtype = dtHOOK;
T_Damage ( other, self, owner, 1 );
// make hook invisible since we will be pulling directly
// towards the player the hook hit. Quakeworld makes it
// too quirky to try to match hook's velocity with that of
// the client that it hit.
setmodel ( self, "" );
}
else
{
sound ( self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM );
// One point of damage inflicted upon impact. Subsequent
// damage will only be done to PLAYERS... this way secret
// doors and triggers will only be damaged once.
if ( other->s.v.takedamage ) {
other->deathtype = dtHOOK;
T_Damage ( other, self, owner, 1 );
}
SetVector( self->s.v.velocity , 0, 0, 0 );
SetVector( self->s.v.avelocity, 0, 0, 0 );
}
// conveniently clears the sound channel of the CHAIN1 sound,
// which is a looping sample and would continue to play. Tink1 is
// the least offensive choice, as NULL.WAV loops and clogs the
// channel with silence
sound ( owner, CHAN_NO_PHS_ADD + CHAN_WEAPON, "weapons/tink1.wav", 1, ATTN_NORM );
if ( !owner->s.v.button0 )
{
GrappleReset( self );
return;
}
if ( (int)owner->s.v.flags & FL_ONGROUND )
owner->s.v.flags -= FL_ONGROUND;
owner->on_hook = true;
sound ( owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM );
owner->ctf_sound = true;
self->s.v.enemy = EDICT_TO_PROG( other );
self->s.v.think = (func_t) GrappleTrack;
self->s.v.nextthink = g_globalvars.time;
self->s.v.solid = SOLID_NOT;
self->s.v.touch = (func_t) SUB_Null;
}
开发者ID:JosephPecoraro,项目名称:ktx,代码行数:80,代码来源:grapple.c
示例17: sound
void sounds::ambient_sound( const tripoint &p, int vol, std::string description )
{
sound( p, vol, description, true );
}
开发者ID:Guuo,项目名称:Cataclysm-DDA,代码行数:4,代码来源:sounds.cpp
示例18: layer
void World::buildScene()
{
// Initialize layers
for(std::size_t i = 0; i < LayerCount; ++i)
{
Category::Type type = (i == (int)Entities) ? Category::EntityLayer : Category::None;
SceneNode::Ptr layer(new SceneNode(type));
mSceneLayers[i] = layer.get();
mSceneGraph.attachChild(std::move(layer));
}
// Background
std::unique_ptr<SpriteNode> background(new SpriteNode(mTextures.get(Textures::Background)));
background->setScale(sf::Vector2f(2.f, 2.f));
mSceneLayers[Background]->attachChild(std::move(background));
// Tilemap
for(int i = 0; i < 8; ++i)
{
for(int j = 0; j < 8; ++j)
{
std::unique_ptr<SpriteNode> tile(new SpriteNode(mTextures.get(Textures::Tile)));
tile->setPosition(toIsoCoord(j, i));
mSceneLayers[Tilemap]->attachChild(std::move(tile));
}
}
// Camera
std::unique_ptr<CameraNode> camera(new CameraNode(mWorldView));
mSceneGraph.attachChild(std::move(camera));
// Sounds
std::unique_ptr<SoundNode> sound(new SoundNode(mSounds));
mSceneLayers[Decorations]->attachChild(std::move(sound));
// Help
std::unique_ptr<HelpNode> help(new HelpNode(mTextures));
mSceneGraph.attachChild(std::move(help));
// Add the Traplist Node, that handle trap creation
std::unique_ptr<TraplistNode> traplist(new TraplistNode(mTextures, mFonts));
mSceneLayers[Entities]->attachChild(std::move(traplist));
Command cmd;
cmd.action = derivedAction<TraplistNode>([](TraplistNode& node, sf::Time dt) {
node.generateTraps(5);
});
cmd.category = Category::Traplist;
mCommandQueue.push(cmd);
// Player
std::unique_ptr<PlayerEntity> player(new PlayerEntity(mTextures));
player->setPosition(toIsoCoord(1, 1));
player->setGridPosition(sf::Vector2i(1, 1));
mPlayer = player.get();
std::unique_ptr<BubbleNode> bubble(new BubbleNode(mTextures, mFonts));
mPlayer->setBubble(bubble.get());
bubble->setString("KILL KIDS! EXTEMINATE!");
player->attachChild(std::move(bubble));
mSceneLayers[Entities]->attachChild(std::move(player));
// Ennemies
/*std::unique_ptr<BasicKidNode> kid(new BasicKidNode(mTextures));
kid->setPosition(toIsoCoord(0, 0));
kid->setGridPosition(sf::Vector2i(0, 0));
mSceneLayers[Entities]->attachChild(std::move(kid));
kid.reset(new BasicKidNode(mTextures));
kid->setPosition(toIsoCoord(0, 2));
kid->setGridPosition(sf::Vector2i(0, 2));
mSceneLayers[Entities]->attachChild(std::move(kid));*/
// Waves & Points
std::unique_ptr<WaveGenerator> waves(new WaveGenerator(mTextures, mFonts, mMusic));
waves->nextWave();
mSceneLayers[Entities]->attachChild(std::move(waves));
}
开发者ID:Lo-X,项目名称:ludumdare31,代码行数:87,代码来源:world.cpp
示例19: main
int main() {
// GLFWの初期化
if (!glfwInit()) return -1;
// GLFW Widnowを用意
GLFWwindow* window = glfwCreateWindow(640, 480,
"Play WAV fie",
nullptr, nullptr);
// Windowsを生成できなければ終了
if (!window) {
glfwTerminate();
return -1;
}
// 用意したWindowsでOpenGLが使えるようにする
// これで、OpenGLの命令が有効になる
glfwMakeContextCurrent(window);
// 描画のタイミングを画面更新と同期
glfwSwapInterval(1);
// OpenALの初期化
ALCdevice* device = alcOpenDevice(nullptr);
ALCcontext* context = alcCreateContext(device, nullptr);
alcMakeContextCurrent(context);
// バッファの生成
ALuint buffer_id;
alGenBuffers(1, &buffer_id);
// WAVデータを読み込む
Wav sound("res/lovelive.wav");
// 読み込んだWAVデータの波形をバッファにコピー
alBufferData(buffer_id,
// ステレオ or モノラル
sound.isStereo() ? AL_FORMAT_STEREO16
: AL_FORMAT_MONO16,
sound.data(), // リニアPCM形式データ
sound.size(), // サイズ(バイト数)
sound.sampleRate()); // サンプリングレート
// ソースの生成
ALuint source_id;
alGenSources(1, &source_id);
// ソースに再生したいバッファを割り当てる
alSourcei(source_id, AL_BUFFER, buffer_id);
// ピッチ変更
alSourcef(source_id, AL_PITCH, -1.0);
// ループ再生ON
alSourcei(source_id, AL_LOOPING, AL_TRUE);
// ソースの再生開始
alSourcePlay(source_id);
// Windowが閉じられるまで繰り返す
while (!glfwWindowShouldClose(window)) {
// 描画領域をクリア
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
// 画面とバックバッファを入れ替える
glfwSwapBuffers(window);
// キー入力などのイベント処理
glfwPollEvents();
}
// ソースの破棄
alDeleteSources(1, &source_id);
// バッファの破棄
alDeleteBuffers(1, &buffer_id);
// OpenALの後始末
alcMakeContextCurrent(nullptr);
alcDestroyContext(context);
alcCloseDevice(device);
// GLFWの後始末
glfwTerminate();
return 0;
}
开发者ID:mid-winter,项目名称:SUSHI,代码行数:90,代码来源:WAVを読み込んで再生.cpp
示例20: ranged_helper
/**
* This is a helper function used by do_cmd_throw and do_cmd_fire.
*
* It abstracts out the projectile path, display code, identify and clean up
* logic, while using the 'attack' parameter to do work particular to each
* kind of attack.
*/
static void ranged_helper(int item, int dir, int range, int shots, ranged_attack attack) {
/* Get the ammo */
object_type *o_ptr = object_from_item_idx(item);
int i, j;
byte missile_attr = object_attr(o_ptr);
char missile_char = object_char(o_ptr);
object_type object_type_body;
object_type *i_ptr = &object_type_body;
char o_name[80];
int path_n;
u16b path_g[256];
int msec = op_ptr->delay_factor;
/* Start at the player */
int x = p_ptr->px;
int y = p_ptr->py;
/* Predict the "target" location */
s16b ty = y + 99 * ddy[dir];
s16b tx = x + 99 * ddx[dir];
bool hit_target = FALSE;
/* Check for target validity */
if ((dir == 5) && target_okay()) {
int taim;
char msg[80];
target_get(&tx, &ty);
taim = distance(y, x, ty, tx);
if (taim > range) {
sprintf (msg, "Target out of range by %d squares. Fire anyway? ",
taim - range);
if (!get_check(msg)) return;
}
}
/* Sound */
sound(MSG_SHOOT);
object_notice_on_firing(o_ptr);
/* Describe the object */
object_desc(o_name, sizeof(o_name), o_ptr, ODESC_FULL | ODESC_SINGULAR);
/* Actually "fire" the object -- Take a partial turn */
p_ptr->energy_use = (100 / shots);
/* Calculate the path */
path_n = project_path(path_g, range, y, x, ty, tx, 0);
/* Hack -- Handle stuff */
handle_stuff(p_ptr);
/* Start at the player */
x = p_ptr->px;
y = p_ptr->py;
/* Project along the path */
for (i = 0; i < path_n; ++i) {
int ny = GRID_Y(path_g[i]);
int nx = GRID_X(path_g[i]);
/* Hack -- Stop before hitting walls */
if (!cave_floor_bold(ny, nx)) break;
/* Advance */
x = nx;
y = ny;
/* Only do visuals if the player can "see" the missile */
if (player_can_see_bold(y, x)) {
print_rel(missile_char, missile_attr, y, x);
move_cursor_relative(y, x);
Term_fresh();
if (p_ptr->redraw) redraw_stuff(p_ptr);
Term_xtra(TERM_XTRA_DELAY, msec);
cave_light_spot(cave, y, x);
Term_fresh();
if (p_ptr->redraw) redraw_stuff(p_ptr);
} else {
/* Delay anyway for consistency */
Term_xtra(TERM_XTRA_DELAY, msec);
}
/* Handle monster */
//.........这里部分代码省略.........
开发者ID:Chiinatso,项目名称:Anquestria,代码行数:101,代码来源:attack.c
注:本文中的sound函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论