Changeset 2241


Ignore:
Timestamp:
2011-06-28 14:59:42 (12 years ago)
Author:
janiemit
Message:

Talletus.

Location:
2011/26/JaniN
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/JaniN/neon wars/neon wars/neon wars/Peli.cs

    r2199 r2241  
    1616    GameObject pyssy; 
    1717 
     18    PhysicsObject alareuna; 
    1819 
    1920    public override void Begin() 
    2021    { 
     22 
     23 
     24         
    2125        aseta_näppäimet(); 
    2226        Mouse.IsCursorVisible = true; 
    2327         
    24         Ihansama = new PhysicsObject(50.0, 50.0); 
     28         
     29        Timer ajastin = new Timer(); 
     30        ajastin.Interval = 0.05; 
     31        ajastin.Trigger += TeeVihollinen; 
     32        ajastin.Start(); 
     33        //TeeVihollinen(ajastin); 
     34 
     35        Ihansama = PhysicsObject.CreateStaticObject(50.0, 50.0); 
    2536        Ihansama.X = 0; 
    26         Ihansama.Y = Level.Bottom+100; 
     37        Ihansama.Y = Level.Bottom + 100; 
    2738        Add(Ihansama); 
    28          
    29         pyssy = new GameObject(200, 15); 
     39       
     40 
     41        pyssy = new GameObject(100, 5); 
    3042        pyssy.Color = Color.Black; 
    3143        Ihansama.Add(pyssy); 
     
    3547        //HingeJoint liitos = PhysicsGame.CreateHingeJoint(Ihansama, pyssy, Ihansama.Position); 
    3648        //Add(liitos); 
    37         pyssy.Image = LoadImage("Untitled");  
     49        pyssy.Image = LoadImage("Untitled"); 
    3850        // Gravity = new Vector(0, -1000); 
    3951        Level.CreateBorders(); 
     52        alareuna = Level.CreateBottomBorder(); 
     53         
     54 
    4055    } 
     56 
    4157 
    4258 
     
    4561        Mouse.Listen(MouseButton.Left, ButtonState.Down, ampuu, null); 
    4662    } 
    47      
    48      
    49      
    50      
     63 
     64 
     65 
     66 
    5167    protected override void Update(Time time) 
    5268    { 
     
    6278    { 
    6379        PhysicsObject ammus = new PhysicsObject(5, 5); 
    64          
     80        ammus.Velocity = (Mouse.PositionOnWorld - Ihansama.Position).Normalize()*500; 
     81 
     82        //ammus.Push(Mouse.PositionOnWorld); 
     83        //ammus.Velocity *= 3; 
     84        ammus.Tag = "ammus"; 
     85        ammus.Destroyed += new Action(delegate { ammus_Destroyed(ammus); }); 
    6586        Add(ammus); 
    66         ammus.Position = Ihansama.Position; 
     87        ammus.Position = Ihansama.Position + (Mouse.PositionOnWorld - Ihansama.Position).Normalize()*((pyssy.Width/2)-14); 
     88 
     89        AddCollisionHandler(ammus, KasitteleAmmuksenTormays); 
     90        ammus.Shape = Shape.Circle; 
     91        ammus.Color = Color.Black; 
     92 
    6793    } 
     94 
     95    void ammus_Destroyed(PhysicsObject ammus) 
     96    { 
     97        Explosion rajahdys = new Explosion(70); 
     98        rajahdys.Position = ammus.Position; 
     99        rajahdys.Force = 0; 
     100        rajahdys.ShockwaveColor = Color.Transparent; 
     101        Add(rajahdys); 
     102    } 
     103 
     104    void KasitteleAmmuksenTormays(PhysicsObject ammus, PhysicsObject kohde) 
     105    { 
     106        if (kohde != Ihansama && kohde.Tag.ToString() != "ammus") ammus.Destroy(); 
     107        if (kohde != Ihansama && kohde.Tag.ToString() == "vihollinen") { kohde.Destroy(); } 
     108    } 
     109    void KasitteleVihollisenTormays(PhysicsObject vihollinen ,PhysicsObject kohde) 
     110    { 
     111        if (kohde == alareuna) vihollinen.Destroy();  
     112    } 
     113 
     114    void TeeVihollinen(Timer sender) 
     115    { 
     116        PhysicsObject vihollinen = new PhysicsObject(50, 50); 
     117        vihollinen.Shape = Shape.Rectangle; 
     118        vihollinen.Velocity = new Vector(0, 500); 
     119        vihollinen.X = RandomGen.NextDouble(Level.Left, Level.Right); 
     120        vihollinen.Y = Level.Top; 
     121        vihollinen.Tag = "vihollinen"; 
     122        vihollinen.Image = LoadImage("vihollinen"); 
     123        vihollinen.Angle = Angle.StraightAngle; 
     124        vihollinen.CanRotate = false; 
     125        AddCollisionHandler(vihollinen, KasitteleVihollisenTormays); 
     126        Add(vihollinen); 
     127    } 
     128 
    68129} 
  • 2011/26/JaniN/neon wars/neon wars/neon warsContent/neon warsContent.contentproj

    r2199 r2241  
    4949    </Compile> 
    5050  </ItemGroup> 
     51  <ItemGroup> 
     52    <Compile Include="vihollinen.png"> 
     53      <Name>vihollinen</Name> 
     54      <Importer>TextureImporter</Importer> 
     55      <Processor>TextureProcessor</Processor> 
     56    </Compile> 
     57  </ItemGroup> 
    5158  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    5259  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
Note: See TracChangeset for help on using the changeset viewer.