Changeset 548
- Timestamp:
- 2010-06-08 13:24:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/vajuanse/Pong/Peli.cs
r541 r548 12 12 PhysicsObject maila2; 13 13 14 PhysicsObject vasenreuna; 15 PhysicsObject oikeareuna; 16 14 17 Vector nopeusylos = new Vector(0, 200); 15 18 Vector nopeusalas = new Vector(0, -200); … … 17 20 IntMeter pelaaja1pisteet; 18 21 IntMeter pelaaja2pisteet; 19 22 20 23 protected override void Begin() 21 24 { … … 26 29 pallo.Hit(impulssi); 27 30 Lisaalaskurit(); 28 31 29 32 } 30 33 31 34 void Luokentta() 32 35 { 33 AddCollisionHadler(pallo, KasittelePallonTormays); 36 pallo = new PhysicsObject(40.0, 40.0); 37 AddCollisionHandler(pallo, KasittelePallonTormays); 34 38 35 PhysicsObjectvasenreuna = Level.CreateLeftBorder();39 vasenreuna = Level.CreateLeftBorder(); 36 40 vasenreuna.Restitution = 1.0; 37 41 vasenreuna.IsVisible = false; 38 42 39 PhysicsObjectoikeareuna = Level.CreateRightBorder();43 oikeareuna = Level.CreateRightBorder(); 40 44 oikeareuna.Restitution = 1.0; 41 45 oikeareuna.IsVisible = false; … … 49 53 ylareuna.IsVisible = false; 50 54 51 pallo = new PhysicsObject(40.0, 40.0);55 52 56 pallo.Shape = Shapes.Circle; 53 57 Add(pallo); 54 58 pallo.Restitution = 1.0; 55 Level.BackgroundColor = Color.Light Blue;59 Level.BackgroundColor = Color.LightGray; 56 60 Camera.ZoomToLevel(1.0); 57 61 pallo.X = -200.0; … … 64 68 void Aloitapeli() 65 69 { 66 Vector impulssi = new Vector( 70 Vector impulssi = new Vector(500.0, 0.0); 67 71 pallo.Hit(impulssi); 68 72 } 69 73 70 PhysicsObject LuoMaila 74 PhysicsObject LuoMaila(double x, double y) 71 75 { 72 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0);73 maila.Shape = Shapes.Rectangle;74 maila.X = x;75 maila.Y = y;76 maila.Restitution = 1.0;77 Add(maila);76 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 77 maila.Shape = Shapes.Rectangle; 78 maila.X = x; 79 maila.Y = y; 80 maila.Restitution = 1.0; 81 Add(maila); 78 82 79 return maila;83 return maila; 80 84 } 81 85 … … 103 107 return; 104 108 } 105 if ( (nopeus.Y > 0) && (maila.Y > Level.top))109 if ((nopeus.Y > 0) && (maila.Y > Level.Top)) 106 110 { 107 111 maila.Velocity = Vector.Zero; … … 124 128 IntMeter laskuri = new IntMeter(0); 125 129 laskuri.MaxValue = 10; 126 ValueDisplay naytto = new ValueDisplay( 130 ValueDisplay naytto = new ValueDisplay(); 127 131 naytto.BindTo(laskuri); 128 132 naytto.X = x; … … 135 139 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 136 140 { 137 if (kohde == oikeapallo 138 } 139 if ( kohde == vasenreuna ) 140 { 141 //... 142 } 141 if (kohde == oikeareuna) 142 { 143 pelaaja1pisteet.Value += 1; 144 } 145 else if (kohde == vasenreuna) 146 { 147 pelaaja2pisteet.Value += 1; 148 } 143 149 144 150 151 } 145 152 } 146 153 }
Note: See TracChangeset
for help on using the changeset viewer.