- Timestamp:
- 2012-07-03 12:25:26 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/MaraP/Pöng/Pöng/Pöng/Pöng.cs
r3452 r3469 17 17 PhysicsObject maila2; 18 18 19 IntMeter pelaajan1Pisteet; 20 IntMeter pelaajan2Pisteet; 21 22 PhysicsObject vasenReuna; 23 PhysicsObject oikeaReuna; 19 24 20 25 public override void Begin() … … 22 27 LuoKentta(); 23 28 AsetaOhjaimet(); 29 LisaaLaskurit(); 24 30 AloitaPeli(); 25 31 … … 40 46 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 41 47 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 42 43 Level.CreateBorders(1.0, false); 48 49 vasenReuna = Level.CreateLeftBorder(); 50 vasenReuna.Restitution = 1.0; 51 vasenReuna.IsVisible = false; 52 53 oikeaReuna = Level.CreateRightBorder(); 54 oikeaReuna.Restitution = 1.0; 55 oikeaReuna.IsVisible = false; 56 57 PhysicsObject ylaReuna = Level.CreateTopBorder(); 58 ylaReuna.Restitution = 1.0; 59 ylaReuna.IsVisible = false; 60 61 PhysicsObject alaReuna = Level.CreateBottomBorder(); 62 alaReuna.Restitution = 1.0; 63 alaReuna.IsVisible = false; 64 44 65 pallo.Restitution = 1.0; 45 66 Level.BackgroundColor = Color.Black; 46 67 Camera.ZoomToLevel(); 68 69 AddCollisionHandler(pallo, KasittelePallonTormays); 47 70 } 48 71 … … 73 96 maila.Restitution = 1.0; 74 97 Add(maila); 75 76 98 maila.Color = Color.Lime; 77 99 … … 81 103 } 82 104 105 IntMeter LuoPisteLaskuri(double x, double y) 106 { 107 IntMeter laskuri = new IntMeter(0); 108 laskuri.MaxValue = 10; 109 110 111 Label naytto = new Label(); 112 naytto.BindTo(laskuri); 113 naytto.X = x; 114 naytto.Y = y; 115 naytto.TextColor = Color.White; 116 naytto.BorderColor = Level.BackgroundColor; 117 naytto.Color = Level.BackgroundColor; 118 Add(naytto); 119 return laskuri; 120 } 121 122 void LisaaLaskurit() 123 { 124 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 125 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 126 127 } 83 128 84 129 void AsetaNopeus(PhysicsObject maila, Vector nopeus) … … 103 148 pallo.Hit(impulssi); 104 149 } 150 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 151 { 152 if (kohde == oikeaReuna) 153 { 154 pelaajan1Pisteet.Value += 1; 155 } 156 else if (kohde == vasenReuna) 157 { 158 pelaajan2Pisteet.Value += 1; 159 } 160 } 105 161 }
Note: See TracChangeset
for help on using the changeset viewer.