Changeset 3774
- Timestamp:
- 2012-07-26 15:01:55 (11 years ago)
- Location:
- 2012/30/TuomasW/Mortal Rally/Mortal Rally
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/30/TuomasW/Mortal Rally/Mortal Rally/Mortal Rally/Mortal_Rally.cs
r3745 r3774 7 7 using Jypeli.Widgets; 8 8 9 public class Mortal_Rally : TopDownPhysicsGame 9 public class Mortal_Rally : TopDownPhysicsGame //actually is dolan 10 10 { 11 11 12 12 13 //saatanan saatanan saatana 14 13 15 Image taustaKuva = LoadImage("rata"); 14 16 15 17 16 18 Automobile auto; 17 19 Automobile auto2; 18 20 19 public override void Begin() 21 public override void Begin() //äxschly is dlan 20 22 { 23 24 LuoKenttä(); 25 26 27 21 28 Level.CreateBorders(1, true); 22 29 Camera.ZoomToLevel(); … … 24 31 Level.Background.Image = taustaKuva; 25 32 Level.BackgroundColor = Color.Green; 33 Level.Background.FitToLevel(); 26 34 27 35 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); … … 29 37 30 38 39 31 40 //PhysicsObject aita = new PhysicsObject(LoadImage("aidat")); 32 41 //Add(aita); 42 43 auto = LuoAuto(-50, -1300); 44 auto.Image = LoadImage("auto1"); 33 45 46 auto2 = LuoAuto(-50, 1100); 47 auto2.Image = LoadImage("auto2"); 34 48 35 auto = LuoAuto(Level.Left + 20, 0);36 auto2 = LuoAuto(Level.Right - 20, 0);49 AddCollisionHandler(auto, auto2, AutoHajoaa); 50 AddCollisionHandler(auto2, auto, Auto2Hajoaa); 37 51 38 Keyboard.Listen(Key.Up, ButtonState.Down, liikutaAutoa, "liikuta", auto); 39 Keyboard.Listen(Key.Down, ButtonState.Down, liikutaAutoa, "liikuta", auto); 40 Keyboard.Listen(Key.Left, ButtonState.Down, Kaanny, "Kääntyy", Angle.FromDegrees(4), auto); 41 Keyboard.Listen(Key.Right, ButtonState.Down, Kaanny, "Kääntyy", Angle.FromDegrees(-4), auto); 52 Keyboard.Listen(Key.Up, ButtonState.Down, liikutaAutoa, "liikuta", auto); 53 Keyboard.Listen(Key.Down, ButtonState.Down, jarruta, "jarruttaa", auto); 54 //Keyboard.Listen(Key.Down, ButtonState.Released, , "liikuta", auto); 55 Keyboard.Listen(Key.Left, ButtonState.Down, Kaanny, "Kääntyy", Angle.FromDegrees(1.5), auto); 56 Keyboard.Listen(Key.Right, ButtonState.Down, Kaanny, "Kääntyy", Angle.FromDegrees(-1.5), auto); 42 57 43 44 Keyboard.Listen(Key.S, ButtonState.Down, liikutaAutoa, "liikuta", auto2);45 Keyboard.Listen(Key.A, ButtonState.Down, Kaanny, "Kääntyy", Angle.FromDegrees(4), auto2);46 Keyboard.Listen(Key.D, ButtonState.Down, Kaanny, "Kääntyy", Angle.FromDegrees(-4), auto2);58 Keyboard.Listen(Key.W, ButtonState.Down, liikutaAutoa, "liikuta", auto2); 59 Keyboard.Listen(Key.S, ButtonState.Down, jarruta, "jarruttaa", auto2); 60 Keyboard.Listen(Key.A, ButtonState.Down, Kaanny, "Kääntyy", Angle.FromDegrees(1.5), auto2); 61 Keyboard.Listen(Key.D, ButtonState.Down, Kaanny, "Kääntyy", Angle.FromDegrees(-1.5), auto2); 47 62 } 48 63 49 Automobile LuoAuto(double x, double y) 64 Automobile LuoAuto(double x, double y) //ask about free shipping! 50 65 { 51 66 52 67 53 Automobile auto = new Automobile(27.5, 45); 54 auto.Shape = Shape.Rectangle; 55 auto.X = x; 56 auto.Y = y; 57 auto.Restitution = 0.5; 58 Add(auto); 59 return auto; 68 Automobile auto = new Automobile(150, 130); 69 auto.Shape = Shape.Rectangle; 70 //auto.Image = LoadImage("auto1"); 71 auto.X = x; 72 auto.Y = y; 73 auto.Restitution = 0.5; 74 //auto.MaxVelocity = 100; 75 auto.Acceleration = 300.0; 76 auto.AngularDamping = 0.01; 77 auto.LinearDamping = 0.992; 78 Add(auto); 79 return auto; 80 81 } 82 //saatanan saatanan SAATANA 60 83 61 84 85 void LuoKenttä() 86 { 87 ColorTileMap ruudut = ColorTileMap.FromLevelAsset("aidat_pieni"); 62 88 89 ruudut.SetTileMethod(Color.Black, LuoAidat); 63 90 91 ruudut.Execute(48, 64); 64 92 65 93 } 94 95 //kenttä on paras :D ja aidat:DD 96 97 void LuoAidat(Vector paikka, double korkeus, double leveys) 98 { 99 PhysicsObject aidat = PhysicsObject.CreateStaticObject(leveys, korkeus); 100 aidat.Position = paikka; 101 aidat.Color = Color.OrangeRed; 102 // aidat.Image = 103 Add(aidat); 104 } 66 105 67 106 void Kaanny (Angle kulma, Automobile auto) … … 72 111 void liikutaAutoa(Automobile auto) 73 112 { 74 auto.Accelerate(1); 75 auto.LinearDamping = 0.99; 76 auto.AngularDamping = 0.99; 113 auto.Accelerate(); 114 } 115 116 void jarruta(Automobile auto) 117 { 118 auto.Brake(); 77 119 } 78 120 … … 87 129 } 88 130 131 void AutoHajoaa(PhysicsObject auto, PhysicsObject auto2) 132 { 133 if (auto.Velocity.Magnitude > 100) 134 { 135 auto2.Destroy(); 136 } 137 } 138 139 void Auto2Hajoaa(PhysicsObject auto2, PhysicsObject auto) 140 { 141 if (auto2.Velocity.Magnitude > 100) 142 { 143 auto.Destroy(); 144 } 145 } 146 147 148 149 89 150 90 151 } 152 153 //NOW GET OUT OF MY HOUSE! -
2012/30/TuomasW/Mortal Rally/Mortal Rally/Mortal RallyContent/Mortal RallyContent.contentproj
r3745 r3774 65 65 </Compile> 66 66 </ItemGroup> 67 <ItemGroup> 68 <Compile Include="aidat_pieni.png"> 69 <Name>aidat_pieni</Name> 70 <Importer>TextureImporter</Importer> 71 <Processor>TextureProcessor</Processor> 72 </Compile> 73 </ItemGroup> 74 <ItemGroup> 75 <Compile Include="auto1.png"> 76 <Name>auto1</Name> 77 <Importer>TextureImporter</Importer> 78 <Processor>TextureProcessor</Processor> 79 </Compile> 80 </ItemGroup> 81 <ItemGroup> 82 <Compile Include="auto2.png"> 83 <Name>auto2</Name> 84 <Importer>TextureImporter</Importer> 85 <Processor>TextureProcessor</Processor> 86 </Compile> 87 </ItemGroup> 67 88 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 68 89 <!-- 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.