Changeset 9126


Ignore:
Timestamp:
2017-07-26 14:13:59 (6 years ago)
Author:
npo17_56
Message:

Ohjukset kopteria päin

Location:
2017/30/OlliL/Bomb helicopter/Bomb helicopter/Bomb_helicopter
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 2017/30/OlliL/Bomb helicopter/Bomb helicopter/Bomb_helicopter/Bomb_helicopter.cs

    r9122 r9126  
    2222    PhysicsObject ohjus; 
    2323    Image Ohjus = LoadImage("ohjuspieni"); 
     24     
     25 
    2426 
    2527 
     
    3941        Laukaisija(500, -450); 
    4042        Laukaisija(1400, -450); 
     43        
    4144 
    4245         
     
    8790        Add(helikopteri); 
    8891 
    89          
     92        AddCollisionHandler(helikopteri, "ohjus", OhjusTormaa); 
     93        // AddCollisionHandler(helikopteri, ohjus, OhjusTormaa); 
    9094    } 
     95 
     96     
    9197 
    9298    void HelikopteriTormaa(PhysicsObject tormaaja, PhysicsObject kohde) 
     
    132138    { 
    133139        PhysicsObject ohjus = new PhysicsObject(40.0, 60.0); 
     140         
    134141        ohjus.Image = Ohjus; 
    135142        ohjus.Position = laukaisija.Position; 
    136143        Add(ohjus); 
    137         ohjus.Hit(new Vector(0, 1200)); 
     144        ohjus.Tag = "ohjus"; 
     145         
    138146 
    139         Vector suunta = (helikopteri.Position - ohjus.Position).Normalize(); 
    140         ohjus.Angle = suunta.Angle; 
     147        Vector suunta = (ohjus.Position - helikopteri.Position).Normalize(); 
     148        ohjus.Angle = suunta.Angle+Angle.FromDegrees(90); 
     149        ohjus.MaximumLifetime = TimeSpan.FromSeconds(6); 
     150        ohjus.MoveTo(helikopteri.Position, 600); 
     151        //ohjus.Hit(Vector.FromLengthAndAngle(2000, ohjus.Angle)); 
    141152 
    142153    } 
     154 
     155    void OhjusTormaa(PhysicsObject tormaaja, PhysicsObject kohde) 
     156    { 
     157        //tormaaja.Velocity = new Vector(tormaaja.Velocity.X, 0); 
     158        kohde.Destroy(); 
     159        tormaaja.Destroy(); 
     160        MessageDisplay.Add("Game Over"); 
     161        Explosion rajahdys = new Explosion(200); 
     162        rajahdys.Position = helikopteri.Position; 
     163        Add(rajahdys); 
     164    } 
    143165} 
Note: See TracChangeset for help on using the changeset viewer.