- Timestamp:
- 2010-07-29 14:54:38 (13 years ago)
- Location:
- 2010/30/samipunn
- Files:
-
- 6 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/30/samipunn/Misle Launch/Content/Content.contentproj
r1373 r1412 41 41 </Compile> 42 42 </ItemGroup> 43 <ItemGroup> 44 <Compile Include="Ohjus.png"> 45 <Name>Ohjus</Name> 46 <Importer>TextureImporter</Importer> 47 <Processor>TextureProcessor</Processor> 48 </Compile> 49 </ItemGroup> 50 <ItemGroup> 51 <Compile Include="savu.png"> 52 <Name>savu</Name> 53 <Importer>TextureImporter</Importer> 54 <Processor>TextureProcessor</Processor> 55 </Compile> 56 </ItemGroup> 57 <ItemGroup> 58 <Compile Include="Liekki.png"> 59 <Name>Liekki</Name> 60 <Importer>TextureImporter</Importer> 61 <Processor>TextureProcessor</Processor> 62 </Compile> 63 </ItemGroup> 43 64 </Project> -
2010/30/samipunn/Misle Launch/Peli.cs
r1373 r1412 3 3 using Jypeli.Widgets; 4 4 using Jypeli.Assets; 5 using Jypeli.Effects; 5 6 6 7 public class Peli : PhysicsGame 7 8 { 8 double ohjusOdotus = 10.0;9 double ohjusOdotus = 3.5; 9 10 10 11 Image maastonKuva = LoadImage("kentta"); … … 12 13 Timer Laskuri1; 13 14 Timer Laskuri2; 15 Timer polttoaine1; 16 Timer polttoaine2; 17 14 18 PhysicsObject laukaisualusta2; 15 19 PhysicsObject laukaisualusta1; … … 18 22 double kaantyyOikealle = 5; 19 23 double kaantyyVasemmalle = -5; 24 double OhjuksenAloitusKorkeus = -340; 25 26 27 Label testikentta1; 28 Label testikentta2; 29 30 BarGauge voimaPalkki1; 31 BarGauge voimaPalkki2; 32 33 34 DoubleMeter voimaMittari1; 35 DoubleMeter voimaMittari2; 36 37 bool ohjus1sammutettu = false; 38 bool ohjus2sammutettu = false; 39 40 Image OhjuksenKuva = LoadImage("Ohjus"); 41 Image SavunKuva = LoadImage("Savu"); 42 Image LiekinKuva = LoadImage("Liekki"); 43 20 44 protected override void Begin() 21 45 { 46 47 48 voimaMittari1 = new DoubleMeter(10000); 49 voimaMittari1.MaxValue = 10000; 50 voimaPalkki1 = new BarGauge(13, 150); 51 voimaPalkki1.BindTo(voimaMittari1); 52 voimaPalkki1.X = -320; 53 voimaPalkki1.Y = -500; 54 voimaPalkki1.Angle = Angle.Degrees(90); 55 Add(voimaPalkki1); 56 57 voimaMittari2 = new DoubleMeter(10000); 58 voimaMittari2.MaxValue = 10000; 59 voimaPalkki2 = new BarGauge(13, 150); 60 voimaPalkki2.BindTo(voimaMittari2); 61 voimaPalkki2.X = 320; 62 voimaPalkki2.Y = -500; 63 voimaPalkki2.Angle = Angle.Degrees(90); 64 Add(voimaPalkki2); 65 66 67 68 testikentta1 = new Label(); 69 testikentta2 = new Label(); 70 71 testikentta1.X = Screen.Left + 100; 72 testikentta1.Y = Screen.Top - 100; 73 testikentta2.X = Screen.Right - 100; 74 testikentta2.Y = Screen.Top - 100; 75 Add(testikentta1); 76 Add(testikentta2); 77 78 79 80 22 81 Laskuri1 = LuoAikaLaskuri(-150, 0); 23 82 Laskuri2 = LuoAikaLaskuri(150, 0); … … 31 90 Add(laukaisualusta1); 32 91 92 33 93 laukaisualusta2 = PhysicsObject.CreateStaticObject(60, 20); 34 94 laukaisualusta2.Shape = Shapes.Rectangle; … … 39 99 40 100 41 Shape shape = Shapes.FromImage( 1200, 400,maastonKuva);101 Shape shape = Shapes.FromImage(maastonKuva); 42 102 PhysicsObject maasto = PhysicsObject.CreateStaticObject(1200, 400, shape ); 103 maasto.Image = maastonKuva; 43 104 maasto.Y = Level.Bottom + maasto.Height / 2.5; 44 105 Add(maasto); … … 48 109 Camera.StayInLevel = true; 49 110 50 ohjus1 = LuoOhjus(-400, -340); 51 ohjus2 = LuoOhjus(400, -340); 52 111 ohjus1 = LuoOhjus(-400, OhjuksenAloitusKorkeus); 112 ohjus2 = LuoOhjus(400, OhjuksenAloitusKorkeus); 113 114 polttoaine1 = LuoPolttoaineLaskuri(ohjus1); 115 testikentta1.BindTo(polttoaine1.SecondCounter); 116 polttoaine2 = LuoPolttoaineLaskuri(ohjus2); 117 testikentta2.BindTo(polttoaine2.SecondCounter); 53 118 54 119 … … 66 131 ohjus.Y = y; 67 132 AddCollisionHandler(ohjus, Tormays); 133 ohjus.Image = OhjuksenKuva; 68 134 Add(ohjus); 135 69 136 return ohjus; 70 137 } 138 71 139 private void nollaaOhjus(PhysicsObject ohjus, double x, double y) 72 140 { … … 75 143 ohjus.Stop(); 76 144 ohjus.Angle = new Angle(); 145 if (ohjus.Tag == ohjus1) 146 { 147 ohjus1sammutettu = false; 148 } 149 else if (ohjus.Tag == ohjus2) 150 { 151 ohjus2sammutettu = false; 152 } 77 153 Add(ohjus); 78 154 } 79 155 156 void Sammuta(Timer ajastin) 157 { 158 if (ajastin.Tag == ohjus1) 159 { 160 ohjus1sammutettu = true; 161 } 162 if (ajastin.Tag == ohjus2) 163 { 164 ohjus2sammutettu = true; 165 } 166 167 ajastin.Reset(); 168 ajastin.Stop(); 169 } 80 170 81 171 void AsetaOhjaimet() … … 110 200 void Paivitys() 111 201 { 112 ohjus1.Push(Vector.FromLengthAndAngle(1500, ohjus1.Angle + Angle.RightAngle)); 113 ohjus2.Push(Vector.FromLengthAndAngle(1500, ohjus2.Angle + Angle.RightAngle)); 202 if (!ohjus1sammutettu) ohjus1.Push(Vector.FromLengthAndAngle(1500, ohjus1.Angle + Angle.RightAngle)); 203 if (!ohjus2sammutettu) ohjus2.Push(Vector.FromLengthAndAngle(1500, ohjus2.Angle + Angle.RightAngle)); 204 114 205 } 115 206 … … 134 225 Level.CreateBottomBorder(); 135 226 Level.CreateTopBorder(); 227 Level.CreateLeftBorder(); 228 Level.CreateRightBorder(); 229 230 136 231 } 137 232 … … 142 237 rajahdys.Position = ohjus.Position; 143 238 rajahdys.Speed = 300.0; 144 rajahdys.Force = 90;239 rajahdys.Force = 300; 145 240 Add(rajahdys); 146 241 … … 148 243 { 149 244 KaynnistaLaskuri(Laskuri1, ohjusOdotus); 150 } 245 ohjus1sammutettu = false; 246 polttoaine1.Reset(); 247 polttoaine1.Stop(); 248 } 249 151 250 if (ohjus == ohjus2) 152 251 { 153 252 KaynnistaLaskuri(Laskuri2, ohjusOdotus); 154 } 155 } 253 ohjus2sammutettu = false; 254 polttoaine2.Reset(); 255 polttoaine2.Stop(); 256 } 257 if (kohde == laukaisualusta1) 258 { 259 voimaMittari1.Value -= 1000; 260 } 261 262 if (kohde == laukaisualusta2) 263 { 264 voimaMittari2.Value -= 1000; 265 } 266 267 if (voimaMittari1.Value<= 0 ) 268 { 269 Exit(); 270 } 271 272 if (voimaMittari2.Value <= 0) 273 { 274 Exit(); 275 } 276 277 if (voimaMittari1.Value <= 5000) 278 { 279 280 Flames liekki = new Flames(SavunKuva, 50, Angle.Degrees(-90)); 281 liekki.Position = new Vector(-400, -370); 282 Add(liekki); 283 284 } 285 286 if (voimaMittari2.Value <= 5000) 287 { 288 289 Flames liekki = new Flames(SavunKuva, 50, Angle.Degrees(-90)); 290 liekki.Position = new Vector(400, -370); 291 Add(liekki); 292 293 } 294 295 if (voimaMittari1.Value <= 2000) 296 { 297 298 Flames liekki = new Flames(LiekinKuva, 50, Angle.Degrees(-90)); 299 liekki.Position = new Vector(-395, -370); 300 Add(liekki); 301 302 } 303 304 if (voimaMittari2.Value <= 2000) 305 { 306 307 Flames liekki = new Flames(LiekinKuva, 50, Angle.Degrees(-90)); 308 liekki.Position = new Vector(395, -370); 309 Add(liekki); 310 311 } 312 313 314 315 316 } 317 318 319 320 321 322 Timer LuoPolttoaineLaskuri(PhysicsObject ohjus) 323 { 324 Timer polttoaine = new Timer(); 325 polttoaine.Interval = 5.3; 326 polttoaine.Start(); 327 polttoaine.Tag = ohjus; 328 polttoaine.Trigger += Sammuta; 329 return polttoaine; 330 331 } 332 156 333 157 334 Timer LuoAikaLaskuri(double x, double y) … … 163 340 aikaLaskuri.Trigger += LaskeAlaspain; 164 341 aikaLaskuri.Tag = alaspainLaskuri; 165 Add(aikaLaskuri);342 //Add(aikaLaskuri); 166 343 167 344 Label aikaNaytto = new Label(); … … 180 357 DoubleMeter alaspainLaskuri = (DoubleMeter)(timer.Tag); 181 358 alaspainLaskuri.Value = aikaaJaljella; 182 183 359 timer.Start(); 184 360 } … … 196 372 if (timer == Laskuri1) 197 373 { 198 nollaaOhjus(ohjus1, -400, -340); 374 nollaaOhjus(ohjus1, -400, OhjuksenAloitusKorkeus); 375 polttoaine1.Reset(); 376 polttoaine1.Start(); 199 377 } 200 378 201 379 if (timer == Laskuri2) 202 380 { 203 nollaaOhjus(ohjus2, 400, -340); 381 nollaaOhjus(ohjus2, 400, OhjuksenAloitusKorkeus); 382 polttoaine2.Reset(); 383 polttoaine2.Start(); 204 384 } 205 385 … … 208 388 } 209 389 210 211 212 213 214 390 215 391 216 392
Note: See TracChangeset
for help on using the changeset viewer.