bool CMine_Sweeper::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int ok = true; int time; int redraw = false; int xpos; int ypos; if( !Get_Grid_Pos(xpos, ypos) ) return( false ); xpos/=SPRITE_SIZE; ypos/=SPRITE_SIZE; ypos=Mine_NY-1-ypos; switch( Mode ) { default: return( false ); case MODULE_INTERACTIVE_LDOWN: if(First_Click) { ResetBoard(xpos, ypos); First_Click=false; } ok = Play(xpos, ypos, false); redraw = true; break; case MODULE_INTERACTIVE_RDOWN: Mark(xpos, ypos); redraw = true; break; } if (redraw) { if(ok) { Show_GameBoard(false); time= Time->Time(); Message_Add(CSG_String::Format(SG_T(":-) Time:%ds Mines:%d\n"),time,N_Mines-MarkedMines)); if (OpenFields == Mine_NX*Mine_NY-N_Mines ) { Message_Add(CSG_String::Format(_TL(":-) :-) you are a winner :-) :-) Time:%ds\n"),time)); Message_Dlg(CSG_String::Format(_TL(":-) :-) you are a winner :-) :-) Time:%ds\n"),time)); Show_GameBoard(true); First_Click=true; } } else { Show_GameBoard(true); Message_Dlg(CSG_String::Format(_TL(":-( :-( you are a loser :-( :-("))); Message_Add(CSG_String::Format(_TL(":-( :-( you are a loser :-( :-("))); First_Click=true; } } return true; }
void JEffectInstance::Render() { JAnimation::Render(); if (!IsPlaying()) { return; } // modify transform by "attach-to" bone if (m_AttachInstance.size() > 0) { int boneID = -1; Mat4 boneTM = Mat4::identity; if (m_AttachInstance.size() > 0) { if (m_AttachInstanceID == -1) { JModelInstance* pModelInst = g_pObjectServer->FindObject<JModelInstance>( m_AttachInstance.c_str(), this ); if (pModelInst) { m_AttachInstanceID = pModelInst->GetInstanceID(); m_AttachBoneID = g_pModelServer->GetModelBoneID( pModelInst->GetModelID(), m_AttachBone.c_str() ); } } g_pModelServer->GetBoneTM( m_AttachInstanceID, m_AttachBoneID, boneTM ); } Mat3 rot; Vec3 scale; boneTM.factorize( scale, rot, m_Position ); if (m_bScreenSpace) { Mat4 tm; ProjToScreenTM( tm, g_pRenderServer->GetViewport() ); if (g_pRenderServer) { tm = g_pRenderServer->GetViewTM()*g_pRenderServer->GetProjTM()*tm; tm.tmproj( m_Position ); } } } float cTime = GetContext().m_Time; if (m_Stamp == g_pParticleServer->GetStamp()) { Vec3 pos = m_Position + GetContext().m_Pos; if (cTime - m_PrevTime > c_RestartTimeout) { Stop(); Play(); cTime = 0.0f; if (GetCurLoop() == 0) { cTime += GetStartTime(); } m_PrevTime = cTime; } if (!GetContext().m_bStateOnly) { g_pParticleServer->Render( m_InstanceID, cTime, pos, m_Scale, m_Alpha ); } m_PrevTime = cTime; } else { Stop(); } }
//----------------------------------------------------------------------------- // Purpose: Handle "cd" console command //----------------------------------------------------------------------------- void CCDAudio::CD_f ( void ) { char *command; int ret; int n; if ( Cmd_Argc() < 2 ) return; command = Cmd_Argv (1); if (stricmp(command, "on") == 0) { m_bEnabled = true; return; } if (stricmp(command, "off") == 0) { if (m_bIsPlaying) Stop(); m_bEnabled = false; return; } if (stricmp(command, "reset") == 0) { m_bEnabled = true; if (m_bIsPlaying) Stop(); for (n = 0; n < 100; n++) m_rgRemapCD[n] = n; GetAudioDiskInfo(); return; } if (stricmp(command, "remap") == 0) { ret = Cmd_Argc() - 2; if ( ret > 0) { for (n = 1; n <= ret; n++) { m_rgRemapCD[n] = atoi(Cmd_Argv (n+1)); } } return; } if (stricmp(command, "close") == 0) { CloseDoor(); return; } if (!m_bIsValid) { GetAudioDiskInfo(); if (!m_bIsValid) { return; } } if (stricmp(command, "play") == 0) { Play( atoi(Cmd_Argv (2)), false ); return; } if (stricmp(command, "loop") == 0) { Play( atoi(Cmd_Argv (2)), true ); return; } if (stricmp(command, "stop") == 0) { Stop(); return; } if (stricmp(command, "pause") == 0) { Pause(); return; } if (stricmp(command, "resume") == 0) { Resume(); return; } if (stricmp(command, "eject") == 0) { if (m_bIsPlaying) Stop(); Eject(); m_bIsValid = false; return; } if (stricmp(command, "info") == 0) { Msg("%u tracks\n", m_nMaxTrack); if ( m_bIsPlaying ) { Msg("Currently %s track %u\n", m_bIsLooping ? "looping" : "playing", m_nPlayTrack); } else if ( m_bWasPlaying ) { Msg("Paused %s track %u\n", m_bIsLooping ? "looping" : "playing", m_nPlayTrack); } Msg("Volume is %f\n", m_flVolume); return; } }
bool is_middle_ladder(Board *b, Coord coord, group_t laddered, Stone lcolor) { /* TODO: Remove the redundant parameters. */ assert(group_at(b, laddered)->liberties == 1); Coord last_lib = get_nlibs_of_group(b, laddered, 1, NULL); assert(last_lib == coord); assert(group_at(b, laddered)->color == lcolor); /* If we can move into empty space or do not have enough space * to escape, this is obviously not a ladder. */ if (immediate_liberty_count(b, coord) != 2) { /* if (DEBUGL(5)) fprintf(stderr, "no ladder, wrong free space\n"); */ return false; } /* A fair chance for a ladder. Group in atari, with some but limited * space to escape. Time for the expensive stuff - set up a temporary * board and start selective 2-liberty search. */ Board *bset = (Board *)malloc(BOARD_MAX_SIZE * 2 * sizeof(Board)); struct move_queue ccq = { .moves = 0 }; if (can_countercapture(b, lcolor, laddered, lcolor, &ccq, 0)) { /* We could escape by countercapturing a group. * Investigate. */ assert(ccq.moves > 0); for (unsigned int i = 0; i < ccq.moves; i++) { Board b2; CopyBoard(&b2, b); bool is_ladder = middle_ladder_walk(&b2, bset, laddered, ccq.move[i], lcolor); // board_done_noalloc(&b2); if (!is_ladder) { free(bset); return false; } } } Board b2; CopyBoard(&b2, b); Coord last_lib2 = get_nlibs_of_group(&b2, laddered, 1, NULL); bool is_ladder = middle_ladder_walk(&b2, bset, laddered, last_lib2, lcolor); // board_done_noalloc(&b2); free(bset); return is_ladder; } bool wouldbe_ladder(Board *b, group_t group, Coord escapelib, Coord chaselib, Stone lcolor) { assert(b->_groups[group].liberties == 2); assert(b->_groups[group].color == lcolor); /* if (DEBUGL(6)) fprintf(stderr, "would-be ladder check - does %s %s play out chasing move %s?\n", stone2str(lcolor), coord2sstr(escapelib, b), coord2sstr(chaselib, b)); */ if (!NEIGHBOR8(escapelib, chaselib)) { /* if (DEBUGL(5)) fprintf(stderr, "cannot determine ladder for remote simulated stone\n"); */ return false; } if (neighbor_count_at(b, chaselib, lcolor) != 1 || immediate_liberty_count(b, chaselib) != 2) { /* if (DEBUGL(5)) fprintf(stderr, "overly trivial for a ladder\n"); */ return false; } bool is_ladder = false; Board *bset = (Board *)malloc(BOARD_MAX_SIZE * 2 * sizeof(Board)); Board b2; CopyBoard(&b2, b); GroupId4 ids; if (TryPlay(&b2, X(chaselib), Y(chaselib), OPPONENT(lcolor), &ids)) { Play(&b2, &ids); Coord last_lib2 = get_nlibs_of_group(&b2, group, 1, NULL); is_ladder = middle_ladder_walk(&b2, bset, group, last_lib2, lcolor); } // board_done_noalloc(&b2); free(bset); return is_ladder; }
static bool middle_ladder_walk(Board *b, Board *bset, group_t laddered, Coord nextmove, Stone lcolor) { assert(group_at(b, laddered)->liberties == 1); /* First, escape. */ /* if (DEBUGL(6)) fprintf(stderr, " ladder escape %s\n", coord2sstr(nextmove, b)); */ GroupId4 ids; if (!TryPlay2(b, nextmove, &ids)) error("The play should never be wrong!"); Play(b, &ids); // laddered = group_at(b, laddered); /* if (DEBUGL(8)) { board_print(b, stderr); fprintf(stderr, "%s c %d\n", coord2sstr(laddered, b), board_group_info(b, laddered).libs); } */ int laddered_libs = b->_groups[laddered].liberties; if (laddered_libs == 1) { /* if (DEBUGL(6)) fprintf(stderr, "* we can capture now\n"); */ return true; } if (laddered_libs > 2) { /* if (DEBUGL(6)) fprintf(stderr, "* we are free now\n"); */ return false; } FOR4(nextmove, _, c) { if (board_at(b, c) == OPPONENT(lcolor) && group_at(b, c)->liberties == 1) { /* We can capture one of the ladder stones * anytime later. */ /* XXX: If we were very lucky, capturing * this stone will not help us escape. * That should be pretty rate. */ /* if (DEBUGL(6)) fprintf(stderr, "* can capture chaser\n"); */ return false; } } ENDFOR4 /* Now, consider alternatives. */ int liblist[2], libs = 0; Coord tmp_libs[2]; get_nlibs_of_group(b, laddered, 2, tmp_libs); for (int i = 0; i < 2; i++) { Coord ataristone = tmp_libs[i]; Coord escape = tmp_libs[1 - i]; if (immediate_liberty_count(b, escape) > 2 + NEIGHBOR4(ataristone, escape)) { /* Too much free space, ignore. */ continue; } liblist[libs++] = i; } /* Try out the alternatives. */ bool is_ladder = false; for (int i = 0; !is_ladder && i < libs; i++) { Board *b2 = b; if (i != libs - 1) { b2 = bset++; CopyBoard(b2, b); } Coord libs_b2[2]; get_nlibs_of_group(b2, laddered, 2, libs_b2); Coord ataristone = libs_b2[liblist[i]]; // Coord escape = board_group_info(b2, laddered).lib[1 - liblist[i]]; struct move m = { ataristone, OPPONENT(lcolor) }; bool play_successful = TryPlay2(b2, ataristone, &ids); if (play_successful) Play(b2, &ids); /* If we just played self-atari, abandon ship. */ /* XXX: If we were very lucky, capturing this stone will * not help us escape. That should be pretty rate. */ /* if (DEBUGL(6)) fprintf(stderr, "(%d=%d) ladder atari %s (%d libs)\n", i, res, coord2sstr(ataristone, b2), board_group_info(b2, group_at(b2, ataristone)).libs); */ if (play_successful && group_at(b2, ataristone)->liberties > 1) { Coord last_lib = get_nlibs_of_group(b2, laddered, 1, NULL); is_ladder = middle_ladder_walk(b2, bset, laddered, last_lib, lcolor); } /* Why we need to do deallocation? if (i != libs - 1) { board_done_noalloc(b2); } */ } /* if (DEBUGL(6)) fprintf(stderr, "propagating %d\n", is_ladder); */ return is_ladder; }
void USkeletalMeshComponent::PlayAnimation(class UAnimationAsset* NewAnimToPlay, bool bLooping) { SetAnimationMode(EAnimationMode::AnimationSingleNode); SetAnimation(NewAnimToPlay); Play(bLooping); }
//Create window message fuction. when the window is created, also initialize a instance of //GPAC player instance. LRESULT CGPAXPlugin::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (m_term) return 0; const char *str; if (m_hWnd==NULL) return 0; gf_sys_init(GF_FALSE); //Create a structure m_user for initialize the terminal. the parameters to set: //1)config file path //2)Modules file path //3)window handler //4)EventProc memset(&m_user, 0, sizeof(m_user)); gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_ERROR); m_user.config = gf_cfg_init(NULL, NULL); if(!m_user.config) { #ifdef _WIN32_WCE ::MessageBox(NULL, _T("GPAC Configuration file not found"), _T("Fatal Error"), MB_OK); #else ::MessageBox(NULL, "GPAC Configuration file not found", "Fatal Error", MB_OK); #endif goto err_exit; } /*check log file*/ str = gf_cfg_get_key(m_user.config, "General", "LogFile"); if (str) { m_pLogs = gf_f64_open(str, "wt"); if (m_pLogs) gf_log_set_callback(m_pLogs, gpax_do_log); } /*if logs are specified, use them*/ gf_log_set_tools_levels( gf_cfg_get_key(m_user.config, "General", "Logs") ); str = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory"); m_user.modules = gf_modules_new(NULL, m_user.config); if(!gf_modules_get_count(m_user.modules)) goto err_exit; m_user.os_window_handler = m_hWnd; m_user.opaque = this; m_user.EventProc = GPAX_EventProc; //create a terminal m_term = gf_term_new(&m_user); if (!m_term) goto err_exit; gf_term_set_option(m_term, GF_OPT_AUDIO_VOLUME, 100); LoadDATAUrl(); RECT rc; ::GetWindowRect(m_hWnd, &rc); m_width = rc.right-rc.left; m_height = rc.bottom-rc.top; if (m_bAutoStart && strlen(m_url)) Play(); return 0; //Error Processing err_exit: if(m_user.modules) gf_modules_del(m_user.modules); m_user.modules = NULL; if(m_user.config) gf_cfg_del(m_user.config); m_user.config = NULL; gf_sys_close(); return 1; }
int CSound::Play(int ChannelID, CSampleHandle SampleID, int Flags) { return Play(ChannelID, SampleID, Flags, 0, 0); }
bool SoundEffect::Play() { return Play(1.0f, 0, 0); }
void GameManager::InitGame() { Produce(_T("Background")); Produce(_T("Player")); Play(_T("BGM")); }
int CSound::PlayAt(int ChannelID, CSampleHandle SampleID, int Flags, float x, float y) { return Play(ChannelID, SampleID, Flags|ISound::FLAG_POS, x, y); }
void GameManager::CheckKey() { if (GameStart() && !GamePause() && !GameOver() ) { if (GetKey('w') || GetKey('W') || GetKey(VK_UP)) { MovePlane(Up); } if (GetKey('s') || GetKey('S') || GetKey(VK_DOWN)) { MovePlane(Down); } if (GetKey('a') || GetKey('A') || GetKey(VK_LEFT)) { MovePlane(Left); } if (GetKey('d') || GetKey('D') || GetKey(VK_RIGHT)) { MovePlane(Right); } if (!(GetKey('a') || GetKey('A') || GetKey(VK_LEFT)) && !(GetKey('d') || GetKey('D') || GetKey(VK_RIGHT)) ) { MovePlane(Stay); } //功能检测 if (GetKey('G') || GetKey('g')) { OnGod(); } if (GetKey('F') || GetKey('f')) { OffGod(); } if (GameManager::GetKey(VK_SPACE))//!GetPlayer()->Kill() { Player* p = GetPlayer(); if (p->FireStatus()) { Play(_T("Player_Shot")); Produce(_T("Weapon"), Point(p->X() + p->Width() / 2 - 3, p->Y() - 4), p->WeaponID()); } } if (GetKey('Q') || GetKey('q')) { Player* p = GetPlayer(); if (p->FireStatus()) { Produce(_T("Weapon"), Point(p->X() + p->Width() / 2 - 3, p->Y() - 4),11, GetList(Index_Enemy)); } } if (GetKey('Z') || GetKey('z')) { CList<GameObject*, GameObject*> *now = GetList(Index_Angela); POSITION pos = now->GetHeadPosition(); while (pos != NULL) { Angela* angela_ = static_cast<Angela*>(now->GetNext(pos)); if (angela_->Op() == 1) { angela_->SetX(GetPlayer()->X() - 80); angela_->SetY(GetPlayer()->Y()); angela_->Op(3, angela_->Position(), GetPlayer()->Position(), GetPlayer()->SpeedX(), GetPlayer()->SpeedY()); } else if (angela_->Op() == 2) { angela_->SetX(GetPlayer()->X() + 80); angela_->SetY(GetPlayer()->Y()); angela_->Op(3, angela_->Position(), GetPlayer()->Position(), GetPlayer()->SpeedX(), GetPlayer()->SpeedY()); } } } if (GetKey('X') || GetKey('x')) { CList<GameObject*, GameObject*> *now = GetList(Index_Angela); POSITION pos = now->GetHeadPosition(); while (pos != NULL) { Angela* angela_ = static_cast<Angela*>(now->GetNext(pos)); if (angela_->Op() == 1) { angela_->Op(1, angela_->Position(), GetPlayer()->Position(), 0,0); } else if (angela_->Op() == 2) { angela_->Op(2, angela_->Position(), GetPlayer()->Position(), 0,0); } } } if (GameManager::GetKey(VK_ESCAPE)) { PauseGame(); } } if (GameManager::GetKey(VK_RETURN)) { if (GameStart() && GamePause() ) { ResumeGame(); } else if(!GameStart()) { StartGame(); Play(_T("Mission_Begin")); } } }
void UMediaPlayer::HandlePlayerMediaEvent(EMediaEvent Event) { MediaEvent.Broadcast(Event); switch(Event) { case EMediaEvent::MediaClosed: OnMediaClosed.Broadcast(); break; case EMediaEvent::MediaOpened: Player->GetControls().SetLooping(Loop); Player->GetOutput().SetOverlaySink(this); if (SoundWave != nullptr) { Player->GetOutput().SetAudioSink(SoundWave); } if (VideoTexture != nullptr) { Player->GetOutput().SetVideoSink(VideoTexture); } OnMediaOpened.Broadcast(CurrentUrl); if (PlayOnOpen) { Play(); } break; case EMediaEvent::MediaOpenFailed: OnMediaOpenFailed.Broadcast(CurrentUrl); if (!Loop && (Playlist != nullptr)) { Next(); } break; case EMediaEvent::PlaybackEndReached: OnEndReached.Broadcast(); if (!Loop && (Playlist != nullptr)) { Next(); } break; case EMediaEvent::PlaybackResumed: OnPlaybackResumed.Broadcast(); break; case EMediaEvent::PlaybackSuspended: OnPlaybackSuspended.Broadcast(); break; case EMediaEvent::TracksChanged: SelectDefaultTracks(); break; } if ((Event == EMediaEvent::MediaOpened) || (Event == EMediaEvent::MediaOpenFailed)) { UE_LOG(LogMediaAssets, Verbose, TEXT("Media Info:\n\n%s"), *Player->GetInfo()); } }
GlobalShortcuts::GlobalShortcuts(QWidget* parent) : QWidget(parent), gnome_backend_(nullptr), system_backend_(nullptr), use_gnome_(false), rating_signals_mapper_(new QSignalMapper(this)) { settings_.beginGroup(kSettingsGroup); // Create actions AddShortcut("play", tr("Play"), SIGNAL(Play())); AddShortcut("pause", tr("Pause"), SIGNAL(Pause())); AddShortcut("play_pause", tr("Play/Pause"), SIGNAL(PlayPause()), QKeySequence(Qt::Key_MediaPlay)); AddShortcut("stop", tr("Stop"), SIGNAL(Stop()), QKeySequence(Qt::Key_MediaStop)); AddShortcut("stop_after", tr("Stop playing after current track"), SIGNAL(StopAfter())); AddShortcut("next_track", tr("Next track"), SIGNAL(Next()), QKeySequence(Qt::Key_MediaNext)); AddShortcut("prev_track", tr("Previous track"), SIGNAL(Previous()), QKeySequence(Qt::Key_MediaPrevious)); AddShortcut("inc_volume", tr("Increase volume"), SIGNAL(IncVolume())); AddShortcut("dec_volume", tr("Decrease volume"), SIGNAL(DecVolume())); AddShortcut("mute", tr("Mute"), SIGNAL(Mute())); AddShortcut("seek_forward", tr("Seek forward"), SIGNAL(SeekForward())); AddShortcut("seek_backward", tr("Seek backward"), SIGNAL(SeekBackward())); AddShortcut("show_hide", tr("Show/Hide"), SIGNAL(ShowHide())); AddShortcut("show_osd", tr("Show OSD"), SIGNAL(ShowOSD())); AddShortcut( "toggle_pretty_osd", tr("Toggle Pretty OSD"), SIGNAL(TogglePrettyOSD())); // Toggling possible only for pretty OSD AddShortcut("shuffle_mode", tr("Change shuffle mode"), SIGNAL(CycleShuffleMode())); AddShortcut("repeat_mode", tr("Change repeat mode"), SIGNAL(CycleRepeatMode())); AddShortcut("toggle_last_fm_scrobbling", tr("Enable/disable Last.fm scrobbling"), SIGNAL(ToggleScrobbling())); AddRatingShortcut("rate_zero_star", tr("Rate the current song 0 stars"), rating_signals_mapper_, 0); AddRatingShortcut("rate_one_star", tr("Rate the current song 1 star"), rating_signals_mapper_, 1); AddRatingShortcut("rate_two_star", tr("Rate the current song 2 stars"), rating_signals_mapper_, 2); AddRatingShortcut("rate_three_star", tr("Rate the current song 3 stars"), rating_signals_mapper_, 3); AddRatingShortcut("rate_four_star", tr("Rate the current song 4 stars"), rating_signals_mapper_, 4); AddRatingShortcut("rate_five_star", tr("Rate the current song 5 stars"), rating_signals_mapper_, 5); connect(rating_signals_mapper_, SIGNAL(mapped(int)), SIGNAL(RateCurrentSong(int))); // Create backends - these do the actual shortcut registration gnome_backend_ = new GnomeGlobalShortcutBackend(this); #ifndef Q_OS_DARWIN system_backend_ = new QxtGlobalShortcutBackend(this); #else system_backend_ = new MacGlobalShortcutBackend(this); #endif ReloadSettings(); }
SicilyToy::SicilyToy(){ timer = new QTimer(this); connect(timer,SIGNAL(timeout()),this,SLOT(Play())); timer -> start(1000); }
void FTimeline::PlayFromStart() { SetPlaybackPosition(0.f, false); Play(); }