Changeset 5937
- Timestamp:
- 2015-06-09 12:04:42 (7 years ago)
- Location:
- 2015/24/AleksiS/Pong
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/24/AleksiS/Pong/Pong/Pong/Pong.cs
r5914 r5937 21 21 LuoKentta(); 22 22 AsetaOhjaimet(); 23 LisaaLaskurit(); 23 24 AloitaPeli(); 24 25 } 26 27 void LisaaLaskurit () 28 { 29 // ... 30 } 31 32 IntMeter LuoPisteLaskuri () 33 { 34 IntMeter laskuri = new IntMeter(0); 35 laskuri.MaxValue = 10; 36 37 Label naytto = new Label(); 38 naytto.BindTo(laskuri); 39 naytto.X = X; 40 naytto.Y = Y; 41 naytto.TextColor = Color.White; 42 naytto.BorderColor = Level.Background.Color; 43 naytto.Color = Level.Background.Color; 44 Add(naytto); 45 46 return laskuri; 47 } 25 48 26 49 … … 77 100 78 101 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 102 Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 103 Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja2: Likkuta mailaa alas", maila2, nopeusAlas); 104 Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 79 105 80 81 106 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 82 107 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 83 108 } … … 85 110 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 86 111 { 87 maila.Velocity = nopeus; 112 if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 113 { 114 maila.Velocity = Vector.Zero; 115 return; 116 } 117 118 if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 119 { 120 maila.Velocity = Vector.Zero; 121 return; 122 } 123 124 maila.Velocity = nopeus; 88 125 89 126 }
Note: See TracChangeset
for help on using the changeset viewer.