- Timestamp:
- 2012-07-05 14:40:30 (11 years ago)
- Location:
- 2012/27/MattiR/FysiikkaPeli3/FysiikkaPeli3
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/MattiR/FysiikkaPeli3/FysiikkaPeli3/FysiikkaPeli3/FysiikkaPeli3.cs
r3540 r3592 16 16 Image[] vasemmalleTippuminen; 17 17 Image[] tippumisAnimaatio = LoadImages("fall 1","fall 2"); 18 IntMeter HPlaskuri; 18 19 public override void Begin() 19 20 { 20 21 // TODO: Kirjoita ohjelmakoodisi tähän 21 MediaPlayer.Play( "Kalimba" );22 22 kävelyVasemmalle = Image.Mirror(ssprites); 23 23 vasemmallePaikallaan = Image.Mirror(pictures); … … 25 25 LuoPelaaja(); 26 26 Gravity = new Vector(0, -500); 27 Luokentta(); 27 28 Level.CreateBorders(); 28 29 keyboard(); 29 30 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 30 31 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 32 LuoHPmittari(); 33 Camera.ZoomToLevel(); 34 } 35 void Luokentta() 36 { 37 TileMap ruudut = TileMap.FromLevelAsset("kenttä 1"); 38 ruudut.SetTileMethod('-', Luotaso); 39 ruudut.SetTileMethod('v', Lasertykki); 40 ruudut.Execute(13, 13); 41 } 42 void Luotaso(Vector paikka, double leveys, double korkeus) 43 { 44 PhysicsObject taso = PhysicsObject.CreateStaticObject(13, 13); 45 taso.Position = paikka; 46 Add(taso); 31 47 } 32 48 void LuoPelaaja() 33 49 { 34 pelaaja1 = new PlatformCharacter( 85.0, 96.0);50 pelaaja1 = new PlatformCharacter(14.0, 15.0); 35 51 Add(pelaaja1); 36 52 pelaaja1.RightIdleAnimation = new Animation(pictures); … … 66 82 { 67 83 pelaaja.Walk(Nopeus); 68 69 84 } 70 85 void hyppaa(PlatformCharacter pelaaja) … … 78 93 pelaaja.LeftIdleAnimation.FPS = 4; 79 94 } 95 void LuoHPmittari() 96 { 97 HPlaskuri = new IntMeter(100); 98 Label HPnaytto = new Label(); 99 HPnaytto.X = Screen.Left + 100; 100 HPnaytto.Y = Screen.Top - 100; 101 HPnaytto.TextColor = Color.Black; 102 HPnaytto.Color = Color.Blue; 103 104 HPnaytto.BindTo(HPlaskuri); 105 Add(HPnaytto); 106 } 107 void Lasertykki(Vector paikka, double leveys, double korkeus) 108 { 109 PhysicsObject Lasertykki = PhysicsObject.CreateStaticObject(20, 10); 110 Lasertykki.Position = paikka; 111 Lasertykki.Shape = Shape.Rectangle; 112 113 Add(Lasertykki); 114 Timer ajastin = new Timer(); 115 ajastin.Interval = 1; 116 ajastin.Timeout += delegate { ammu(Lasertykki.Position - new Vector(Lasertykki.Width / 2, 0)); }; 117 ajastin.Start(); 118 } 119 void ammu(Vector paikka) 120 { 121 PhysicsObject ammus = new PhysicsObject(13, 14); 122 ammus.Position = paikka; 123 ammus.Shape = Shape.Circle; 124 Add(ammus); 125 ammus.Hit(new Vector(-600, 0)); 126 ammus.MaximumLifetime = TimeSpan.FromSeconds(1.0); 127 } 80 128 } -
2012/27/MattiR/FysiikkaPeli3/FysiikkaPeli3/FysiikkaPeli3Content/FysiikkaPeli3Content.contentproj
r3540 r3592 106 106 </Compile> 107 107 </ItemGroup> 108 <ItemGroup> 109 <Compile Include="kenttä 1.txt"> 110 <Name>kenttä 1</Name> 111 <Importer>TextFileImporter</Importer> 112 <Processor>TextFileContentProcessor</Processor> 113 </Compile> 114 </ItemGroup> 108 115 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 109 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.