Changeset 4376


Ignore:
Timestamp:
2013-07-02 15:10:32 (10 years ago)
Author:
juiitamm
Message:

Talletus.

Location:
2013/27/Emil-AleksiK
Files:
16 added
2 edited

Legend:

Unmodified
Added
Removed
  • 2013/27/Emil-AleksiK/Pong/Pong/Pong/Pong.cs

    r4341 r4376  
    1111    PhysicsObject pallo; 
    1212    PhysicsObject maila; 
     13    Image laatikkokuva = LoadImage("laatikko"); 
    1314    public override void Begin() 
    1415    { 
     16        Level.Width *= 1.4; 
    1517        starttaa(); 
    1618        aloita(); 
    17           
    18         
    19  
     19         
     20         
    2021 
    2122        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
     
    3435    void liikuta(Vector suunta) 
    3536    { 
    36         if (maila.Right > Level.Right) 
     37        if (maila.Right > Level.Right && suunta.X >0) 
    3738        { 
    3839            maila.Velocity = Vector.Zero; 
    3940            return; 
    4041        } 
    41         if (maila.Left < Level.Left) 
     42        if (maila.Left < Level.Left && suunta.X < 0) 
    4243        { 
    4344            maila.Velocity = Vector.Zero; 
     
    4950    void starttaa() 
    5051    { 
    51         pallo = new PhysicsObject(90.0, 90.0); 
     52         
     53 
     54        TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
     55        kentta.SetTileMethod('o', luo_laatikko); 
     56        kentta.SetTileMethod('k', luo_pallo); 
     57        kentta.SetTileMethod('p', luo_maila); 
     58        kentta.Execute(40,40); 
     59        
     60        Level.CreateBorders(0.9, false); 
     61        pallo.Restitution = 1.5; 
     62        Level.BackgroundColor = Color.Green; 
     63        Camera.ZoomToLevel(); 
     64        IsMouseVisible = true; 
     65         
     66 
     67    } 
     68 
     69    void luo_laatikko(Vector paikka, double leveys, double korkeus) 
     70    { 
     71        PhysicsObject laatikko= PhysicsObject.CreateStaticObject(leveys, korkeus); 
     72        laatikko.Position = paikka; 
     73        laatikko.Image = laatikkokuva; 
     74        laatikko.Tag = "laatikko"; 
     75        Add(laatikko); 
     76    } 
     77 
     78    void luo_pallo(Vector paikka, double leveys, double korkeus) 
     79    { 
     80        pallo = new PhysicsObject(leveys, korkeus); 
    5281        Add(pallo); 
    5382        pallo.Shape = Shape.Circle; 
    5483        pallo.Color = Color.Red; 
    55         pallo.X = -200; 
    56         pallo.Y = 42; 
    57         
    58         Level.CreateBorders(1.0, false); 
    59         pallo.Restitution = 1.0; 
    60         Level.BackgroundColor = Color.Green; 
    61         Camera.ZoomToLevel(); 
    62         IsMouseVisible = true; 
    63         maila = PhysicsObject.CreateStaticObject(250.0, 50.0); 
     84        pallo.Position = paikka; 
     85        AddCollisionHandler(pallo, "laatikko", törmäys); 
     86    } 
     87    void luo_maila(Vector paikka, double leveys, double korkeus) 
     88    { 
     89        maila = PhysicsObject.CreateStaticObject(leveys*3, korkeus); 
    6490        maila.Shape = Shape.Rectangle; 
    65         maila.X = 0.0; 
    66         maila.Y = -350.0; 
    67         maila.Restitution = 1.0; 
     91        maila.Position = paikka; 
     92        maila.Restitution = 3.0; 
    6893        Add(maila); 
     94    } 
     95 
     96    void törmäys(PhysicsObject pallo,PhysicsObject laatikko) 
     97    { 
     98        Explosion rajahdys = new Explosion(100); 
     99        rajahdys.Position = laatikko.Position; 
     100        rajahdys.UseShockWave = false; 
     101        Add(rajahdys); 
     102        laatikko.Destroy(); 
    69103 
    70104    } 
     105 
    71106} 
     107 
  • 2013/27/Emil-AleksiK/Pong/Pong/PongContent/PongContent.contentproj

    r4341 r4376  
    4545    <Reference Include="AnimationExtension" /> 
    4646  </ItemGroup> 
     47  <ItemGroup> 
     48    <Compile Include="kentta1.txt"> 
     49      <Name>kentta1</Name> 
     50      <Importer>TextFileImporter</Importer> 
     51      <Processor>TextFileContentProcessor</Processor> 
     52    </Compile> 
     53  </ItemGroup> 
     54  <ItemGroup> 
     55    <Compile Include="laatikko.jpg"> 
     56      <Name>laatikko</Name> 
     57      <Importer>TextureImporter</Importer> 
     58      <Processor>TextureProcessor</Processor> 
     59    </Compile> 
     60  </ItemGroup> 
    4761  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    4862  <!--  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.