Changeset 3300 for 2012/26


Ignore:
Timestamp:
2012-06-28 10:36:41 (11 years ago)
Author:
sijoseha
Message:

Talletus.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2012/26/OlliL/SpaceImpact2/SpaceImpact2/SpaceImpact2/SpaceImpact2.cs

    r3280 r3300  
    99public class SpaceImpact2 : PhysicsGame 
    1010{ 
     11 
    1112    Vector nopeusYlos = new Vector(0, 300); 
    1213    Vector nopeusAlas = new Vector(0, -300); 
     
    1617    PhysicsObject laser; 
    1718 
     19    List<PhysicsObject> vihut= new List<PhysicsObject>(); 
    1820 
    1921    public override void Begin() 
    2022    { 
     23        SetWindowSize(800, 480, false); 
     24 
    2125        Luokentta(); 
    2226        AloitaPeli(); 
    2327        AsetaOhjaimet(); 
    2428 
     29        // Level.Size = new Vector(800, 480); 
     30 
    2531        Level.Background.CreateStars(10000); 
    26         SetWindowSize(800, 480, false); 
     32        LuoPistelaskuri(); 
    2733 
    2834    } 
     
    3036    { 
    3137        Level.BackgroundColor = Color.Black; 
     38        Level.Width = 800; 
     39        Level.Height = 480; 
    3240        Level.CreateBorders(1.0, true); 
    33  
     41        Camera.ZoomToLevel(); 
    3442        alus = Luoalus(Level.Left + 250.0, 0.0); 
    35         Camera.ZoomToLevel(1500); 
    3643    } 
    3744    void AloitaPeli() 
     
    5360        alus.Shape = Shape.Diamond; 
    5461        alus.Color = Color.Magenta; 
     62        alus.CollisionIgnoreGroup = 1; 
    5563        alus.X = x; 
    5664        alus.Y = y; 
     
    5866        return alus; 
    5967    } 
     68 
    6069    PhysicsObject Luovihu(double x, double y) 
    6170    { 
     
    6372        vihu.Color = RandomGen.NextColor(); 
    6473        vihu.Shape = Shape.Circle; 
    65         // vihu.LifetimeLeft = TimeSpan.FromSeconds(9.0); 
     74        vihu.Tag = "vihu"; 
    6675        vihu.X = x; 
    6776        vihu.Y = y; 
     
    6978        vihu.Hit(new Vector(-100, 0)); 
    7079        Add(vihu); 
    71         AddCollisionHandler(vihu, CollisionHandler.DestroyObject); 
     80        vihut.Add(vihu); 
     81        AddCollisionHandler(vihu, CollisionHandler.DestroyObject);      
     82        return vihu; 
     83    } 
    7284 
    73         vihu.Destroyed += delegate 
    74         { 
    75             Explosion rajahdys = new Explosion(100); 
    76             rajahdys.Position = vihu.Position; 
    77             rajahdys.Speed = 500.0; 
    78             rajahdys.Force = 10000; 
    79             rajahdys.ShockwaveColor = Color.Orange; 
    80             Add(rajahdys); 
    81         }; 
    82  
    83         return vihu; 
    84  
    85     } 
    8685    void Luolaser() 
    8786    { 
     
    8988        laser.Shape = Shape.Rectangle; 
    9089        laser.Color = Color.Red; 
     90        laser.CollisionIgnoreGroup = 1; 
    9191        AddCollisionHandler(laser, CollisionHandler.DestroyObject); 
     92        AddCollisionHandler(laser, "vihu", delegate(PhysicsObject ammus, PhysicsObject vihu) 
     93        { 
     94            Explosion rajahdys = new Explosion(100); 
     95            rajahdys.Position = vihu.Position; 
     96            rajahdys.Speed = 500.0; 
     97            rajahdys.Force = 0; 
     98            rajahdys.ShockwaveColor = Color.Orange; 
     99            Add(rajahdys); 
     100        } 
     101        ); 
    92102        laser.Position = alus.Position; 
    93103        Add(laser); 
    94104        Vector impulssi = new Vector(500.0, 0.0); 
    95         laser.Hit(impulssi); 
    96  
    97          
     105        laser.Hit(impulssi);        
    98106 
    99107       // Explosion rajahdys = new Explosion(100); 
     
    135143        while (laskuri < 3) 
    136144        { 
    137             Luovihu(Level.Right - 56, RandomGen.NextDouble(Level.Bottom + 28, Level.Top - 28)); 
     145            double y = RandomGen.NextDouble( 
     146                Level.Bottom + 28, Level.Top - 28 
     147                ); 
     148            Luovihu(Level.Right - 57, y); 
    138149            laskuri++; 
    139150        } 
     
    149160        } 
    150161    } 
     162     
     163    void LuoPistelaskuri() 
     164    { 
     165         
     166        pisteLaskuri = new IntMeter(0); 
     167 
     168        Label pisteNaytto = new Label(); 
     169        pisteNaytto.Title = "Points"; 
     170        pisteNaytto.X = Screen.Left + 200; 
     171        pisteNaytto.Y = Screen.Top - 50; 
     172        pisteNaytto.TextColor = Color.Black; 
     173        pisteNaytto.Color = Color.White; 
     174 
     175        pisteNaytto.BindTo(pisteLaskuri); 
     176        Add(pisteNaytto); 
     177 
     178    } 
     179 
     180    public IntMeter pisteLaskuri { get; set; } 
    151181} 
     182 
Note: See TracChangeset for help on using the changeset viewer.