Changeset 7307
- Timestamp:
- 2016-06-14 15:01:23 (7 years ago)
- Location:
- 2016/24/LasseK
- Files:
-
- 9 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/24/LasseK/PinPong/PinPong/PinPong/PinPong.cs
r7264 r7307 15 15 PhysicsObject pallo; 16 16 PhysicsObject maila1; 17 IPhysicsObject maila2; 17 PhysicsObject maila2; 18 PhysicsObject vasenReuna; 19 PhysicsObject oikeaReuna; 20 IntMeter pelaajan1Pisteet; 21 IntMeter pelaajan2Pisteet; 22 18 23 public override void Begin() 19 24 { 20 21 25 LisaaLaskurit(); 26 LuoKentta(); 22 27 AloitaPeli(); 23 28 AsetaOhjaimet(); … … 39 44 Add(pallo); 40 45 41 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0);42 maila.Shape = Shape.Rectangle;43 maila.X = Level.Left + 20.0;44 maila.Y = 0.0;45 maila.Restitution = 1.0;46 Add(maila);47 48 46 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 49 47 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 50 48 AddCollisionHandler(pallo, KasittelePallonTormays); 51 49 52 50 pallo.X = -200.0; 53 51 54 52 pallo.Y = 0.0; 55 Level.CreateBorders(1.0, false); 53 vasenReuna = Level.CreateLeftBorder(); 54 vasenReuna.Restitution = 1.0; 55 vasenReuna.IsVisible = false; 56 oikeaReuna = Level.CreateRightBorder(); 57 oikeaReuna.Restitution = 1.0; 58 oikeaReuna.IsVisible = false; 59 PhysicsObject YlaReuna = Level.CreateTopBorder(); 60 YlaReuna.Restitution = 1.0; 61 YlaReuna.IsVisible = false; 62 PhysicsObject AlaReuna = Level.CreateBottomBorder(); 63 AlaReuna.Restitution = 1.0; 64 AlaReuna.IsVisible = false; 65 56 66 pallo.Restitution = 1.0; 57 Level.Background.Color = Color. Pink;67 Level.Background.Color = Color.HotPink; 58 68 Camera.ZoomToLevel(); 59 69 } … … 70 80 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 71 81 { 82 83 if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 84 { 85 maila.Velocity = Vector.Zero; 86 return; 87 } 88 if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 89 90 { 91 maila.Velocity = Vector.Zero; 92 return; 93 } 94 72 95 maila.Velocity = nopeus; 96 73 97 } 74 98 void AsetaOhjaimet() 75 99 { 76 100 Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylos", maila1, nopeusYlos); 77 Keyboard.Listen(Key.A, ButtonState.Released, null, maila1, Vector.Zero);101 Keyboard.Listen(Key.A, ButtonState.Released,AsetaNopeus, null, maila1, Vector.Zero); 78 102 Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 79 103 Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); … … 89 113 } 90 114 115 IntMeter LuoPisteLaskuri(double x, double y) 116 { 117 IntMeter laskuri = new IntMeter(0); 118 laskuri.MaxValue = 10; 119 Label naytto = new Label(); 120 naytto.BindTo(laskuri); 121 naytto.X = x; 122 naytto.Y = y; 123 naytto.TextColor = Color.HotPink; 124 naytto.BorderColor = Level.Background.Color; 125 naytto.Color = Level.Background.Color; 126 Add(naytto); 127 128 129 return laskuri; 130 } 131 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 132 { 133 134 if (kohde == oikeaReuna) 135 { 136 pelaajan1Pisteet.Value += 1; 137 } 138 else if (kohde == vasenReuna) 139 { 140 pelaajan2Pisteet.Value += 1; 141 } 142 } 143 void LisaaLaskurit() 144 { 145 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 146 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 147 148 149 150 } 151 152 153 91 154 92 155 … … 94 157 95 158 96 -
2016/24/LasseK/PinPong/PinPong/PinPong/obj/x86/Debug/ContentPipeline-{6DAC37A3-7F96-4641-8C99-0BC4C668F854}.xml
r7264 r7307 17 17 <Assembly> 18 18 <Key>C:\Windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key> 19 <Value>2015-09-16T13:4 6:35.8102287+03:00</Value>19 <Value>2015-09-16T13:41:58.0471254+03:00</Value> 20 20 </Assembly> 21 21 </Assemblies>
Note: See TracChangeset
for help on using the changeset viewer.