Changeset 7749
- Timestamp:
- 2016-07-05 10:41:56 (5 years ago)
- Location:
- 2016/27/JamiL/Ping
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/27/JamiL/Ping/Ping/Ping/Ping.cs
r7707 r7749 16 16 PhysicsObject maila2; 17 17 18 PhysicsObject vasenReuna; 19 PhysicsObject oikeaReuna; 20 21 18 22 IntMeter pelaajan1Pisteet; 19 23 IntMeter pelaajan2Pisteet; 20 21 24 public override void Begin() 22 25 { … … 24 27 AsetaOhjaimet(); 25 28 LisaaLaskurit(); 26 AloitaPeli(); 29 30 AloitaPeli(); 31 } 32 void Luokentta() 33 { 34 pallo = new PhysicsObject(40.0, 40.0); 35 pallo.Shape = Shape.Circle; 36 pallo.X = -200.0; 37 pallo.Y = 0.0; 38 pallo.Restitution = 1.0; 39 Add(pallo); 40 AddCollisionHandler(pallo, KasittelePallonTormays); 27 41 28 29 } void LisaaLaskurit(double x, double y) 42 maila1= LuoMaila(Level.Left + 20.0, 0.0); 43 maila2= LuoMaila(Level.Right - 20.0, 0.0); 44 45 vasenReuna = Level.CreateLeftBorder(); 46 vasenReuna.Restitution = 1.0; 47 vasenReuna.IsVisible = false; 48 49 oikeaReuna = Level.CreateRightBorder(); 50 oikeaReuna.Restitution = 1.0; 51 oikeaReuna.IsVisible = false; 52 53 PhysicsObject ylaReuna = Level.CreateTopBorder(); 54 ylaReuna.Restitution = 1.0; 55 ylaReuna.IsVisible = false; 56 57 PhysicsObject alaReuna = Level.CreateBottomBorder(); 58 alaReuna.Restitution = 1.0; 59 alaReuna.IsVisible = false; 60 61 Level.CreateBorders(1.0, false); 62 Level.Background.Color = Color.Black; 63 64 Camera.ZoomToLevel(); 65 } 66 67 void LisaaLaskurit() 30 68 { 69 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 70 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 31 71 32 } IntMeter LuoPisteLaskuri() 72 73 74 } 75 IntMeter LuoPisteLaskuri(double x,double y) 33 76 { 34 77 35 78 IntMeter laskuri = new IntMeter(0); 36 79 laskuri.MaxValue = 10; 37 Label naytto = new Label(); 80 81 Label naytto = new Label(); 38 82 naytto.BindTo(laskuri); 39 83 naytto.X = x; … … 45 89 return laskuri; 46 90 } 47 91 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 92 { 93 if (kohde == oikeaReuna) 94 { 95 pelaajan1Pisteet.Value += 1; 96 } 97 else if (kohde == vasenReuna) 98 { 99 pelaajan2Pisteet.Value += 1; 100 } 101 } 48 102 49 103 void AsetaNopeus(PhysicsObject maila, Vector nopeus) … … 60 114 maila.Velocity = nopeus; 61 115 } 62 void AsetaOhjaimet() 116 void AloitaPeli() 117 { 118 Vector impulssi = new Vector(500.0, 0.0); 119 pallo.Hit(impulssi); 120 121 } 122 void AsetaOhjaimet() 63 123 { 64 124 … … 78 138 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 79 139 } 80 void AloitaPeli() 81 { 82 Vector impulssi = new Vector(500.0, 0.0); 83 pallo.Hit(impulssi); 84 85 } 140 86 141 87 142 88 143 89 void Luokentta() 90 { 91 92 93 pallo = new PhysicsObject(40.0, 40.0); 94 pallo.Shape = Shape.Circle; 95 pallo.X = -200.0; 96 pallo.Y = 0.0; 97 pallo.Restitution = 1.0; 98 Add(pallo); 99 100 maila1= LuoMaila(Level.Left + 20.0, 0.0); 101 maila2= LuoMaila(Level.Right - 20.0, 0.0); 102 103 Level.CreateBorders(1.0, false); 104 Level.Background.Color = Color.Black; 105 106 Camera.ZoomToLevel(); 107 } 144 108 145 109 146 PhysicsObject LuoMaila(double x, double y)
Note: See TracChangeset
for help on using the changeset viewer.