Changeset 83

Show
Ignore:
Timestamp:
12/04/07 17:45:16 (1 year ago)
Author:
clayasaurus
Message:

player machine gun sound effects

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/bullet.d

    r81 r83  
    3434    // if a laserbolt hits something, remove it 
    3535     
    36     // TODO: if the Bullet collides with something, do something 
     36    // TODO: if the Bullet collides with something, remove the bullet 
    3737    void onCollideStart(Body a, Body b) 
    3838    { 
  • trunk/src/engine.d

    r74 r83  
    5555            arc.input.open(); 
    5656            arc.time.open(); 
     57            arc.sound.open(); 
    5758 
    5859            logger.info("Starting GUI...");          
     
    8485        arc.input.close(); 
    8586        arc.window.close(); 
     87        arc.sound.close(); 
    8688    } 
    8789     
     
    163165        arc.scenegraph.drawable.drawScenegraph(); 
    164166        arc.time.limitFPS(60); 
     167        arc.sound.process();  
    165168    } 
    166169 
  • trunk/src/player.d

    r81 r83  
    1212    arc.window, 
    1313    arc.input; 
     14     
     15import tank;  
    1416     
    1517     
     
    4042        //setParent(null); 
    4143        //physics.sigSustainedPostCollide.detach(&onCollide); 
     44         
     45        // kill player if it touches the tank 
     46        if(cast(Tank)b.getParent() !is null) 
     47        { 
     48            w.removeChild(this);  
     49            alive = false; 
     50        } 
    4251    } 
    4352     
     
    108117        //image.draw(); 
    109118    }*/ 
     119     
     120    void playFire() 
     121    { 
     122        fireSound.play(); 
     123    } 
     124     
     125    bool alive=true;  
    110126         
    111127private: 
    112128    //8. Laser bolt vars 
    113     World w; 
     129   World w; 
    114130    Body physics; 
    115131    Frame image; 
     132    Sound fireSound;   
    116133//  Bullet[] bullets; 
    117134 
     
    123140        // for all instances of LaserBolt 
    124141        image = new Frame(Texture("images/Player-standing.png")); 
     142        fireSound = new Sound(new SoundFile("sound/machine_gun.wav")); 
     143        fireSound.setLoop(false);  
     144        registerAutoProcessSound(fireSound); 
    125145    }    
    126146     
  • trunk/src/tilemap.d

    r81 r83  
    368368        } 
    369369       
    370         if (arc.input.keyPressed(' ')
     370        if (arc.input.keyPressed(' ') && player.alive
    371371        { 
    372372            bullets ~= Bullet.addBullet(playerLoc + Point.fromPolar(32, player.transform.rotation - PI/2), player.transform.rotation, this); 
     373            player.playFire(); 
    373374        }  
    374375         
    375376        foreach (inout Bullet b; bullets) 
    376377            b.process();  
     378    } 
     379     
     380    void resetGame() 
     381    { 
     382        bullets.length=0;  
     383        tanks.length=0;  
     384        helicopters.length=0;  
     385        rootNode.deleteAllChildTrees(); 
     386        loadLevel(); 
    377387    } 
    378388