Changeset 186
- Timestamp:
- 2009-07-24 13:16:49 (14 years ago)
- Location:
- valtteri_s/Avaruuspeli3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
valtteri_s/Avaruuspeli3/Content/Content.contentproj
r145 r186 54 54 </Compile> 55 55 </ItemGroup> 56 <ItemGroup> 57 <Compile Include="NuclearMissle.png"> 58 <Name>NuclearMissle</Name> 59 <Importer>TextureImporter</Importer> 60 <Processor>TextureProcessor</Processor> 61 </Compile> 62 </ItemGroup> 56 63 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 57 64 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
valtteri_s/Avaruuspeli3/Peli.cs
r145 r186 55 55 public ProjectileWeapon Cannon; 56 56 57 private BattleObject pelaaja; 58 59 57 60 /// <summary> 58 61 /// Suurimman vääntömomentin itseisarvo, jolla tankki voi pyörittää pyöriä. … … 61 64 62 65 63 public VihollisAlus( PhysicsGame game, string name )66 public VihollisAlus( PhysicsGame game, string name, BattleObject pelaaja ) 64 67 : base( game, name ) 65 { 66 Hull = new BattleObject( name + "hull", 170, 200, 5000, 500 ); 68 { //Vihollis Aluksen koko,massa ja HP 69 this.pelaaja = pelaaja; 70 71 Hull = new BattleObject( name + "hull", 195, 304, 500000, 5 ); 67 72 Hull.Texture = Game.Content.Load<Texture2D>( "vihollinen" ); 73 Hull.X = -1400; 74 Hull.Y = -1400; 75 76 Timer ajastin = new Timer(); 77 ajastin.Interval = 0.7; 78 ajastin.Trigger += new Timer.TriggerHandler(Ammu); 79 game.AddTimer(ajastin); 80 ajastin.Start(); 81 82 68 83 69 84 // Just to be sure … … 76 91 77 92 } 93 void Ammu(Timer sender) 94 { 95 Projectile Ammus = Cannon.Use(); 96 if (Ammus == null) 97 return; 98 Game.Level.Objects.Add(Ammus); 99 Vector2D suunta = new Vector2D(pelaaja.X - this.X,pelaaja.Y - this.Y); 100 101 //Angle kulma = new Angle(RandomGen.NextDouble(-60, 45), true); 102 Angle kulma = new Angle(suunta.Angle,false); 103 AimCannon(kulma); 104 105 } 106 107 78 108 79 109 private void AddCannon( PhysicsObject hull ) 80 110 { 81 111 CannonBall ammus = new CannonBall(); 82 ammus.Explosion.Force = 0; 83 112 ammus.Explosion.Force = 10; 113 //ammus.Texture = Game.Content.Load<Texture2D>("NuclearMissle"); 114 //Vihollis Aluksen Tykki 84 115 Cannon = new Cannon( ammus ); 85 Cannon.FireRate = 100; 116 Cannon.Size = Cannon.Size * 2; 117 Cannon.UpdateShapeFromSize(); 118 Cannon.FireRate = 1000; 119 Cannon.Power = new Meter<double>(10000, 10000, 10000); 120 Cannon.Powered = false; 86 121 this.Add( Cannon ); 87 122 88 Vector2D ppaikka = new Vector2D( hull.Position.X+ 10, hull.Position.Y +5 );123 Vector2D ppaikka = new Vector2D( hull.Position.X+25, hull.Position.Y +5 ); 89 124 Cannon.Position = ppaikka; 90 125 Cannon.Anchor = ppaikka; 91 126 92 Cannon.Clip.Ammo.MaxValue = 1 30;93 Cannon.Clip.Ammo.Value = 1 30;127 Cannon.Clip.Ammo.MaxValue = 1000000000; 128 Cannon.Clip.Ammo.Value = 1000000000; 94 129 Cannon.Clip.Ammo.LowerAlertValue = 25; 95 130 … … 186 221 IShape ympyra = Shapes.CreateCircle(80.0); 187 222 //Maapallon massa 188 PhysicsObject maapallo = new PhysicsObject(1000000 , ympyra);223 PhysicsObject maapallo = new PhysicsObject(100000000, ympyra); 189 224 maapallo.Texture = Content.Load<Texture2D>("Maa"); 190 225 //Maapallon sijainti 191 maapallo.X = -10;192 maapallo.Y = -10;226 maapallo.X = 1900; 227 maapallo.Y = 1900; 193 228 kentta.Objects.Add(maapallo); 194 229 … … 210 245 AddCollisionHandler(pelaaja1, KasittelePelaajanTormays); 211 246 247 //vihollis Alus 212 248 VihollisAlus vihollinen; 213 vihollinen = new VihollisAlus(this, "vihollinen" );249 vihollinen = new VihollisAlus(this, "vihollinen",pelaaja1); 214 250 vihollinen.X = 100; 215 251 vihollinen.Y = 100; … … 266 302 Controls.Listen(Keys.Right, ButtonPosition.Down, PyoritaAlusta, null, pelaaja1, Angle.Radians(-0.05f)); 267 303 Controls.Listen(Keys.Up, ButtonPosition.Down, KaytaMoottoria, "Käytä moottoria", pelaaja1, 500); 268 Controls.Listen(Keys.Space, ButtonPosition. Down, Ammu);304 Controls.Listen(Keys.Space, ButtonPosition.Pressed, Ammu); 269 305 270 306 lisaaGamePadNappaimet(PlayerIndex.One, pelaaja1); … … 281 317 282 318 // Pelaajan 1 näppäimet 283 Controls.Listen(pelaajaNro, Buttons. DPadLeft, ButtonPosition.Down, PyoritaAlusta, null, pelaaja1, Angle.Radians(0.05f));284 Controls.Listen(pelaajaNro, Buttons. DPadRight, ButtonPosition.Down, PyoritaAlusta, null, pelaaja1, Angle.Radians(-0.05f));319 Controls.Listen(pelaajaNro, Buttons.LeftTrigger, ButtonPosition.Down, PyoritaAlusta, null, pelaaja1, Angle.Radians(0.05f)); 320 Controls.Listen(pelaajaNro, Buttons.RightTrigger, ButtonPosition.Down, PyoritaAlusta, null, pelaaja1, Angle.Radians(-0.05f)); 285 321 Controls.Listen(pelaajaNro, Buttons.A, ButtonPosition.Down, KaytaMoottoria, "Käytä moottoria", pelaaja1, 500); 286 322 287 Controls.Listen(pelaajaNro, Buttons.X, ButtonPosition. Down, Ammu);323 Controls.Listen(pelaajaNro, Buttons.X, ButtonPosition.Pressed, Ammu); 288 324 } 289 325 … … 305 341 // luodaan ammus 306 342 Projectile ammus = ase.Use(); 343 if (ammus == null) return false; 344 307 345 ammus.Position = ammus.Position + (Vector2D.FromLengthAndAngle(40, ase.Angle.Radian)); 308 346 ammus.Push(ammus.Velocity); //?
Note: See TracChangeset
for help on using the changeset viewer.