void CWeaponGravityGun::SoundUpdate( void ) { int newState; if ( m_hObject ) newState = SS_LOCKEDON; else newState = SS_SCANNING; if ( newState != m_soundState ) { SoundStop(); m_soundState = newState; SoundStart(); } switch( m_soundState ) { case SS_SCANNING: break; case SS_LOCKEDON: { CPASAttenuationFilter filter( this ); float height = m_hObject->GetAbsOrigin().z - m_originalObjectPosition.z; // go from pitch 90 to 150 over a height of 500 int pitch = 90 + (int)UTIL_LineFraction( height, 0, 500, 60 ); assert(m_sndLockedOn!=NULL); if ( m_sndLockedOn != NULL ) { (CSoundEnvelopeController::GetController()).SoundChangePitch( m_sndLockedOn, pitch, 0.0f ); } // attenutate the movement sounds over 200 units of movement float distance = UTIL_LineFraction( m_movementLength, 0, 200, 1.0 ); // blend the "mass" sounds between 50 and 500 kg IPhysicsObject *pPhys = GetPhysObjFromPhysicsBone( m_hObject, m_physicsBone ); if ( pPhys == NULL ) { // we no longer exist! break; } float fade = UTIL_LineFraction( pPhys->GetMass(), 50, 500, 1.0 ); (CSoundEnvelopeController::GetController()).SoundChangeVolume( m_sndLightObject, fade * distance, 0.0f ); (CSoundEnvelopeController::GetController()).SoundChangeVolume( m_sndHeavyObject, (1.0 - fade) * distance, 0.0f ); } break; } }
int InitLemm( void ) { int i; #ifdef USEX FBFlushGrafic(); #endif FBFillRect( 0, 0, 720, 576, STEELBLUE ); FBFillRect( 60, 448, 300, 100, BLACK ); if ( !bgImage ) { FBDrawString(64,482,32,"Initialize...",WHITE,0); FBDrawFx2Logo( 320, 486 ); #ifdef USEX FBFlushGrafic(); #endif initNumbers(); if ( LoadPics() == -1 ) return -1; bgImage=malloc(1600*160); SoundStart(); } if ( !bgImage ) return -1; for( i=0; i<12; i++ ) svdimage[i]=malloc(32*48); for( i=0; i<320; i+=32 ) inSc( 19, 0, i+main_x, 352, 1 ); inSc( 29, 0, 66+main_x, 370, 1 ); inSc( 29, 1, 100+main_x, 372, 1 ); inSc( 8, 0, 134+main_x, 372, 0 ); // explosion inSc( 4, 10, 166+main_x, 374, 1 ); // lemming2 inSc( 29, 2, 200+main_x, 368, 1 ); inSc( 29, 3, 234+main_x, 368, 1 ); inSc( 29, 4, 264+main_x, 372, 1 ); inSc( 5, 2, 292+main_x, 368, 1 ); inSc( 20, 0, 320+main_x, 352, 1 ); FBDrawString(44,390,48,"-",GREEN,0); FBDrawString(76,390,48,"+",GREEN,0); return 0; }
void CWeaponGravityGun::SoundUpdate( void ) { int newState; if ( m_hObject ) newState = SS_LOCKEDON; else newState = SS_SCANNING; if ( newState != m_soundState ) { SoundStop(); m_soundState = newState; SoundStart(); } switch( m_soundState ) { case SS_SCANNING: break; case SS_LOCKEDON: { CPASAttenuationFilter filter( GetOwner() ); filter.MakeReliable(); float height = m_hObject->GetAbsOrigin().z - m_originalObjectPosition.z; // go from pitch 90 to 150 over a height of 500 int pitch = 90 + (int)UTIL_LineFraction( height, 0, 500, 60 ); CSoundParameters params; if ( GetParametersForSound( "Weapon_Physgun.LockedOn", params, NULL ) ) { EmitSound_t ep( params ); ep.m_nFlags = SND_CHANGE_VOL | SND_CHANGE_PITCH; ep.m_nPitch = pitch; EmitSound( filter, GetOwner()->entindex(), ep ); } // attenutate the movement sounds over 200 units of movement float distance = UTIL_LineFraction( m_movementLength, 0, 200, 1.0 ); // blend the "mass" sounds between 50 and 500 kg IPhysicsObject *pPhys = m_hObject->VPhysicsGetObject(); float fade = UTIL_LineFraction( pPhys->GetMass(), 50, 500, 1.0 ); if ( GetParametersForSound( "Weapon_Physgun.LightObject", params, NULL ) ) { EmitSound_t ep( params ); ep.m_nFlags = SND_CHANGE_VOL; ep.m_flVolume = fade * distance; EmitSound( filter, GetOwner()->entindex(), ep ); } if ( GetParametersForSound( "Weapon_Physgun.HeavyObject", params, NULL ) ) { EmitSound_t ep( params ); ep.m_nFlags = SND_CHANGE_VOL; ep.m_flVolume = (1.0 - fade) * distance; EmitSound( filter, GetOwner()->entindex(), ep ); } } break; } }
void CWeaponGravityGun::SoundCreate( void ) { m_soundState = SS_SCANNING; SoundStart(); }
//***************************************************************************** // // This application performs simple audio synthesis and playback based on the // keys pressed on the touch screen virtual piano keyboard. // //***************************************************************************** int main(void) { uint32_t ui32SysClock, ui32OldKey, ui32NewKey; tContext sContext; // // Run from the PLL at 120 MHz. // ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(ui32SysClock); // // Initialize the graphics context. // GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&sContext, "synth"); // // Draw the keys on the virtual piano keyboard. // DrawWhiteKeys(&sContext); DrawBlackKeys(&sContext); // // Initialize the touch screen driver. // TouchScreenInit(ui32SysClock); TouchScreenCallbackSet(TouchCallback); // // Initialize the sound driver. // SoundInit(ui32SysClock); SoundVolumeSet(128); SoundStart(g_pi16AudioBuffer, AUDIO_SIZE, 64000, SoundCallback); // // Default the old and new key to not pressed so that the first key press // will be properly drawn on the keyboard. // ui32OldKey = NUM_WHITE_KEYS + NUM_BLACK_KEYS; ui32NewKey = NUM_WHITE_KEYS + NUM_BLACK_KEYS; // // Loop forever. // while(1) { // // See if the first half of the sound buffer needs to be filled. // if(HWREGBITW(&g_ui32Flags, FLAG_PING) == 1) { // // Synthesize new audio into the first half of the sound buffer. // ui32NewKey = GenerateAudio(g_pi16AudioBuffer, AUDIO_SIZE / 2); // // Clear the flag for the first half of the sound buffer. // HWREGBITW(&g_ui32Flags, FLAG_PING) = 0; } // // See if the second half of the sound buffer needs to be filled. // if(HWREGBITW(&g_ui32Flags, FLAG_PONG) == 1) { // // Synthesize new audio into the second half of the sound buffer. // ui32NewKey = GenerateAudio(g_pi16AudioBuffer + (AUDIO_SIZE / 2), AUDIO_SIZE / 2); // // Clear the flag for the second half of the sound buffer. // HWREGBITW(&g_ui32Flags, FLAG_PONG) = 0; } // // See if a different key has been pressed. // if(ui32OldKey != ui32NewKey) { // // See if the old key was a white key. // if(ui32OldKey < NUM_WHITE_KEYS) { // // Redraw the face of the white key so that it no longer shows // as being pressed. // FillWhiteKey(&sContext, ui32OldKey, ClrWhiteKey); } // // See if the old key was a black key. // else if(ui32OldKey < (NUM_WHITE_KEYS + NUM_BLACK_KEYS)) { // // Redraw the face of the black key so that it no longer shows // as being pressed. // FillBlackKey(&sContext, ui32OldKey - NUM_WHITE_KEYS, ClrBlackKey); } // // See if the new key is a white key. // if(ui32NewKey < NUM_WHITE_KEYS) { // // Redraw the face of the white key so that it is shown as // being pressed. // FillWhiteKey(&sContext, ui32NewKey, ClrPressed); } // // See if the new key is a black key. // else if(ui32NewKey < (NUM_WHITE_KEYS + NUM_BLACK_KEYS)) { // // Redraw the face of the black key so that it is shown as // being pressed. // FillBlackKey(&sContext, ui32NewKey - NUM_WHITE_KEYS, ClrPressed); } // // Save the new key as the old key. // ui32OldKey = ui32NewKey; } } }
//***************************************************************************** // // A simple demonstration of the features of the TivaWare Graphics Library. // //***************************************************************************** int main(void) { tContext sContext; uint32_t ui32SysClock; // // Run from the PLL at 120 MHz. // ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(ui32SysClock); // // Initialize the graphics context. // GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&sContext, "grlib-demo"); // // Configure and enable uDMA // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); SysCtlDelay(10); ROM_uDMAControlBaseSet(&psDMAControlTable[0]); ROM_uDMAEnable(); // // Initialize the sound driver. // SoundInit(ui32SysClock); SoundVolumeSet(128); SoundStart(g_pi16AudioBuffer, AUDIO_SIZE, 64000, SoundCallback); // // Initialize the touch screen driver and have it route its messages to the // widget tree. // TouchScreenInit(ui32SysClock); TouchScreenCallbackSet(WidgetPointerMessage); // // Add the title block and the previous and next buttons to the widget // tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious); WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle); WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext); // // Add the first panel to the widget tree. // g_ui32Panel = 0; WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels); CanvasTextSet(&g_sTitle, g_pcPanelNames[0]); // // Issue the initial paint request to the widgets. // WidgetPaint(WIDGET_ROOT); // // Loop forever handling widget messages. // while(1) { // // Process any messages in the widget message queue. // WidgetMessageQueueProcess(); // // See if the first half of the sound buffer needs to be filled. // if(HWREGBITW(&g_ui32Flags, FLAG_PING) == 1) { // // generate new audio into the first half of the sound buffer. // GenerateAudio(g_pi16AudioBuffer, AUDIO_SIZE / 2); // // Clear the flag for the first half of the sound buffer. // HWREGBITW(&g_ui32Flags, FLAG_PING) = 0; } // // See if the second half of the sound buffer needs to be filled. // if(HWREGBITW(&g_ui32Flags, FLAG_PONG) == 1) { // // generate new audio into the second half of the sound buffer. // GenerateAudio(g_pi16AudioBuffer + (AUDIO_SIZE / 2), AUDIO_SIZE / 2); // // Clear the flag for the second half of the sound buffer. // HWREGBITW(&g_ui32Flags, FLAG_PONG) = 0; } } }
int main() { int TempAngleGrab; //because the pod takes time to move, //grab the current angle, start moving the pod //then call the body turn function //(pod moves while body is turning int WhiteLine = 1; int Old, done=0; int RoomNum = 0; //------------------------------------------------------------------- // DO NOT EDIT BELOW THIS LINE! //------------------------------------------------------------------- Initialize(); // Function sets port direction bits and calls // setup routines for all of the chip's systems #if DEBUG>0 DEBUG_START(); #endif //------------------------------------------------------------------- // DO NOT EDIT ABOVE THIS LINE! //------------------------------------------------------------------- if(SOUNDSTART_ENABLE == 1) { char x = 1; LED_Turret(0); // Turn off LED turret. while(x == 1) { x = SoundStart(); } START_ENABLED = 1; } LED_Turret(2); // Turn on LED turret showing we are running. LATFbits.LATF6 = 1; // Turn on Status LED //HardwareDelayNmSec(500); while(1) { Forward_Dist(5800); // Forward over the stairs and to the first room. (about 60 inches) SERVO_ADJUST_TURRET(-70); // Look to the left HardwareDelayNmSec(100); // wait for turret to move if (UVCheck()) { HOTROOM = 1; // Set room number //TempAngleGrab = SERVO_TURRET_ANGLE; SERVO_ADJUST_TURRET(0); // turn the turret first, it turns while the body is turning Turn(-90); // Forward_Dist(1200); // Drive into the room (about 6 inches) HardwareDelayNmSec(100); Turn(30); Forward_Dist(500); // Drive into the room. LocateAndExtinguish(); } else //not in room 1, move on to two { SERVO_ADJUST_TURRET(0); // straight //Forward_Dist(1700); // Forward to Room 2. Turn(30); Forward_Dist(600); HardwareDelayNmSec(100); Turn(-30); Forward_Dist(1180); SERVO_ADJUST_TURRET(90); // Look to the right HardwareDelayNmSec(100); // wait for turret to move if(UVCheck()) { HOTROOM = 2; // Set room number TempAngleGrab = SERVO_TURRET_ANGLE; SERVO_ADJUST_TURRET(0); // straight Turn(TempAngleGrab); // Adjust body to turret position Forward_Dist(1200); // Drive into the room. HardwareDelayNmSec(100); Turn(30); Forward_Dist(500); // Drive into the room. LocateAndExtinguish(); } else//not in room 2, move on to three { SERVO_ADJUST_TURRET(0); Reverse_Dist(3400); ///3900); // Reverse to center of the room. HardwareDelayNmSec(1000); Turn(90); // Turn to the right Reverse_Dist(1900); // Back up to room 3. //Stop in front of room 3 SERVO_ADJUST_TURRET(90); // Look to the right HardwareDelayNmSec(100); // wait for turret to move if(UVCheck()) {//Flame Found! HOTROOM = 3; // Set room number TempAngleGrab = SERVO_TURRET_ANGLE; SERVO_ADJUST_TURRET(0); Turn(TempAngleGrab); // Adjust body to turret position Forward_Dist(1000); // Drive into the room. HardwareDelayNmSec(100); Turn(30); Forward_Dist(300); // Drive into the room. LocateAndExtinguish(); } else //not in room three - must be in four { SERVO_ADJUST_TURRET(0); //Forward_Dist(4400); // Drive to room 4 Forward_Dist(1550); HardwareDelayNmSec(100); Turn(45); Forward_Dist(848); HardwareDelayNmSec(100); Turn(-45); Forward_Dist(2200); //don't bother checking for UV - it's the only room left HOTROOM = 4; // Set room number HardwareDelayNmSec(1000); Turn(90); // Turn to the right Forward_Dist(1200); // Drive into the room. HardwareDelayNmSec(100); Turn(30); Forward_Dist(500); // Drive into the room. LocateAndExtinguish(); } } } ReturnFromLocateAndExtinguish(); HardwareDelayNmSec(0xFFFF); } }
func Switch() { var phase = GetPhase(); if(open) { if(GetAction() == "Open") { open = 0; SetAction("Closes"); if(update) { SoundStart(); Sound("iris_atlantis_close"); } else Sound("luke1"); } if(GetAction() == "Opens") { open = 0; SetAction("Closes"); if(update) { SoundStart(); Sound("iris_atlantis_close"); } else Sound("luke1"); SetPhase(20-phase); } if(GetAction() == "Closes") { return(1); } if(GetAction() == "Close") { return(1); } } else { if(GetAction() == "Open") { return(1); } if(GetAction() == "Opens") { return(1); } if(GetAction() == "Closes") { open = 1; SetAction("Opens"); if(update) { SoundStop(); Sound("iris_atlantis_open"); } else Sound("luke1"); SetPhase(20 - phase); } if(GetAction() == "Close") { open = 1; SetAction("Opens"); if(update) { SoundStop(); Sound("iris_atlantis_open"); } else Sound("luke1"); } } return(1); }