- Timestamp:
- 2012-06-28 10:36:41 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/26/OlliL/SpaceImpact2/SpaceImpact2/SpaceImpact2/SpaceImpact2.cs
r3280 r3300 9 9 public class SpaceImpact2 : PhysicsGame 10 10 { 11 11 12 Vector nopeusYlos = new Vector(0, 300); 12 13 Vector nopeusAlas = new Vector(0, -300); … … 16 17 PhysicsObject laser; 17 18 19 List<PhysicsObject> vihut= new List<PhysicsObject>(); 18 20 19 21 public override void Begin() 20 22 { 23 SetWindowSize(800, 480, false); 24 21 25 Luokentta(); 22 26 AloitaPeli(); 23 27 AsetaOhjaimet(); 24 28 29 // Level.Size = new Vector(800, 480); 30 25 31 Level.Background.CreateStars(10000); 26 SetWindowSize(800, 480, false);32 LuoPistelaskuri(); 27 33 28 34 } … … 30 36 { 31 37 Level.BackgroundColor = Color.Black; 38 Level.Width = 800; 39 Level.Height = 480; 32 40 Level.CreateBorders(1.0, true); 33 41 Camera.ZoomToLevel(); 34 42 alus = Luoalus(Level.Left + 250.0, 0.0); 35 Camera.ZoomToLevel(1500);36 43 } 37 44 void AloitaPeli() … … 53 60 alus.Shape = Shape.Diamond; 54 61 alus.Color = Color.Magenta; 62 alus.CollisionIgnoreGroup = 1; 55 63 alus.X = x; 56 64 alus.Y = y; … … 58 66 return alus; 59 67 } 68 60 69 PhysicsObject Luovihu(double x, double y) 61 70 { … … 63 72 vihu.Color = RandomGen.NextColor(); 64 73 vihu.Shape = Shape.Circle; 65 // vihu.LifetimeLeft = TimeSpan.FromSeconds(9.0);74 vihu.Tag = "vihu"; 66 75 vihu.X = x; 67 76 vihu.Y = y; … … 69 78 vihu.Hit(new Vector(-100, 0)); 70 79 Add(vihu); 71 AddCollisionHandler(vihu, CollisionHandler.DestroyObject); 80 vihut.Add(vihu); 81 AddCollisionHandler(vihu, CollisionHandler.DestroyObject); 82 return vihu; 83 } 72 84 73 vihu.Destroyed += delegate74 {75 Explosion rajahdys = new Explosion(100);76 rajahdys.Position = vihu.Position;77 rajahdys.Speed = 500.0;78 rajahdys.Force = 10000;79 rajahdys.ShockwaveColor = Color.Orange;80 Add(rajahdys);81 };82 83 return vihu;84 85 }86 85 void Luolaser() 87 86 { … … 89 88 laser.Shape = Shape.Rectangle; 90 89 laser.Color = Color.Red; 90 laser.CollisionIgnoreGroup = 1; 91 91 AddCollisionHandler(laser, CollisionHandler.DestroyObject); 92 AddCollisionHandler(laser, "vihu", delegate(PhysicsObject ammus, PhysicsObject vihu) 93 { 94 Explosion rajahdys = new Explosion(100); 95 rajahdys.Position = vihu.Position; 96 rajahdys.Speed = 500.0; 97 rajahdys.Force = 0; 98 rajahdys.ShockwaveColor = Color.Orange; 99 Add(rajahdys); 100 } 101 ); 92 102 laser.Position = alus.Position; 93 103 Add(laser); 94 104 Vector impulssi = new Vector(500.0, 0.0); 95 laser.Hit(impulssi); 96 97 105 laser.Hit(impulssi); 98 106 99 107 // Explosion rajahdys = new Explosion(100); … … 135 143 while (laskuri < 3) 136 144 { 137 Luovihu(Level.Right - 56, RandomGen.NextDouble(Level.Bottom + 28, Level.Top - 28)); 145 double y = RandomGen.NextDouble( 146 Level.Bottom + 28, Level.Top - 28 147 ); 148 Luovihu(Level.Right - 57, y); 138 149 laskuri++; 139 150 } … … 149 160 } 150 161 } 162 163 void LuoPistelaskuri() 164 { 165 166 pisteLaskuri = new IntMeter(0); 167 168 Label pisteNaytto = new Label(); 169 pisteNaytto.Title = "Points"; 170 pisteNaytto.X = Screen.Left + 200; 171 pisteNaytto.Y = Screen.Top - 50; 172 pisteNaytto.TextColor = Color.Black; 173 pisteNaytto.Color = Color.White; 174 175 pisteNaytto.BindTo(pisteLaskuri); 176 Add(pisteNaytto); 177 178 } 179 180 public IntMeter pisteLaskuri { get; set; } 151 181 } 182
Note: See TracChangeset
for help on using the changeset viewer.