Changeset 1438 for 2010/30/vematata/SeikailuRoolipeli
- Timestamp:
- 2010-07-30 12:00:42 (11 years ago)
- Location:
- 2010/30/vematata/SeikailuRoolipeli
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/30/vematata/SeikailuRoolipeli/Content/Content.contentproj
r1414 r1438 34 34 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 35 35 </ItemGroup> 36 <ItemGroup>37 <Compile Include="Miekka.png">38 <Name>Miekka</Name>39 <Importer>TextureImporter</Importer>40 <Processor>TextureProcessor</Processor>41 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>42 </Compile>43 </ItemGroup>44 36 </Project> -
2010/30/vematata/SeikailuRoolipeli/Peli.cs
r1426 r1438 1 using Jypeli; 1 using System; 2 using Jypeli; 2 3 using Jypeli.Assets; 4 using Jypeli.Widgets; 5 using Physics2DDotNet.Ignorers; 3 6 4 7 public class Peli : PhysicsGame … … 9 12 Vector nopeusOikea = new Vector(300, 0); 10 13 double voima = 20; 14 DoubleMeter elamat; 11 15 //PhysicsObject pallo; 12 16 13 17 PhysicsObject hahmo; 14 18 PhysicsObject miekka; 19 PhysicsObject nuoli; 20 ObjectIgnorer ignorer; 15 21 16 22 Image miekanKuva = LoadImage("Miekka"); … … 20 26 protected override void Begin() 21 27 { 28 ignorer = new ObjectIgnorer(); 29 ElamaPalkki(); 22 30 Testi(); 23 31 AsetaOhjaimet(); … … 44 52 hahmo.LinearDamping = 0.95; 45 53 hahmo.CanRotate = false; 54 hahmo.CollisionIgnorer = ignorer; 55 46 56 47 57 Add(hahmo,0); 48 Miekka();58 //Miekka(); 49 59 50 60 Camera.Follow(hahmo); 51 61 Camera.Zoom(1.5); 52 62 } 63 64 BarGauge ElamaPalkki() 65 { 66 elamat = new DoubleMeter(1000); 67 elamat.MaxValue = 1000; 68 BarGauge elamaPalkki = new BarGauge(10, 500); 69 elamaPalkki.BindTo(elamat); 70 elamaPalkki.X = (Screen.LeftSafe+275); 71 elamaPalkki.Y = (Screen.TopSafe-20); 72 elamaPalkki.BorderColor = Color.White; 73 elamaPalkki.Angle = Angle.Degrees(90); 74 elamat.LowerLimit += ElamatLoppui; 75 Add(elamaPalkki); 76 return elamaPalkki; 77 } 78 79 void ElamatLoppui(double mittarinArvo) 80 { 81 MessageDisplay.Add("Elamat loppuivat, voi voi."); 82 } 83 84 void VahennaElamia() 85 { 86 elamat.Value--; 87 } 88 89 void LisaaElamia() 90 { 91 elamat.Value += 0.2; 92 } 93 94 95 void Nuoli() 96 { 97 nuoli = new PhysicsObject(10,3,Shapes.Circle); 98 nuoli.CollisionIgnorer = ignorer; 99 AddCollisionHandler(nuoli, Osuma); 100 nuoli.Angle = hahmo.Angle; 101 nuoli.Position = hahmo.Position; 102 Add(nuoli,-3); 103 104 nuoli.Hit(Vector.FromLengthAndAngle(500, nuoli.Angle)); 105 } 106 107 void Osuma(PhysicsObject ammus, PhysicsObject kohde) 108 { 109 if (kohde.Tag.ToString() == "vihollinen") 110 { 111 kohde.Brain.Active = false; 112 kohde.Destroy(); 113 ammus.Destroy(); 114 } 115 else ammus.Destroy(); 116 } 117 118 119 53 120 54 121 PhysicsObject Otus(double x, double y) … … 60 127 otus.Y = y; 61 128 otus.Restitution = 0.0; 129 otus.Tag = "vihollinen"; 62 130 Add(otus,0); 63 131 Timer Ajastin = new Timer(); … … 73 141 { 74 142 PhysicsObject kohde = Ajastin.Tag as PhysicsObject; 75 143 if (kohde.IsDestroyed()) 144 { 145 return; 146 } 76 147 77 148 if(kohde != null) 78 149 { 79 150 Vector etaisyys = new Vector(kohde.X - hahmo.X, kohde.Y - hahmo.Y); 80 if (etaisyys.Magnitude < 100&& (kohde.Brain is RandomMoverBrain||kohde.Brain is WandererBrain))151 if (etaisyys.Magnitude < kohde.Width*4 && (kohde.Brain is RandomMoverBrain||kohde.Brain is WandererBrain)) 81 152 { 82 153 FollowerBrain seuraajaAivot = new FollowerBrain(); 83 154 seuraajaAivot.Target = hahmo; 84 155 seuraajaAivot.MovingSpeed = 100; 85 seuraajaAivot.TargetFollowDistance = 100;156 seuraajaAivot.TargetFollowDistance = kohde.Width*4; 86 157 seuraajaAivot.FollowAlways = true; 87 seuraajaAivot.TargetCloseDistance = 200; 88 //seuraajaAivot.StopWhenTargetClose = true; 158 seuraajaAivot.TargetCloseDistance = kohde.Width*2; 159 //seuraajaAivot.StopWhenTargetClose = true; 160 161 seuraajaAivot.TargetClose += new EventHandler(Hyokkaa); 162 89 163 kohde.Brain = seuraajaAivot; 164 90 165 } 91 166 else … … 101 176 102 177 } 103 178 179 void Hyokkaa(object sender, EventArgs e) 180 { 181 VahennaElamia(); 182 MessageDisplay.Add("mennetit elämiä"); 183 } 184 104 185 105 186 PhysicsObject Kivi(double koko, double x, double y) … … 139 220 runko.Color = Color.Brown; 140 221 lehdet.Color = Color.ForestGreen; 141 222 223 lehdet.CollisionIgnorer = ignorer; 224 142 225 Timer Ajastin = new Timer(); 143 226 Ajastin.Interval = 0.1; … … 193 276 Keyboard.Listen(Key.D, ButtonState.Down, AsetaNopeus, "Liiku oikealle", hahmo, nopeusOikea); 194 277 Keyboard.Listen(Key.D, ButtonState.Released, AsetaNopeus, null, hahmo, Vector.Zero); 278 Keyboard.Listen(Key.Space, ButtonState.Pressed, Nuoli, null); 195 279 196 280 … … 279 363 miekka.IgnoresExplosions = true; 280 364 miekka.IgnoresPhysicsLogics = true; 281 //miekka.Image = Image.Mirror(miekanKuva);282 365 Add(miekka,-1); 283 366 Timer Ajastin = new Timer(); … … 287 370 Ajastin.Start(); 288 371 } 289 372 Vector Jokin; 290 373 void Miekansijainti(Timer Ajastin) 291 { 292 miekka.X = hahmo.X - 25; 293 miekka.Y = hahmo.Bottom; 374 { 375 Jokin =new Vector(hahmo.X-25,hahmo.Bottom); 376 377 miekka.Position = Jokin ; 294 378 miekka.Angle = hahmo.Angle; 295 379 } … … 297 381 protected override void Update(Time time) 298 382 { 299 hahmo.Angle = (Mouse.PositionOnWorld - hahmo.Position).Angle; 383 hahmo.Angle = (Mouse.PositionOnWorld - hahmo.Position).Angle; 384 if (hahmo.Velocity == Vector.Zero) 385 { 386 LisaaElamia(); 387 } 300 388 301 389 base.Update(time);
Note: See TracChangeset
for help on using the changeset viewer.