- Timestamp:
- 2016-06-14 14:25:13 (7 years ago)
- Location:
- 2016/24/JamiP
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/24/JamiP/PONG/PONG/PONG/PONG.cs
r7263 r7288 16 16 PhysicsObject maila2; 17 17 18 PhysicsObject vasenReuna; 19 PhysicsObject oikeaReuna; 20 18 21 IntMeter pelaajan1Pisteet; 19 22 IntMeter pelaajan2Pisteet; … … 25 28 AsetaOhjaimet(); 26 29 LisaaLaskurit(); 30 AddCollisionHandler(pallo, KasittelePallonTormays); 27 31 28 32 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); … … 35 39 pallo = new PhysicsObject(40.0, 40.0); 36 40 Add(pallo); 37 pallo.Shape = Shape. Octagon;41 pallo.Shape = Shape.Triangle; 38 42 pallo.X = -200.0; 39 43 pallo.Y = 0.0; … … 41 45 42 46 43 maila1 = LuoMaila(Level.Left + 20.0, 0.0);44 maila2 = LuoMaila(Level.Right - 20.0, 0.0);45 // LuoMaila(Level.Right - 20.0, 200.0);47 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 48 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 49 // LuoMaila(Level.Right - 20.0, 200.0); 46 50 51 vasenReuna = Level.CreateLeftBorder(); 52 vasenReuna.Restitution = 1.0; 53 vasenReuna.IsVisible = false; 47 54 48 Level.CreateBorders(1.0, false); 55 oikeaReuna = Level.CreateRightBorder(); 56 oikeaReuna.Restitution = 1.0; 57 oikeaReuna.IsVisible = false; 58 59 PhysicsObject ylaReuna = Level.CreateTopBorder(); 60 ylaReuna.Restitution = 1.0; 61 ylaReuna.IsVisible = false; 62 63 PhysicsObject alaReuna = Level.CreateBottomBorder(); 64 alaReuna.Restitution = 1.0; 65 alaReuna.IsVisible = false; 66 49 67 Level.Background.Color = Color.Black; 50 68 Camera.ZoomToLevel(); … … 74 92 Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 75 93 Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 76 Keyboard.Listen(Key.Space, ButtonState.Pressed, LyoPalloa, null, 1000);94 Keyboard.Listen(Key.Space, ButtonState.Pressed, LyoPalloa, null, 1000); 77 95 78 96 … … 102 120 103 121 } 104 void LyoPalloa(int voima 122 void LyoPalloa(int voima) 105 123 { 106 124 Vector impulssi = new Vector(voima, 10.0); … … 116 134 IntMeter laskuri = new IntMeter(0); 117 135 laskuri.MaxValue = 10; 118 136 119 137 Label naytto = new Label(); 120 138 naytto.BindTo(laskuri); … … 128 146 return laskuri; 129 147 } 130 } 148 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 149 { 150 if (kohde == oikeaReuna) 151 { 152 pelaajan1Pisteet.Value += 1; 153 } 154 else if (kohde == vasenReuna) 155 { 156 pelaajan2Pisteet.Value += 1; 131 157 132 158 } 159 } 160 } 133 161 162 163
Note: See TracChangeset
for help on using the changeset viewer.