- Timestamp:
- 2011-06-14 14:57:15 (12 years ago)
- Location:
- 2011/24/VilmaK
- Files:
-
- 31 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/24/VilmaK/Pong/Pong/Pong/Peli.cs
r1973 r1987 12 12 Vector nopeusYlos = new Vector(0, 200); 13 13 Vector nopeusAlas = new Vector ( 0, -200); 14 PhysicsObject vasenReuna; 15 PhysicsObject oikeaReuna; 16 14 17 15 18 PhysicsObject pallo; 16 19 PhysicsObject maila1; 17 20 PhysicsObject maila2; 21 IntMeter pelaajan1Pisteet; 22 IntMeter pelaajan2Pisteet; 23 18 24 19 25 public override void Begin() … … 25 31 AloitaPeli(); 26 32 MessageDisplay.TextColor = Color.White; 33 } 27 34 // TODO: Kirjoita ohjelmakoodisi tähän 28 35 29 36 void LisaaLaskurit() 30 37 { 31 IntMeter 38 pelaajan1Pisteet = LuoPisteLaskuri ( Screen.Left + 100.0, Screen.Top -100.0); 39 pelaajan2Pisteet = LuoPisteLaskuri ( Screen.Right -100.0, Screen.Top -100.0); 40 32 41 } 33 34 35 36 37 38 39 40 41 42 43 44 45 42 IntMeter LuoPisteLaskuri ( double x, double y) 43 { 44 IntMeter Laskuri = new IntMeter ( 0 ); 45 Laskuri.MaxValue = 10; 46 Label naytto = new Label(); 47 naytto.BindTo ( Laskuri ); 48 naytto. X = x; 49 naytto. Y = y; 50 naytto.TextColor = Color.White; 51 naytto.BorderColor = Level.BackgroundColor; 52 naytto.Color = Level.BackgroundColor; 53 Add ( naytto ); 54 return Laskuri; 46 55 } 56 47 57 48 58 void LuoKentta() … … 57 67 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 58 68 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 69 AddCollisionHandler(pallo, KasittelePallonTormays); 59 70 60 71 61 72 62 Level.CreateBorders(1.0, false); 63 pallo.Restitution = 1.0; 73 vasenReuna = Level.CreateLeftBorder (); 74 vasenReuna.Restitution = 1.0; 75 vasenReuna.IsVisible = false; 76 oikeaReuna = Level.CreateRightBorder (); 77 oikeaReuna.Restitution = 1.0; 78 oikeaReuna.IsVisible = false; 79 PhysicsObject alaReuna = Level.CreateBottomBorder (); 80 alaReuna.Restitution = 1.0; 81 alaReuna.IsVisible = false; 82 PhysicsObject ylaReuna = Level.CreateTopBorder (); 83 ylaReuna.Restitution = 1.0 ; 84 ylaReuna.IsVisible = false; 85 86 pallo.Restitution = 1.0; 64 87 Level.BackgroundColor = Color.Black; 65 88 Camera.ZoomToLevel(); 89 90 91 66 92 67 93 … … 119 145 120 146 } 147 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 148 { 149 if ( kohde == oikeaReuna ) 150 { 151 pelaajan1Pisteet. Value += 1; 152 } 153 else if ( kohde == vasenReuna ) 154 { 155 pelaajan2Pisteet. Value += 1; 156 } 121 157 122 158 159 } 123 160 124 161
Note: See TracChangeset
for help on using the changeset viewer.