- Timestamp:
- 2014-06-25 15:02:00 (8 years ago)
- Location:
- 2014/26/Pyry-PetteriP/Motopeli
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/26/Pyry-PetteriP/Motopeli/Motopeli/Motopeli/Motopeli.cs
r5094 r5109 11 11 Image autoKuva = LoadImage("auto2"); 12 12 Automobile moottoripyora; 13 RoadMap tie; 13 14 14 15 Vector[] reittiPisteet = new Vector[] 15 { new Vector( 600.0, -400.0 ), 16 new Vector( -300.0, 400.0 ), 17 new Vector( -.400, -214.0 ), 18 // new Vector(- ), 19 // new Vector( ), 20 21 22 }; 16 { 17 new Vector( 0, 300 ), 18 new Vector(400,300 ),//suoran päätös oikealla ulhaalla 19 new Vector(500, 250), 20 new Vector (600,100), 21 new Vector (600, 0), 22 new Vector (600, -100), 23 new Vector (600, -200), 24 new Vector (550, -210), 25 new Vector (500, -220), 26 new Vector (300, -300), 27 new Vector (100, -300), 28 new Vector (0, -300), 29 new Vector (-200, -100), 30 new Vector (-400, 0), 31 new Vector (-500, 50), 32 new Vector (-510, 80), 33 new Vector (-520, 110), 34 new Vector (-530, 140), 35 new Vector (-530, 180), 36 new Vector (-530, 220), 37 new Vector (-500, 250), 38 new Vector (-450, 270), 39 new Vector (-400, 290), 40 new Vector (-350, 300), 41 new Vector (10, 300), 42 }; 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 23 58 24 59 25 60 public override void Begin() 26 61 { 62 AloitaAlusta(); 27 63 SmoothTextures = false; 28 Luokentta(); 29 Camera.ZoomToLevel(); 30 Moottoripyora(); 31 AsetaOhjaimet(); 32 64 65 66 67 //LuoKaide(); 33 68 34 69 } … … 37 72 void Luokentta() 38 73 { 39 RoadMaptie = new RoadMap(reittiPisteet);40 tie.DefaultWidth = 150.0;74 tie = new RoadMap(reittiPisteet); 75 tie.DefaultWidth = 200.0; 41 76 tie.Insert(); 42 Level.BackgroundColor = Color.Green; 43 44 foreach (Vector paikka in reittiPisteet) 45 {46 LuoMerkki(paikka); 47 48 } 77 78 Level.Background.Color = Color.Green; 79 80 Level.Size = Screen.Size; 81 82 Level.CreateBorders(0.5, false); 83 49 84 } 50 85 … … 52 87 void Moottoripyora() 53 88 { 54 moottoripyora = new Automobile( 40.0, 25.0);89 moottoripyora = new Automobile(35.0, 20.0); 55 90 Add(moottoripyora); 91 moottoripyora.Position = new Vector(0, 300); 56 92 moottoripyora.Image = autoKuva; 57 93 moottoripyora.AngularDamping = 0.95; 58 94 //moottoripyora.MomentOfInertia = 400; 59 95 moottoripyora.TopSpeed = 10; 96 moottoripyora.Acceleration = 200; 97 moottoripyora.BrakeDeceleration = 500; 60 98 } 61 99 … … 63 101 void AsetaOhjaimet() 64 102 { 65 Keyboard.Listen(Key. Right, ButtonState.Down, KaannaPelaajaa, null, -1000.0);66 Keyboard.Listen(Key. Left, ButtonState.Down, KaannaPelaajaa, null, 1000.0);67 Keyboard.Listen(Key. Up, ButtonState.Down, KaasutaPelaajaa, null);68 Keyboard.Listen(Key. Down, ButtonState.Down, TaaksepainPelaajaa, null);103 Keyboard.Listen(Key.D, ButtonState.Down, KaannaPelaajaa, null, -2000.0); 104 Keyboard.Listen(Key.A, ButtonState.Down, KaannaPelaajaa, null, 2000.0); 105 Keyboard.Listen(Key.W, ButtonState.Down, KaasutaPelaajaa, null); 106 Keyboard.Listen(Key.S, ButtonState.Down, TaaksepainPelaajaa, null); 69 107 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 70 108 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 109 Keyboard.Listen(Key.R, ButtonState.Pressed, AloitaAlusta, "Aloittaa Pelin Alusta"); 110 71 111 } 72 112 … … 99 139 } 100 140 141 //void LuoKaide() 142 //{ 143 // RoadMap kaide = new RoadMap(kaidePisteet); 144 // kaide.DefaultWidth = 30.0; 145 // kaide.CreateSegmentFunction = LuoKaiteenPatka; 146 // kaide.Insert(); 147 //} 148 149 //PhysicsObject LuoKaiteenPatka(double width, double height, Shape shape) 150 //{ 151 // PhysicsObject patka = PhysicsObject.CreateStaticObject(width, height, shape); 152 // patka.Color = Color.Brown; 153 // Add(patka); 154 // return patka; 155 //} 101 156 void AloitaAlusta() 102 157 { 103 158 ClearAll(); 104 } 105 106 159 Luokentta(); 160 lisaaMaaliViiva(); 161 AsetaOhjaimet(); 162 // LuoKaide(); 163 Moottoripyora(); 164 Camera.ZoomToLevel(); 165 LisaaAjastimet(); 166 LuoAikaLaskuri(); 167 } 168 169 void lisaaMaaliViiva() 170 { 171 PhysicsObject maali = PhysicsObject.CreateStaticObject(20, 200); 172 maali.Color = Color.White; 173 maali.Position = new Vector(0, 300); 174 maali.IgnoresCollisionResponse = true; 175 Add(maali); 176 } 177 178 179 void LisaaAjastimet() 180 { 181 Timer ajastin = new Timer(); 182 ajastin.Interval = 0.1; 183 ajastin.Timeout += Asetaautonnopedet; 184 ajastin.Start(); 185 } 186 187 188 void Asetaautonnopedet() 189 { 190 if (tie.IsInside(moottoripyora.Position)) 191 { 192 moottoripyora.MaxVelocity = 1000; 193 } 194 else 195 { 196 moottoripyora.MaxVelocity = 100; 197 } 198 199 } 200 201 202 void LuoAikaLaskuri() 203 { 204 Timer aikaLaskuri = new Timer(); 205 aikaLaskuri.Start(); 206 207 Label aikaNaytto = new Label(); 208 aikaNaytto.TextColor = Color.White; 209 aikaNaytto.DecimalPlaces = 1; 210 aikaNaytto.BindTo(aikaLaskuri.SecondCounter); 211 aikaNaytto.Position = new Vector(Screen.Right - 40, Screen.Top - 40); 212 Add(aikaNaytto); 213 } 107 214 } 108 109 110 215 216 217
Note: See TracChangeset
for help on using the changeset viewer.