Changeset 4607 for 2013/30


Ignore:
Timestamp:
2013-07-24 10:27:14 (10 years ago)
Author:
viosfilp
Message:

Talletus.

Location:
2013/30/VilleF/Lentokone/Lentokone
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2013/30/VilleF/Lentokone/Lentokone/Lentokone/Lentokone.cs

    r4577 r4607  
    99public class Lentokone : PhysicsGame 
    1010{ 
    11     private Animation havuLento; 
     11    private Animation sauruksenLento; 
    1212 
    1313 
     
    1919    Vector nopeusAlas = new Vector(0, -1000); 
    2020    PhysicsObject pelaaja; 
    21      
    22  
     21    //PhysicsObject pommi; 
    2322 
    2423    public override void Begin() 
    2524    { 
    26        // havuLento = LoadAnimation("havuLento"); 
     25        sauruksenLento = LoadAnimation("animaatio"); 
    2726        Level.Width = 1920; 
    2827        Level.Height = 1080; 
    2928        //SetWindowSize(1024, 800, false); 
    3029 
     30        Gravity = new Vector(0.0, -500); 
     31        //MediaPlayer.Play(" 
    3132 
    3233 
    3334 
    34         
    35  
     35         
    3636        LuoKentta(); 
    3737        LuoPelaaja(); 
    38         LiikutaPelaajaa(); 
     38 
     39        pelaaja.Animation = sauruksenLento; 
     40        pelaaja.Animation.Start(); 
     41        pelaaja.Animation.FPS = 3; 
     42         
     43 
    3944        Camera.ZoomToLevel(); 
    40         TiputaPommi(); 
     45        //TiputaPommi(); 
    4146        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    4247 
     
    4449 
    4550        Keyboard.Listen(Key.Left, ButtonState.Down, 
    46           LiikutaPelaajaa, null, -1); 
     51          HidastaPelaajaa, null); 
    4752        Keyboard.Listen(Key.Right, ButtonState.Down, 
    4853          LiikutaPelaajaa, null, 1); 
    4954        Keyboard.Listen(Key.Up, ButtonState.Down, 
    50           KaannaPelaajaa, null, -1.0); 
     55          KaannaPelaajaa, null, 1.0); 
    5156        Keyboard.Listen(Key.Up, ButtonState.Released, 
    5257          KaannaPelaajaa, null, 0.0); 
    5358        Keyboard.Listen(Key.Down, ButtonState.Down, 
    54           KaannaPelaajaa, null, 1.0); 
     59          KaannaPelaajaa, null, -1.0); 
    5560        Keyboard.Listen(Key.Down, ButtonState.Released, 
    5661          KaannaPelaajaa, null, 0.0); 
     
    5964    void TiputaPommi() 
    6065    { 
    61    //    pommi = new PhysicsObject(100.0, 100.0); 
    62      //  pommi.Shape = Shape.FromImage(pommi); 
    63        //pommi.Image = pommi; 
    64        //Add(pommi); 
    65     }  
     66        gre 
     67    } 
    6668    void KaannaPelaajaa(double kaannos) 
    6769    { 
     
    6971         
    7072    } 
     73 
     74 
     75    protected override void Update(Time time) 
     76    { 
     77        base.Update(time); 
     78        if (pelaaja != null) 
     79        { 
     80            if (pelaaja.Position.X > Level.Right) pelaaja.Position = new Vector(Level.Left, pelaaja.Position.Y); 
     81            if (pelaaja.Position.X < Level.Left) pelaaja.Position = new Vector(Level.Right, pelaaja.Position.Y); 
     82        } 
     83    } 
     84 
     85    void HidastaPelaajaa() 
     86    { 
     87        pelaaja.Velocity = new Vector(pelaaja.Velocity.X * 0.95, pelaaja.Velocity.Y); 
     88        
     89    } 
     90 
    7191    void PelaajaTormasi(PhysicsObject tormaaja, PhysicsObject kohde) 
    7292    { 
     
    7595    void LiikutaPelaajaa(int suunta) 
    7696    { 
    77         pelaaja.Push(Vector.FromLengthAndAngle(1000*suunta, pelaaja.Angle)); 
     97        pelaaja.Push(Vector.FromLengthAndAngle(3000*suunta, pelaaja.Angle)); 
    7898    } 
    7999 
     
    91111    void LuoPelaaja() 
    92112    { 
    93         pelaaja = new PhysicsObject(235.0, 283.0); 
     113        pelaaja = new PhysicsObject(150.0, 190.0); 
    94114        pelaaja.Shape = Shape.FromImage(havusaurus); 
    95115        pelaaja.Image = havusaurus; 
    96         pelaaja.MirrorImage(); 
     116        pelaaja.LinearDamping = 0.99; 
     117 
     118        //pelaaja.MirrorImage(); 
    97119        Add(pelaaja); 
    98120       AddCollisionHandler(pelaaja, CollisionHandler.ExplodeBoth(200, true)); 
     121        pelaaja.MaxVelocity = 600; 
     122       Timer ajastin = new Timer(); 
     123       ajastin.Interval = 0.1; 
     124       ajastin.Timeout += KaannaKohtiMaata; 
     125       ajastin.Start(); 
    99126    } 
    100     void LiikutaPelaajaa() 
     127 
     128    void KaannaKohtiMaata() 
    101129    { 
    102         pelaaja.LinearDamping = 0.95; 
    103         Vector pelaajanSuunta = Vector.FromLengthAndAngle(500.0, pelaaja.Angle); 
    104         pelaaja.Push(pelaajanSuunta); 
     130        if((pelaaja.Angle.Degrees > 70) && (pelaaja.Angle.Degrees < 110)) 
     131            return; 
     132        if ((pelaaja.Angle.Degrees >= 110) || (pelaaja.Angle.Degrees <= -90)) 
     133            pelaaja.Angle = Angle.FromDegrees(pelaaja.Angle.Degrees + 0.4); 
     134        else 
     135            pelaaja.Angle = Angle.FromDegrees(pelaaja.Angle.Degrees - 0.4); 
     136    } 
    105137 
    106  
    107     } 
    108138     
    109139} 
  • 2013/30/VilleF/Lentokone/Lentokone/LentokoneContent/LentokoneContent.contentproj

    r4577 r4607  
    9494    </Compile> 
    9595  </ItemGroup> 
     96  <ItemGroup> 
     97    <Compile Include="animaatio.anim"> 
     98      <Name>animaatio</Name> 
     99      <Importer>AnimationImporter</Importer> 
     100      <Processor>AnimationContentProcessor</Processor> 
     101    </Compile> 
     102  </ItemGroup> 
     103  <ItemGroup> 
     104    <Compile Include="animaatio\havusaurus01.png"> 
     105      <Name>havusaurus01</Name> 
     106      <Importer>TextureImporter</Importer> 
     107      <Processor>TextureProcessor</Processor> 
     108    </Compile> 
     109    <Compile Include="animaatio\Havusaurus02.png"> 
     110      <Name>Havusaurus02</Name> 
     111      <Importer>TextureImporter</Importer> 
     112      <Processor>TextureProcessor</Processor> 
     113    </Compile> 
     114  </ItemGroup> 
    96115  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    97116  <!--  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.