- Timestamp:
- 2013-07-24 10:27:14 (10 years ago)
- 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 9 9 public class Lentokone : PhysicsGame 10 10 { 11 private Animation havuLento;11 private Animation sauruksenLento; 12 12 13 13 … … 19 19 Vector nopeusAlas = new Vector(0, -1000); 20 20 PhysicsObject pelaaja; 21 22 21 //PhysicsObject pommi; 23 22 24 23 public override void Begin() 25 24 { 26 // havuLento = LoadAnimation("havuLento");25 sauruksenLento = LoadAnimation("animaatio"); 27 26 Level.Width = 1920; 28 27 Level.Height = 1080; 29 28 //SetWindowSize(1024, 800, false); 30 29 30 Gravity = new Vector(0.0, -500); 31 //MediaPlayer.Play(" 31 32 32 33 33 34 34 35 35 36 36 LuoKentta(); 37 37 LuoPelaaja(); 38 LiikutaPelaajaa(); 38 39 pelaaja.Animation = sauruksenLento; 40 pelaaja.Animation.Start(); 41 pelaaja.Animation.FPS = 3; 42 43 39 44 Camera.ZoomToLevel(); 40 TiputaPommi();45 //TiputaPommi(); 41 46 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 42 47 … … 44 49 45 50 Keyboard.Listen(Key.Left, ButtonState.Down, 46 LiikutaPelaajaa, null, -1);51 HidastaPelaajaa, null); 47 52 Keyboard.Listen(Key.Right, ButtonState.Down, 48 53 LiikutaPelaajaa, null, 1); 49 54 Keyboard.Listen(Key.Up, ButtonState.Down, 50 KaannaPelaajaa, null, -1.0);55 KaannaPelaajaa, null, 1.0); 51 56 Keyboard.Listen(Key.Up, ButtonState.Released, 52 57 KaannaPelaajaa, null, 0.0); 53 58 Keyboard.Listen(Key.Down, ButtonState.Down, 54 KaannaPelaajaa, null, 1.0);59 KaannaPelaajaa, null, -1.0); 55 60 Keyboard.Listen(Key.Down, ButtonState.Released, 56 61 KaannaPelaajaa, null, 0.0); … … 59 64 void TiputaPommi() 60 65 { 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 } 66 68 void KaannaPelaajaa(double kaannos) 67 69 { … … 69 71 70 72 } 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 71 91 void PelaajaTormasi(PhysicsObject tormaaja, PhysicsObject kohde) 72 92 { … … 75 95 void LiikutaPelaajaa(int suunta) 76 96 { 77 pelaaja.Push(Vector.FromLengthAndAngle( 1000*suunta, pelaaja.Angle));97 pelaaja.Push(Vector.FromLengthAndAngle(3000*suunta, pelaaja.Angle)); 78 98 } 79 99 … … 91 111 void LuoPelaaja() 92 112 { 93 pelaaja = new PhysicsObject( 235.0, 283.0);113 pelaaja = new PhysicsObject(150.0, 190.0); 94 114 pelaaja.Shape = Shape.FromImage(havusaurus); 95 115 pelaaja.Image = havusaurus; 96 pelaaja.MirrorImage(); 116 pelaaja.LinearDamping = 0.99; 117 118 //pelaaja.MirrorImage(); 97 119 Add(pelaaja); 98 120 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(); 99 126 } 100 void LiikutaPelaajaa() 127 128 void KaannaKohtiMaata() 101 129 { 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 } 105 137 106 107 }108 138 109 139 } -
2013/30/VilleF/Lentokone/Lentokone/LentokoneContent/LentokoneContent.contentproj
r4577 r4607 94 94 </Compile> 95 95 </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> 96 115 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 97 116 <!-- 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.