Changeset 1174
- Timestamp:
- 2010-07-08 11:29:58 (13 years ago)
- 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"> 2 2 <PropertyGroup> 3 3 <ProjectGuid>df71e4f8-85ec-46e2-8dae-689bf7828c02</ProjectGuid> … … 28 28 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 29 29 </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> 30 47 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 31 48 <!-- 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 14 14 } 15 15 } 16 -
2010/27/patammi/Autopeli1/Peli.cs
r1155 r1174 3 3 using Jypeli.Widgets; 4 4 using Jypeli.Assets; 5 using Jypeli.Effects; 5 6 6 7 public class Peli : TopDownPhysicsGame … … 9 10 Automobile auto2; 10 11 11 LaserGun laserPyssy; 12 LaserGun LaserPyssy; 13 12 LaserGun laserPyssy1; 13 LaserGun laserPyssy2; 14 15 PhysicsObject OilBarrel; 16 17 ExplosionSystem es; 18 14 19 protected override void Begin() 15 20 { … … 18 23 auto = new Automobile(40, 20); 19 24 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); 21 27 auto.AngularDamping = 0.9; 22 28 Add(auto); 23 29 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); 27 34 28 35 auto2 = new Automobile(40, 20); 29 36 auto2.Mass = 10.0; 37 auto2.Maneuverability = Angle.Degrees(120); 30 38 auto2.Color = new Color(192, 192, 255); 31 39 auto2.AngularDamping = 0.9; 32 40 Add(auto2); 33 41 34 auto2.Add( LaserPyssy);42 auto2.Add(laserPyssy2); 35 43 36 37 for (int a = 0; a < 10 0; a++)44 45 for (int a = 0; a < 10; a++) 38 46 { 39 PhysicsObject laatikko = new PhysicsObject(10, 10); 40 laatikko.X = RandomGen.NextDouble(-4000, 4000); 41 Add(laatikko); 47 LisaaOilBarrel(); 42 48 } 43 49 … … 49 55 AsetaNappaimet(); 50 56 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 51 67 } 52 68 53 69 void AsetaXBoxOhjaimet() 54 70 { 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ä."); 56 72 57 73 58 74 } 59 75 void LiikutaPelaajaa(AnalogState state) 60 76 { 61 auto.Turn(Angle.Degrees(state.StateVector.X *-4), Time.SinceLastUpdate.TotalSeconds);77 auto.Turn(Angle.Degrees(state.StateVector.X * -4), Time.SinceLastUpdate.TotalSeconds); 62 78 } 63 79 void AsetaNappaimet() … … 67 83 Keyboard.Listen(Key.Up, ButtonState.Down, kiihdyta, "Kiihdytä", auto); 68 84 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)); 71 87 72 88 Keyboard.Listen(Key.W, ButtonState.Down, kiihdyta, "Kiihdytä", auto2); 73 89 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)); 76 92 77 93 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"); 81 96 82 97 } … … 85 100 void laaserase() 86 101 { 87 88 89 //laserPyssy.LaserCollision = LaserSadeOsuu; 90 91 102 //laserPyssy.LaserCollision = LaserSadeOsuu; 92 103 } 93 104 94 105 95 106 96 107 … … 113 124 114 125 126 void Rajahdys(PhysicsObject tormaaja, PhysicsObject kohde) 127 { 128 es.AddEffect(tormaaja.X, tormaaja.Y, 20); 129 tormaaja.Destroy(); 130 } 115 131 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 } 118 143 119 144 }
Note: See TracChangeset
for help on using the changeset viewer.