Changeset 1174


Ignore:
Timestamp:
2010-07-08 11:29:58 (9 years ago)
Author:
paaaanro
Message:
 
Location:
2010/27/patammi/Autopeli1
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2010/27/patammi/Autopeli1/Content/Content.contentproj

    r1155 r1174  
    1 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> 
     1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> 
    22  <PropertyGroup> 
    33    <ProjectGuid>df71e4f8-85ec-46e2-8dae-689bf7828c02</ProjectGuid> 
     
    2828    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 
    2929  </ItemGroup> 
     30  <ItemGroup> 
     31    <Compile Include="Explosion.png"> 
     32      <Name>Explosion</Name> 
     33      <Importer>TextureImporter</Importer> 
     34      <Processor>TextureProcessor</Processor> 
     35    </Compile> 
     36    <Compile Include="Red.png"> 
     37      <Name>Red</Name> 
     38      <Importer>TextureImporter</Importer> 
     39      <Processor>TextureProcessor</Processor> 
     40    </Compile> 
     41    <Compile Include="Yellow.png"> 
     42      <Name>Yellow</Name> 
     43      <Importer>TextureImporter</Importer> 
     44      <Processor>TextureProcessor</Processor> 
     45    </Compile> 
     46  </ItemGroup> 
    3047  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    3148  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
  • 2010/27/patammi/Autopeli1/Ohjelma.cs

    r1155 r1174  
    1414    } 
    1515} 
    16  
  • 2010/27/patammi/Autopeli1/Peli.cs

    r1155 r1174  
    33using Jypeli.Widgets; 
    44using Jypeli.Assets; 
     5using Jypeli.Effects; 
    56 
    67public class Peli : TopDownPhysicsGame 
     
    910    Automobile auto2; 
    1011 
    11     LaserGun laserPyssy; 
    12     LaserGun LaserPyssy; 
    13      
     12    LaserGun laserPyssy1; 
     13    LaserGun laserPyssy2; 
     14 
     15    PhysicsObject OilBarrel; 
     16 
     17    ExplosionSystem es; 
     18 
    1419    protected override void Begin() 
    1520    { 
     
    1823        auto = new Automobile(40, 20); 
    1924        auto.Mass = 1.0; 
    20         auto.Color = new Color(0,0,0); 
     25        auto.Maneuverability = Angle.Degrees(120); 
     26        auto.Color = new Color(0, 0, 0); 
    2127        auto.AngularDamping = 0.9; 
    2228        Add(auto); 
    2329 
    24         laserPyssy = new LaserGun(20, 5); 
    25         auto.Add(laserPyssy); 
    26         LaserPyssy = new LaserGun(20, 5); 
     30        laserPyssy1 = new LaserGun(20, 5); 
     31        laserPyssy1.TimeBetweenUse = TimeSpan.FromSeconds(0.5); 
     32        auto.Add(laserPyssy1); 
     33        laserPyssy2 = new LaserGun(20, 5); 
    2734 
    2835        auto2 = new Automobile(40, 20); 
    2936        auto2.Mass = 10.0; 
     37        auto2.Maneuverability = Angle.Degrees(120); 
    3038        auto2.Color = new Color(192, 192, 255); 
    3139        auto2.AngularDamping = 0.9; 
    3240        Add(auto2); 
    3341 
    34         auto2.Add(LaserPyssy); 
     42        auto2.Add(laserPyssy2); 
    3543 
    36         
    37         for (int a = 0; a < 100; a++) 
     44 
     45        for (int a = 0; a < 10; a++) 
    3846        { 
    39             PhysicsObject laatikko = new PhysicsObject(10, 10); 
    40             laatikko.X = RandomGen.NextDouble(-4000, 4000); 
    41             Add(laatikko); 
     47            LisaaOilBarrel(); 
    4248        } 
    4349 
     
    4955        AsetaNappaimet(); 
    5056        AsetaXBoxOhjaimet(); 
     57        LataaRajahdys(); 
     58 
     59    } 
     60 
     61    void LataaRajahdys() 
     62    { 
     63        Image expl = LoadImage("Red"); 
     64        es = new ExplosionSystem(expl, 1000); 
     65        Add(es); 
     66 
    5167    } 
    5268 
    5369    void AsetaXBoxOhjaimet() 
    5470    { 
    55         ControllerOne.ListenAnalog (AnalogControl.LeftStick,0.1, LiikutaPelaajaa, "Liikuta pelaajaa tattia pyörittämällä."); 
     71        ControllerOne.ListenAnalog(AnalogControl.LeftStick, 0.1, LiikutaPelaajaa, "Liikuta pelaajaa tattia pyörittämällä."); 
    5672 
    57          
     73 
    5874    } 
    5975    void LiikutaPelaajaa(AnalogState state) 
    6076    { 
    61         auto.Turn(Angle.Degrees(state.StateVector.X*-4), Time.SinceLastUpdate.TotalSeconds); 
     77        auto.Turn(Angle.Degrees(state.StateVector.X * -4), Time.SinceLastUpdate.TotalSeconds); 
    6278    } 
    6379    void AsetaNappaimet() 
     
    6783        Keyboard.Listen(Key.Up, ButtonState.Down, kiihdyta, "Kiihdytä", auto); 
    6884        Keyboard.Listen(Key.Down, ButtonState.Down, jarruta, "Jarruta", auto); 
    69         Keyboard.Listen(Key.Left, ButtonState.Down, kaanny, "Käänny vasemmalle", auto, Angle.Degrees(1)); 
    70         Keyboard.Listen(Key.Right, ButtonState.Down, kaanny, "Käänny oikealle", auto, Angle.Degrees(-1)); 
     85        Keyboard.Listen(Key.Left, ButtonState.Down, kaanny, "Käänny vasemmalle", auto, Angle.Degrees(2)); 
     86        Keyboard.Listen(Key.Right, ButtonState.Down, kaanny, "Käänny oikealle", auto, Angle.Degrees(-2)); 
    7187 
    7288        Keyboard.Listen(Key.W, ButtonState.Down, kiihdyta, "Kiihdytä", auto2); 
    7389        Keyboard.Listen(Key.S, ButtonState.Down, jarruta, "Jarruta", auto2); 
    74         Keyboard.Listen(Key.A, ButtonState.Down, kaanny, "Käänny vasemmalle", auto2, Angle.Degrees(1)); 
    75         Keyboard.Listen(Key.D, ButtonState.Down, kaanny, "Käänny oikealle", auto2, Angle.Degrees(-1)); 
     90        Keyboard.Listen(Key.A, ButtonState.Down, kaanny, "Käänny vasemmalle", auto2, Angle.Degrees(2)); 
     91        Keyboard.Listen(Key.D, ButtonState.Down, kaanny, "Käänny oikealle", auto2, Angle.Degrees(-2)); 
    7692 
    7793 
    78         Keyboard.Listen(Key.M, ButtonState.Down, laserPyssy.Use, "ammu"); 
    79         Keyboard.Listen(Key.V, ButtonState.Down, LaserPyssy.Use, "ammu"); 
    80  
     94        Keyboard.Listen(Key.M, ButtonState.Down, laserPyssy1.Use, "ammu"); 
     95        Keyboard.Listen(Key.V, ButtonState.Down, laserPyssy2.Use, "ammu"); 
    8196 
    8297    } 
     
    85100    void laaserase() 
    86101    { 
    87  
    88      
    89     //laserPyssy.LaserCollision = LaserSadeOsuu; 
    90      
    91      
     102        //laserPyssy.LaserCollision = LaserSadeOsuu; 
    92103    } 
    93104 
    94      
     105 
    95106 
    96107 
     
    113124 
    114125 
     126    void Rajahdys(PhysicsObject tormaaja, PhysicsObject kohde) 
     127    { 
     128        es.AddEffect(tormaaja.X, tormaaja.Y, 20); 
     129        tormaaja.Destroy(); 
     130    } 
    115131 
    116  
    117  
     132    void LisaaOilBarrel() 
     133    { 
     134        OilBarrel = new PhysicsObject(15, 15, Shapes.Circle); 
     135        OilBarrel.Color = Color.Red; 
     136        OilBarrel.Mass = 100; 
     137        OilBarrel.LinearDamping = 0.9; 
     138        Add(OilBarrel); 
     139        AddCollisionHandler(OilBarrel, Rajahdys); 
     140        OilBarrel.X = RandomGen.NextDouble(Level.Left, Level.Right); 
     141        OilBarrel.Y = RandomGen.NextDouble(Level.Bottom, Level.Top); 
     142    } 
    118143 
    119144} 
Note: See TracChangeset for help on using the changeset viewer.