Changeset 2241
- Timestamp:
- 2011-06-28 14:59:42 (12 years ago)
- Location:
- 2011/26/JaniN
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/JaniN/neon wars/neon wars/neon wars/Peli.cs
r2199 r2241 16 16 GameObject pyssy; 17 17 18 PhysicsObject alareuna; 18 19 19 20 public override void Begin() 20 21 { 22 23 24 21 25 aseta_näppäimet(); 22 26 Mouse.IsCursorVisible = true; 23 27 24 Ihansama = new PhysicsObject(50.0, 50.0); 28 29 Timer ajastin = new Timer(); 30 ajastin.Interval = 0.05; 31 ajastin.Trigger += TeeVihollinen; 32 ajastin.Start(); 33 //TeeVihollinen(ajastin); 34 35 Ihansama = PhysicsObject.CreateStaticObject(50.0, 50.0); 25 36 Ihansama.X = 0; 26 Ihansama.Y = Level.Bottom +100;37 Ihansama.Y = Level.Bottom + 100; 27 38 Add(Ihansama); 28 29 pyssy = new GameObject(200, 15); 39 40 41 pyssy = new GameObject(100, 5); 30 42 pyssy.Color = Color.Black; 31 43 Ihansama.Add(pyssy); … … 35 47 //HingeJoint liitos = PhysicsGame.CreateHingeJoint(Ihansama, pyssy, Ihansama.Position); 36 48 //Add(liitos); 37 pyssy.Image = LoadImage("Untitled"); 49 pyssy.Image = LoadImage("Untitled"); 38 50 // Gravity = new Vector(0, -1000); 39 51 Level.CreateBorders(); 52 alareuna = Level.CreateBottomBorder(); 53 54 40 55 } 56 41 57 42 58 … … 45 61 Mouse.Listen(MouseButton.Left, ButtonState.Down, ampuu, null); 46 62 } 47 48 49 50 63 64 65 66 51 67 protected override void Update(Time time) 52 68 { … … 62 78 { 63 79 PhysicsObject ammus = new PhysicsObject(5, 5); 64 80 ammus.Velocity = (Mouse.PositionOnWorld - Ihansama.Position).Normalize()*500; 81 82 //ammus.Push(Mouse.PositionOnWorld); 83 //ammus.Velocity *= 3; 84 ammus.Tag = "ammus"; 85 ammus.Destroyed += new Action(delegate { ammus_Destroyed(ammus); }); 65 86 Add(ammus); 66 ammus.Position = Ihansama.Position; 87 ammus.Position = Ihansama.Position + (Mouse.PositionOnWorld - Ihansama.Position).Normalize()*((pyssy.Width/2)-14); 88 89 AddCollisionHandler(ammus, KasitteleAmmuksenTormays); 90 ammus.Shape = Shape.Circle; 91 ammus.Color = Color.Black; 92 67 93 } 94 95 void ammus_Destroyed(PhysicsObject ammus) 96 { 97 Explosion rajahdys = new Explosion(70); 98 rajahdys.Position = ammus.Position; 99 rajahdys.Force = 0; 100 rajahdys.ShockwaveColor = Color.Transparent; 101 Add(rajahdys); 102 } 103 104 void KasitteleAmmuksenTormays(PhysicsObject ammus, PhysicsObject kohde) 105 { 106 if (kohde != Ihansama && kohde.Tag.ToString() != "ammus") ammus.Destroy(); 107 if (kohde != Ihansama && kohde.Tag.ToString() == "vihollinen") { kohde.Destroy(); } 108 } 109 void KasitteleVihollisenTormays(PhysicsObject vihollinen ,PhysicsObject kohde) 110 { 111 if (kohde == alareuna) vihollinen.Destroy(); 112 } 113 114 void TeeVihollinen(Timer sender) 115 { 116 PhysicsObject vihollinen = new PhysicsObject(50, 50); 117 vihollinen.Shape = Shape.Rectangle; 118 vihollinen.Velocity = new Vector(0, 500); 119 vihollinen.X = RandomGen.NextDouble(Level.Left, Level.Right); 120 vihollinen.Y = Level.Top; 121 vihollinen.Tag = "vihollinen"; 122 vihollinen.Image = LoadImage("vihollinen"); 123 vihollinen.Angle = Angle.StraightAngle; 124 vihollinen.CanRotate = false; 125 AddCollisionHandler(vihollinen, KasitteleVihollisenTormays); 126 Add(vihollinen); 127 } 128 68 129 } -
2011/26/JaniN/neon wars/neon wars/neon warsContent/neon warsContent.contentproj
r2199 r2241 49 49 </Compile> 50 50 </ItemGroup> 51 <ItemGroup> 52 <Compile Include="vihollinen.png"> 53 <Name>vihollinen</Name> 54 <Importer>TextureImporter</Importer> 55 <Processor>TextureProcessor</Processor> 56 </Compile> 57 </ItemGroup> 51 58 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 52 59 <!-- 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.