Changeset 2939 for 2012/24/NikoH/Pong/Pong/Pong/Pong.cs
- Timestamp:
- 2012-06-12 11:56:52 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/24/NikoH/Pong/Pong/Pong/Pong.cs
r2934 r2939 9 9 public class Pong : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200);12 Vector nopeusAlas = new Vector(0, - 200);11 Vector nopeusYlos = new Vector(0, 1000); 12 Vector nopeusAlas = new Vector(0, -1000); 13 13 14 14 PhysicsObject pallo; … … 16 16 PhysicsObject maila1; 17 17 PhysicsObject maila2; 18 18 PhysicsObject oikeaReuna; 19 PhysicsObject vasenReuna; 19 20 IntMeter pelaajan1Pisteet; 20 21 IntMeter pelaajan2Pisteet; … … 22 23 public override void Begin() 23 24 { 24 // TODO: Kirjoita ohjelmakoodisi tähän25 25 LuoKentta(); 26 26 AsetaOhjaimet(); 27 27 LisaaLaskurit(); 28 28 AloitaPeli(); 29 30 31 29 32 30 } … … 37 35 pallo.Shape = Shape.Circle; 38 36 pallo.Color = Color.Black; 39 pallo.X = -200 .0;40 pallo.Y = 0 .0;37 pallo.X = -200; 38 pallo.Y = 0; 41 39 pallo.Restitution = 1.0; 42 40 Add(pallo); 41 AddCollisionHandler( pallo, PallonTormays ); 43 42 44 43 maila1 = LuoMaila(Level.Left + 20.0, 0.0); … … 46 45 47 46 48 Level.CreateBorders(1.0, false); 49 Level.BackgroundColor = Color.Green; 47 vasenReuna = Level.CreateLeftBorder(); 48 vasenReuna.Restitution = 1.0; 49 vasenReuna.IsVisible = false; 50 oikeaReuna = Level.CreateRightBorder(); 51 oikeaReuna.Restitution = 1.0; 52 oikeaReuna.IsVisible = false; 53 PhysicsObject alaReuna = Level.CreateBottomBorder(); 54 alaReuna.Restitution = 1.0; 55 alaReuna.IsVisible = false; 56 PhysicsObject ylaReuna = Level.CreateTopBorder(); 57 ylaReuna.Restitution = 1.0; 58 ylaReuna.IsVisible = false; 59 Level.BackgroundColor = Color.DarkRed; 50 60 Camera.ZoomToLevel(); 51 61 } 52 62 void AloitaPeli() 53 63 { 54 Vector impulssi = new Vector( 5000.0, 450.0);64 Vector impulssi = new Vector(3000.0, 0.0); 55 65 pallo.Hit(impulssi); 56 66 } … … 108 118 { 109 119 IntMeter laskuri = new IntMeter(0); 110 laskuri.MaxValue = 30;120 laskuri.MaxValue = 15; 111 121 Label naytto = new Label(); 112 122 naytto.BindTo(laskuri); 113 123 naytto.X = x; 114 124 naytto.Y = y; 115 naytto.TextColor = Color. Yellow;125 naytto.TextColor = Color.Cyan; 116 126 naytto.BorderColor = Level.BackgroundColor; 117 127 naytto.Color = Level.BackgroundColor; … … 120 130 return laskuri; 121 131 } 132 void PallonTormays(PhysicsObject pallo, PhysicsObject kohde) 133 { 134 if (kohde == oikeaReuna) 135 { 136 pelaajan1Pisteet.Value += 1; 137 } 138 else if (kohde == vasenReuna) 139 { 140 pelaajan2Pisteet.Value += 1; 141 } 142 143 } 122 144 123 145 }
Note: See TracChangeset
for help on using the changeset viewer.