Changeset 127

Show
Ignore:
Timestamp:
12/10/06 18:52:40 (5 years ago)
Author:
clayasaurus
Message:

sound for ship thrust

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/soundtest/arc/io/sound.d

    r125 r127  
    125125 
    126126    float       pitch = 1.0; 
    127     float       radius = 256; // The radius of the Sound that plays. 
     127    float       radius = 50;  // The radius of the Sound that plays. 
    128128    float       volume = 1.0; 
    129129    float       gain   = 1.0;  
  • branches/soundtest/classes/ship.d

    r125 r127  
    6464    // sound info 
    6565    Sound snd;  
     66    public: 
     67    bool isThrust = false;  
     68    bool prevThrust = false;  
     69 
     70    private: 
    6671 
    6772    // AI integers 
     
    465470        short myAlpha = getAlpha(); 
    466471        if( myAlpha < 255 ) setAlpha(myAlpha+1); 
     472 
    467473        // handle FU_OBJECT stuff 
     474 
    468475        super.handle_object(); 
    469476 
    470         if (this is PlayerShip) 
    471         { 
    472             arc.io.sound.setListenerPosition(getX, getY);  
    473             snd.setPosition(getX, getY); 
    474  
    475             if (arc.io.input.keyHit(SDLK_UP)) 
    476             { 
    477                 snd.play();  
    478                 snd.setPitch(1);  
    479             } 
    480             else if (!arc.io.input.keyDown(SDLK_UP)) 
    481             { 
    482                 snd.stop();  
    483             } 
    484              
    485             snd.process();  
    486         } 
     477 
    487478         
    488479        // handle all of my items 
     
    598589                                            if( straferMode == 1 ) thrust(ITEM_CLASS.STRAFER, 1); 
    599590                                            else thrust(ITEM_CLASS.STRAFER, -1); 
     591                                        } 
     592                                        else{ 
     593                                            isThrust = false;  
    600594                                        } 
    601595                                    } 
     
    763757        // handle space storm effects 
    764758        effectShip(this); 
     759 
     760        // handle sound code  
     761        if (this is PlayerShip) 
     762        { 
     763            // set listener to location of playership 
     764            arc.io.sound.setListenerPosition(getX, getY);  
     765        } 
     766 
     767        // set sound position to position of ship 
     768        snd.setPosition(getX, getY); 
     769 
     770        if (isThrust == true && prevThrust == false) 
     771        { 
     772            snd.play();  
     773            snd.setPitch(.5);  
     774        } 
     775        else if (isThrust == false) 
     776        { 
     777            snd.stop();  
     778        } 
     779 
     780        snd.process();  
    765781    } 
    766782    // return this ship's default action 
     
    841857        } 
    842858        float d_angle = angDest - getRotation(); 
    843         if ( (d_angle < 180 && d_angle >= 0) || (d_angle < -180.) ) thrust(ITEM_CLASS.TURNER, 1); 
    844         else thrust(ITEM_CLASS.TURNER, -1); 
     859 
     860        if ( (d_angle < 180 && d_angle >= 0) || (d_angle < -180.) ){ 
     861            thrust(ITEM_CLASS.TURNER, 1); 
     862            return angDist;  
     863        } else { 
     864            thrust(ITEM_CLASS.TURNER, -1); 
     865            return angDist;  
     866        } 
     867 
     868        isThrust = false;  
    845869        return angDist; 
    846870    } 
     
    855879            thrust(ITEM_CLASS.ENGINE, -1); 
    856880            return targetDistance; 
     881        }else{ 
     882            isThrust = false;  
    857883        } 
    858884        if( angDistance > 45 ) return targetDistance; 
     
    861887                if( thrust(ITEM_CLASS.CRUISER, 1) == false ) { 
    862888                    thrust(ITEM_CLASS.ENGINE, 1); 
     889                }else{ 
     890                    isThrust = false;  
    863891                } 
    864892                usingCruiser = true; 
     
    875903                    thrust(ITEM_CLASS.AFTERBURNER, 1); 
    876904                    return targetDistance; 
     905                }else{ 
     906                    isThrust=false;  
    877907                } 
    878908            } 
    879909        } 
     910        // THRUST=FALSE? 
    880911        thrust(ITEM_CLASS.ENGINE, 1); 
    881912        return targetDistance; 
     
    921952        setFriction(true); 
    922953        int angle_offset = 0; 
     954 
    923955        bool success = false; 
     956 
    924957        if( itemClassUsed == ITEM_CLASS.STRAFER ) angle_offset = 90; 
    925958        items.reset(); 
     
    934967                            super.max_speed = items.data.getVars().maximum; 
    935968                            super.accelerate(amount, angle_offset, false, this); 
     969 
    936970                            if( getAlpha() > 200 && rand()%2==0) { 
    937971                                FU_PARTICLE newParticle; 
    938972                                switch(itemClassUsed) { 
    939973                                case ITEM_CLASS.ENGINE: 
     974 
    940975                                case ITEM_CLASS.STRAFER: 
    941976                                    newParticle = new FU_PARTICLE(this,255,150,100); 
     
    951986                            } 
    952987                        } 
    953                         else super.turn(amount); 
     988                        else  
     989                        { 
     990                            super.turn(amount); 
     991                        } 
    954992                    } 
    955993                } 
    956994            } 
    957995        } 
     996 
     997        isThrust = success;  
     998         
    958999        return success; 
    9591000    } 
     1001 
    9601002    int getStormProtection() { return stormProtection; } 
    9611003    void maxUtils() { 
  • branches/soundtest/derelict/opengl/glu.d

    r124 r127  
    285285// TYPES 
    286286//============================================================================== 
    287 struct GLUnurbs; 
    288 struct GLUquadric; 
    289 struct GLUtesselator; 
     287struct GLUnurbs{} 
     288struct GLUquadric{} 
     289struct GLUtesselator{} 
    290290 
    291291typedef GLUnurbs GLUnurbsObj; 
  • branches/soundtest/run-build.bat

    r124 r127  
    1 bud FreeUniverse.d -Rn -full -cleanup -debug -g -v1 | more 
     1bud FreeUniverse.d -d -Rn -full -cleanup -debug -g -v1 | more 
    22PAUSE 
    33 
  • branches/soundtest/space/handler.d

    r124 r127  
    4040    }    
    4141    if( PlayerShip.getArmor() > 0 ) { 
     42 
     43        PlayerShip.prevThrust = PlayerShip.isThrust;  
     44 
    4245        if( arc.io.input.keyDown(SDLK_DOWN) ) { 
    4346            PlayerShip.thrust(ITEM_CLASS.ENGINE,-1); 
    4447        } else if( arc.io.input.keyDown(SDLK_UP) ) { 
    4548            PlayerShip.thrust(ITEM_CLASS.ENGINE,1); 
    46         } 
     49        }else{ 
     50            PlayerShip.isThrust=false; 
     51        } 
     52         
    4753        if( arc.io.input.keyDown(SDLK_RIGHT) ) { 
    4854            PlayerShip.thrust(ITEM_CLASS.TURNER,1); 
     
    5056            PlayerShip.thrust(ITEM_CLASS.TURNER,-1); 
    5157        } 
     58 
    5259        if( arc.io.input.keyDown(SDLK_SPACE) ) { 
    5360            PlayerShip.thrust(ITEM_CLASS.AFTERBURNER,1);