Changeset 6564 for 2015/27/SampoR/Pong
- Timestamp:
- 2015-06-30 11:00:43 (8 years ago)
- Location:
- 2015/27/SampoR/Pong
- Files:
-
- 30 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/SampoR/Pong/Pong/Pong/Pong.cs
r6535 r6564 15 15 16 16 PhysicsObject pallo; 17 18 17 PhysicsObject maila1; 19 18 PhysicsObject maila2; 19 20 PhysicsObject vasenReuna; 21 PhysicsObject oikeaReuna; 22 23 IntMeter pelaajan1Pisteet; 24 IntMeter pelaajan2Pisteet; 20 25 21 26 public override void Begin() … … 36 41 Add(pallo); 37 42 38 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 39 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 43 AddCollisionHandler(pallo, KasittelePallonTormays); 40 44 41 Level.CreateBorders(1.0, false); 42 Level.Background.Color = Color.Black; 45 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 46 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 47 48 vasenReuna = Level.CreateLeftBorder(); 49 vasenReuna.Restitution = 1.0; 50 vasenReuna.IsVisible = false; 51 52 oikeaReuna = Level.CreateRightBorder(); 53 oikeaReuna.Restitution = 1.0; 54 oikeaReuna.IsVisible = false; 55 56 PhysicsObject alaReuna = Level.CreateBottomBorder(); 57 alaReuna.Restitution = 1.0; 58 alaReuna.IsVisible = false; 59 60 PhysicsObject ylaReuna = Level.CreateTopBorder(); 61 ylaReuna.Restitution = 1.0; 62 ylaReuna.IsVisible = false; 63 64 65 66 Level.Background.Color = Color.LightGreen; 43 67 44 68 Camera.ZoomToLevel(); … … 105 129 void LisaaLaskurit() 106 130 { 107 131 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 132 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 108 133 } 109 134 110 IntMeter LuoPisteLaskuri( )135 IntMeter LuoPisteLaskuri(double x, double y) 111 136 { 112 137 IntMeter laskuri = new IntMeter(0); 113 138 laskuri.MaxValue = 10; 139 140 Label naytto = new Label(); 141 naytto.BindTo(laskuri); 142 naytto.X = x; 143 naytto.Y = y; 144 naytto.TextColor = Color.White; 145 naytto.BorderColor = Level.Background.Color; 146 naytto.Color = Level.Background.Color; 147 Add(naytto); 148 114 149 return laskuri; 115 150 } 116 151 117 } 152 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 153 { 154 if (kohde == oikeaReuna) 155 { 156 pelaajan1Pisteet.Value += 1; 157 } 158 else if (kohde == vasenReuna) 159 { 160 pelaajan2Pisteet.Value += 1; 161 } 162 } 163 }
Note: See TracChangeset
for help on using the changeset viewer.