- Timestamp:
- 2015-06-23 11:34:51 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/26/Tuisku/counter food/counter food/counter food/counter_food.cs
r6140 r6165 9 9 public class counter_food : PhysicsGame 10 10 { 11 Vector liikeOikealle = new Vector (100.0, 0); 12 Vector liikeVasemalle = new Vector(-100.0, 0); 13 PhysicsObject pelaaja1; 11 14 12 15 IntMeter pisteLaskuri; 13 16 IntMeter pisteLaskuri2; 17 Vector nopeus; 14 18 15 19 … … 17 21 { 18 22 kartta(); 19 pelaaja1();20 pelaaja2();23 LuoPelaaja1(); 24 LuoPelaaja2(); 21 25 LuoPistelaskuri(); 22 26 LuoPistelaskuri2(); 27 28 23 29 24 30 } … … 34 40 lattia.Y = (-500.0); 35 41 42 43 44 36 45 } 37 46 38 47 39 void pelaaja1()48 void LuoPelaaja1() 40 49 { 41 50 PhysicsObject h = new PhysicsObject(20.0, 20.0); … … 44 53 Add(h); 45 54 h.X = (900.0); 46 h.Y = (-4 30);47 55 h.Y = (-420); 56 48 57 } 49 58 50 void pelaaja2()59 void LuoPelaaja2() 51 60 { 52 61 PhysicsObject p = new PhysicsObject(20.0, 20.0); 62 63 64 //new PhysicsObject(LoadImage("")); 65 53 66 p.Shape = Shape.Circle; 54 67 p.Color = Color.Red; … … 58 71 59 72 } 60 61 62 63 64 73 65 74 void LuoPistelaskuri() … … 82 91 83 92 Label pisteNaytto2 = new Label(); 84 pisteNaytto2.X = Screen.Right +100;85 pisteNaytto2.Y = Screen.Top -100;93 pisteNaytto2.X = Screen.Right - 100; 94 pisteNaytto2.Y = Screen.Top + 100; 86 95 pisteNaytto2.TextColor = Color.Black; 87 96 pisteNaytto2.Color = Color.White; … … 91 100 Add(pisteNaytto2); 92 101 } 102 103 void lisaanappaimet() 104 { 105 Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "pelaaja 1: liiku oikealle", pelaaja1, liikeOikealle); 106 Keyboard.Listen(Key.Right, ButtonState.Released, AsetaNopeus, null, pelaaja1, Vector.Zero); 107 Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liiku vasemalle", pelaaja1, liikeVasemalle); 108 Keyboard.Listen(Key.Left, ButtonState.Released, AsetaNopeus, null, pelaaja1, Vector.Zero); 109 110 111 } 112 113 114 115 void AsetaNopeus(PhysicsObject pelaaja1, Vector nopeus) 116 { 117 if ((nopeus.Y < 0) && (pelaaja1.Bottom < Level.Bottom)) 118 { 119 pelaaja1.Velocity = Vector.Zero; 120 return; 121 } 122 if ((nopeus.Y > 0) && (pelaaja1.Top > Level.Top)) 123 { 124 pelaaja1.Velocity = Vector.Zero; 125 return; 126 } 127 128 pelaaja1.Velocity = nopeus; 129 } 93 130 131 132 94 133 95 134
Note: See TracChangeset
for help on using the changeset viewer.