Changeset 5529
- Timestamp:
- 2014-07-22 10:52:30 (9 years ago)
- Location:
- 2014/30/LauriR/Pong
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/LauriR/Pong/Pong/Pong/Pong.cs
r5508 r5529 9 9 public class Pong : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200); 12 Vector nopeusAlas = new Vector(0, -200); 13 14 PhysicsObject pallo; 11 Vector nopeusYlos = new Vector(0, 400); 12 Vector nopeusAlas = new Vector(0, -400); 13 15 14 PhysicsObject maila1; 16 15 PhysicsObject maila2; … … 27 26 AsetaOhjaimet(); 28 27 LisaaLaskurit(); 29 AloitaPeli(); 30 } 31 32 void LuoKentta() 33 { 34 pallo = new PhysicsObject(40.0, 40.0); 35 pallo.Shape = Shape.Circle; 36 pallo.X = -350.0; 37 pallo.Y = 0.0; 28 29 } 30 31 void LuoPallo() 32 { 33 PhysicsObject pallo = new PhysicsObject(40.0, 40.0); 34 pallo.Shape = Shape.Hexagon; 35 pallo.Color = RandomGen.NextColor(); 36 pallo.X = RandomGen.NextDouble(-100,100); 37 pallo.Y = RandomGen.NextDouble(-100, 100); 38 38 pallo.Restitution = 1.0; 39 39 pallo.KineticFriction = 0.0; … … 42 42 AddCollisionHandler(pallo, KasittelePallonTormays); 43 43 44 Vector impulssi = new Vector(500.0, 0.0); 45 pallo.Hit(impulssi); 46 } 47 48 void LuoKentta() 49 { 50 for (int i = 0; i < 10; i++) 51 { 52 53 54 LuoPallo(); 55 56 } 57 44 58 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 45 59 maila2 = LuoMaila(Level.Right - 20.0, 0.0); … … 65 79 alaReuna.KineticFriction = 0.0; 66 80 67 Level.BackgroundColor = Color.Black; 81 Level.Background.Color = Color.Green; 82 83 maila1.Color = Color.Wheat; 84 maila2.Color = Color.Wheat; 68 85 69 86 Camera.ZoomToLevel(); … … 91 108 { 92 109 IntMeter laskuri = new IntMeter(0); 93 laskuri.MaxValue = 10 ;110 laskuri.MaxValue = 1000; 94 111 95 112 Label naytto = new Label(); … … 98 115 naytto.Y = y; 99 116 naytto.TextColor = Color.White; 100 naytto.BorderColor = Level.Background Color;101 naytto.Color = Level.Background Color;117 naytto.BorderColor = Level.Background.Color; 118 naytto.Color = Level.Background.Color; 102 119 Add(naytto); 103 120 … … 117 134 } 118 135 119 void AloitaPeli()120 {121 Vector impulssi = new Vector(500.0, 0.0);122 pallo.Hit(impulssi);123 }124 125 136 void AsetaOhjaimet() 126 137 { 138 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 139 127 140 Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 128 141 Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); … … 167 180 maila.Velocity = nopeus; 168 181 } 182 183 const double PALLON_MIN_NOPEUS = 500; 184 185 protected override void Update(Time time) 186 { 187 /* 188 if (pallo != null && Math.Abs(pallo.Velocity.X) < PALLON_MIN_NOPEUS) 189 { 190 pallo.Velocity = new Vector(pallo.Velocity.X * 1.1, pallo.Velocity.Y); 191 } 192 */ 193 base.Update(time); 194 } 169 195 } 170 196
Note: See TracChangeset
for help on using the changeset viewer.