- Timestamp:
- 2012-07-03 10:45:14 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/MarkusK/pong/pong/pong/pong/pong.cs
r3443 r3461 17 17 PhysicsObject maila2; 18 18 19 PhysicsObject vasenReuna; 20 PhysicsObject oikeaReuna; 21 22 IntMeter Pelaajan1Pisteet; 23 IntMeter Pelaajan2Pisteet; 24 19 25 public override void Begin() 20 26 { 21 27 LuoKentta(); 22 28 AsetaOhjaimet(); 29 Lisaalaskurit(); 23 30 AloitaPeli(); 24 31 … … 32 39 ball.X = -200.0; 33 40 ball.Y = 0.0; 41 ball.MomentOfInertia = Double.PositiveInfinity; 42 ball.KineticFriction = 1.0; 34 43 ball.Restitution = 1.0; 35 44 Add(ball); 45 46 AddCollisionHandler(ball, KasittelePallonTormays); 36 47 37 48 //Maila ja sen ominaisuuksia … … 39 50 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 40 51 41 Level.CreateBorders(1.0, false); 52 vasenReuna = Level.CreateLeftBorder(); 53 vasenReuna.Restitution = 1.0; 54 vasenReuna.IsVisible = false; 55 56 oikeaReuna = Level.CreateRightBorder(); 57 oikeaReuna.Restitution = 1.0; 58 oikeaReuna.IsVisible = false; 59 60 PhysicsObject ylaReuna = Level.CreateTopBorder(); 61 ylaReuna.Restitution = 1.0; 62 ylaReuna.IsVisible = false; 63 64 PhysicsObject alaReuna = Level.CreateBottomBorder(); 65 alaReuna.Restitution = 1.0; 66 alaReuna.IsVisible = false; 67 68 42 69 Level.BackgroundColor = Color.Black; 43 70 … … 46 73 } 47 74 48 voidLuoMaila(double x, double y)75 PhysicsObject LuoMaila(double x, double y) 49 76 { 50 77 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); … … 54 81 maila.Restitution = 1.0; 55 82 Add(maila); 83 return maila; 56 84 } 57 85 … … 79 107 } 80 108 81 109 82 110 83 111 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 84 112 { 113 if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 114 { 115 maila.Velocity = Vector.Zero; 116 return; 117 } 118 119 if ((nopeus.Y > 0) && (maila.Bottom < Level.Bottom)) 120 { 121 maila.Velocity = Vector.Zero; 122 return; 123 } 85 124 maila.Velocity = nopeus; 86 125 } 87 126 127 void Lisaalaskurit() 128 { 129 //HUEHUeHUEHUEHUEHUEHUE 130 //BR BR BR BR BR BR BR 131 132 Pelaajan1Pisteet = Luopistelaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 133 Pelaajan2Pisteet = Luopistelaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 134 } 135 136 IntMeter Luopistelaskuri(double x, double y) 137 { 138 IntMeter laskuri = new IntMeter(0); 139 laskuri.MaxValue = 10; 140 /*/===================|\__/|====================/*/ 141 Label naytto = new Label(); 142 naytto.BindTo(laskuri); 143 naytto.X = x; 144 naytto.Y = y; 145 naytto.TextColor = Color.White; 146 naytto.BorderColor = Level.BackgroundColor; 147 naytto.Color = Level.BackgroundColor; 148 Add(naytto); 149 150 return laskuri; 151 } 152 153 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 154 { 155 if (kohde == oikeaReuna) 156 { 157 Pelaajan1Pisteet.Value += 1; 158 } 159 else if (kohde == vasenReuna) 160 { 161 Pelaajan2Pisteet.Value += 1; 162 } 163 164 } 165 166 88 167 }
Note: See TracChangeset
for help on using the changeset viewer.