Changeset 4738 for 2013/27/HenrikS
- Timestamp:
- 2013-07-26 12:29:10 (7 years ago)
- Location:
- 2013/27/HenrikS/Masa Majava/MasaMajavanMaailma/MasaMajavanMaailma
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/HenrikS/Masa Majava/MasaMajavanMaailma/MasaMajavanMaailma/Debug.txt
r4501 r4738 1 O O2 O O3 O O4 O O5 O OEEEEE6 O O7 O O J8 O O O9 O K O O10 O O O11 O O O12 O O OI I13 O14 M L m Om15 O1 S S 2 S S 3 S S 4 S S 5 S S EEEEE 6 S S 7 S S J * 8 S S S 9 S K S S 10 S S S 11 S S S 12 S S S I I 13 S 14 M L l l m S m 15 S 16 16 OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO -
2013/27/HenrikS/Masa Majava/MasaMajavanMaailma/MasaMajavanMaailma/Peli.cs
r4501 r4738 11 11 public Timer HyokkaysTimer; 12 12 13 public Loukku( double leveys, double korkeus)13 public Loukku(double leveys, double korkeus) 14 14 : base(leveys, korkeus) 15 15 { … … 28 28 const double hyppyNopeus = 1691; 29 29 const double lentonopeus = 21400; 30 const double leijuntanopeus = 1000; 30 31 const int RUUDUN_KOKO = 40; 31 bool onkoJetPak = false; 32 bool jetPakKeratty = false; 33 bool onkoAse = false; 32 34 33 35 PlatformCharacter pelaaja1; … … 70 72 Image isoloukkuhyokkausvasen = LoadImage("IsoLoukkuHyökkäysVasen"); 71 73 Image loukkutör = LoadImage("PieniLoukkuTör"); 72 74 73 75 Image multaseina = LoadImage("Multa seinä"); 74 76 Image lopetusnaytto = LoadImage("Loppu näyttö"); … … 81 83 // Image kyltti = LoadImage("Kyltti"); 82 84 85 ListenContext jetPackOhjaimet; 86 ListenContext normaaliOhjaus; 87 83 88 ExplosionSystem hajotus; 84 89 ExplosionSystem hajotus2; 85 90 86 91 bool masaKatsooOikealle = true; 87 bool masaLyo = false;88 92 bool onkoilmassa = false; 89 93 … … 94 98 95 99 public override void Begin() 100 { 101 SetWindowSize(1024, 768, true); 102 UusiPeli(); 103 } 104 105 public void UusiPeli() 96 106 { 97 107 Elama = new DoubleMeter(10); … … 101 111 lisaaKeppimittari(); 102 112 lisaaElamamittari(); 103 113 104 114 hajotus = new ExplosionSystem(LoadImage("Lentävälauta"), 50); 105 115 … … 114 124 protected override void Update(Time time) 115 125 { 116 117 118 119 120 base.Update(time); 121 122 if (kepit.Value == 100) 126 base.Update(time); 127 128 if (kepit.Value == 100) 129 { 130 131 Elama.MaxValue += 5; 132 Elama.Value = Elama.MaxValue; 133 kepit.Value = 0; 134 } 135 136 137 if (!pelaaja1.IsDestroyed && pelaaja1 != null) 138 { 139 if (pelaaja1.Top < Level.Bottom) 123 140 { 124 125 Elama.MaxValue += 5; 126 Elama.Value = Elama.MaxValue; 127 kepit.Value = 0; 141 pelaaja1.Destroy(); 142 UusiPeli(); 128 143 } 129 130 131 if (!pelaaja1.IsDestroyed && pelaaja1 != null) 132 { 133 if (pelaaja1.Top < Level.Bottom) 134 { 135 pelaaja1.Destroy(); 136 Begin(); 137 } 138 } 139 140 } 141 144 } 145 146 } 147 142 148 void aloitapeli(int kenttanumero) 143 149 { 144 150 145 151 //ClearAll(); 146 152 double esMaara = 0; … … 182 188 luokentta4(); 183 189 } 184 lisaaNappaimet(); 190 LisaaNappaimet(); 191 192 if (jetPakKeratty) 193 jetPackOhjaimet.Enable(); 185 194 186 195 Camera.Follow(pelaaja1); 187 196 Camera.ZoomFactor = 1.2; 188 197 Camera.StayInLevel = true; 189 198 190 199 } 191 200 … … 198 207 } 199 208 200 209 201 210 #region uusi kentänluonti 202 211 … … 228 237 229 238 #endregion 230 231 239 232 240 #region Vanha kentänluonti … … 284 292 Level.Background.FitToLevel(); 285 293 Layers[-2].RelativeTransition = new Vector(0.1, 0.1); 286 287 294 295 288 296 } 289 297 … … 311 319 312 320 Level.CreateBorders(); 313 321 314 322 315 323 … … 319 327 Level.Background.FitToLevel(); 320 328 Add(taustakuva, -2); 321 329 322 330 Layers[-2].RelativeTransition = new Vector(0.1, 0.1); 323 331 Add(hajotus); … … 365 373 Layers[-2].RelativeTransition = new Vector(0.1, 0.1); 366 374 Add(hajotus); 367 Add 375 Add(hajotus2); 368 376 } 369 377 … … 399 407 Add(seina, -1); 400 408 } 401 409 402 410 void lisaaJuusto(Vector paikka, double leveys, double korkeus) 403 411 { … … 412 420 void lisaakyltti(Vector paikka, double leveys, double korkeus) 413 421 { 414 PhysicsObject kyltti = PhysicsObject.CreateStaticObject(85, 120); 422 PhysicsObject kyltti = new PhysicsObject(85, 120); 423 kyltti.IgnoresGravity = true; 415 424 kyltti.IgnoresCollisionResponse = true; 416 425 kyltti.Image = Kyltti; … … 424 433 void lisaaESplus(Vector paikka, double leveys, double korkeus) 425 434 { 426 PhysicsObject ESplus = PhysicsObject.CreateStaticObject(90, 90); 435 PhysicsObject ESplus = new PhysicsObject(90, 90); 436 ESplus.IgnoresGravity = true; 427 437 ESplus.IgnoresCollisionResponse = true; 428 438 ESplus.Image = Plussa; … … 489 499 void lisaaKitara(Vector paikka, double leveys, double korkeus) 490 500 { 491 PhysicsObject kitara = PhysicsObject.CreateStaticObject(65, 120); 501 if (onkoAse) 502 { 503 return; 504 } 505 PhysicsObject kitara = new PhysicsObject(65, 120); 506 kitara.IgnoresGravity = true; 492 507 kitara.IgnoresCollisionResponse = true; 493 508 kitara.Image = Kiitara; … … 499 514 void lisaaTahti(Vector paikka, double leveys, double korkeus) 500 515 { 501 PhysicsObject tahti = PhysicsObject.CreateStaticObject(70, 60); 516 PhysicsObject tahti = new PhysicsObject(70, 60); 517 tahti.IgnoresGravity = true; 502 518 tahti.IgnoresCollisionResponse = true; 503 519 tahti.Shape = Shape.Rectangle; … … 536 552 void lisaaJetpak(Vector paikka, double leveys, double korkeus) 537 553 { 538 PhysicsObject jetpak = PhysicsObject.CreateStaticObject(65, 90); 554 if (jetPakKeratty) 555 { 556 return; 557 } 558 559 PhysicsObject jetpak = new PhysicsObject(65, 90); 560 jetpak.IgnoresGravity = true; 539 561 jetpak.IgnoresCollisionResponse = true; 540 562 jetpak.Image = Jetpack; … … 542 564 jetpak.Position = paikka; 543 565 Add(jetpak); 566 544 567 } 545 568 546 569 void lisaaES(Vector paikka, double leveys, double korkeus) 547 570 { 548 PhysicsObject es = PhysicsObject.CreateStaticObject(40, 80);571 PhysicsObject es = new PhysicsObject(40, 80); 549 572 es.Image = Polttoaine; 550 573 es.IgnoresCollisionResponse = true; 574 es.IgnoresGravity = true; 551 575 es.Tag = "ES"; 552 576 es.Position = paikka; … … 585 609 AddCollisionHandler(pelaaja1, osuTahteen); 586 610 AddCollisionHandler(pelaaja1, osuJetpakiin); 587 AddCollisionHandler(pelaaja1, "laatikko", osuLaatikkoon);588 611 AddCollisionHandler(pelaaja1, osuKitaraan); 589 612 AddCollisionHandler(pelaaja1, osuMaaliin); … … 594 617 AddCollisionHandler(pelaaja1, maassa); 595 618 596 597 if (onkoJetPak) 598 { 619 620 if (jetPakKeratty) 621 { 622 //jetPackOhjaimet.Enable(); 599 623 AddCollisionHandler(pelaaja1, osuES); 600 624 } 601 625 602 603 604 AddCollisionHandler(pelaaja1, osuLoukkuun); 626 AddCollisionHandler(pelaaja1, "loukku", osuLoukkuun); 627 AddCollisionHandler(pelaaja1, "vasenloukku", osuLoukkuun); 605 628 AddCollisionHandler(pelaaja1, osuIsoonLoukkuun); 606 629 //pelaaja1.Shape = Shape.Circle; … … 609 632 } 610 633 634 611 635 void PelaajanAnimaatiot() 612 636 { … … 615 639 pelaaja1.AnimIdle = new Animation(pelaajanKuvaOikea); 616 640 pelaaja1.AnimIdle.FPS = 1; 617 // pelaaja1.AnimFall = new Animation(pelaajanKuvaOikea);618 // pelaaja1.AnimFall.FPS = 1;641 // pelaaja1.AnimFall = new Animation(pelaajanKuvaOikea); 642 // pelaaja1.AnimFall.FPS = 1; 619 643 pelaaja1.Image = pelaajanKuvaOikea; 620 644 621 645 SkipFrame = true; 622 646 623 Image[] lento = new Image[] {Pelaajalentaa};647 Image[] lento = new Image[] { Pelaajalentaa }; 624 648 625 649 LentoAnimaatio = new Animation(lento); … … 627 651 } 628 652 629 void lisaaNappaimet() 630 { 653 void VaihdaResoluutio() 654 { 655 SetWindowSize(1280, 768, true); 656 } 657 658 void LisaaNappaimet() 659 { 660 jetPackOhjaimet = ControlContext.CreateSubcontext(); 661 normaaliOhjaus = ControlContext.CreateSubcontext(); 662 631 663 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 632 664 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 633 665 634 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 635 Keyboard.Listen(Key.Right, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 636 Keyboard.Listen(Key.X, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 637 if (onkoJetPak) 638 { 639 Keyboard.Listen(Key.Up, ButtonState.Down, kaytajetpak, "Käyttää Jetpakiä", pelaaja1, lentonopeus); 640 Keyboard.Listen(Key.Up, ButtonState.Released, PelaajanAnimaatiot, "Lopettaa lennon"); 641 642 ControllerOne.Listen(Button.DPadUp, ButtonState.Down, kaytajetpak, "Käyttää Jetpakiä", pelaaja1, lentonopeus); 643 ControllerOne.Listen(Button.DPadUp, ButtonState.Released, PelaajanAnimaatiot, "Lopettaa lennon"); 644 } 645 646 ControllerOne.Listen(Button.X, ButtonState.Pressed, hakkaa, "Hakkaa kitaralla", pelaaja1); 647 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 648 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 649 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 650 ControllerOne.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 666 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus).InContext(normaaliOhjaus); 667 Keyboard.Listen(Key.Right, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus).InContext(normaaliOhjaus); 668 Keyboard.Listen(Key.X, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus).InContext(normaaliOhjaus); 669 670 Keyboard.Listen(Key.D1, ButtonState.Pressed, VaihdaResoluutio, "Vaihda resoluutio"); 671 672 //if (jetPakKeratty) 673 //{ 674 675 Keyboard.Listen(Key.X, ButtonState.Down, kaytajetpak, "Käyttää Jetpakiä", pelaaja1, lentonopeus, 0.035).InContext(jetPackOhjaimet); 676 Keyboard.Listen(Key.X, ButtonState.Released, PelaajanAnimaatiot, "Lopettaa lennon").InContext(jetPackOhjaimet); 677 ControllerOne.Listen(Button.A, ButtonState.Down, kaytajetpak, "Käyttää Jetpakiä", pelaaja1, lentonopeus, 0.035).InContext(jetPackOhjaimet); 678 ControllerOne.Listen(Button.A, ButtonState.Released, PelaajanAnimaatiot, "Lopettaa lennon").InContext(jetPackOhjaimet); 679 680 681 682 Keyboard.Listen(Key.Space, ButtonState.Pressed, delegate() { pelaaja1.Stop(); }, null).InContext(jetPackOhjaimet); 683 ControllerOne.Listen(Button.RightTrigger, ButtonState.Pressed, delegate() { pelaaja1.Stop(); }, null).InContext(jetPackOhjaimet); 684 ControllerOne.Listen(Button.RightShoulder, ButtonState.Pressed, delegate() { pelaaja1.Stop(); }, null).InContext(jetPackOhjaimet); 685 Keyboard.Listen(Key.Space, ButtonState.Down, leijunta, null, pelaaja1, true).InContext(jetPackOhjaimet); 686 ControllerOne.Listen (Button.RightTrigger, ButtonState.Down, leijunta, null, pelaaja1, true).InContext(jetPackOhjaimet); 687 ControllerOne.Listen (Button.RightShoulder, ButtonState.Down, leijunta, null, pelaaja1, true).InContext(jetPackOhjaimet); 688 Keyboard.Listen(Key.Space, ButtonState.Released, leijunta, null, pelaaja1, false).InContext(jetPackOhjaimet); 689 ControllerOne.Listen(Button.RightShoulder, ButtonState.Released, leijunta, null, pelaaja1, false).InContext(jetPackOhjaimet); 690 ControllerOne.Listen(Button.RightTrigger, ButtonState.Released, leijunta, null, pelaaja1, false).InContext(jetPackOhjaimet); 691 692 jetPackOhjaimet.Disable(); 693 694 //} 695 696 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 697 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus).InContext(normaaliOhjaus); 698 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus).InContext(normaaliOhjaus); 699 ControllerOne.ListenAnalog(AnalogControl.LeftStick, 0.114, liikutaTatilla, "Pelaaja liikkuu", pelaaja1, nopeus).InContext(normaaliOhjaus); 700 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus).InContext(normaaliOhjaus); 701 702 ControllerOne.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus).InContext(normaaliOhjaus); 703 704 normaaliOhjaus.Enable(); 705 706 if ( onkoAse ) 707 { 708 asetaAseKontrollit(); 709 } 651 710 } 652 711 … … 654 713 { 655 714 ESmittari = LuoESmittari(600, 500, esMaara); 656 Label ES = new Label("E S");715 Label ES = new Label("Energiajuoma"); 657 716 ES.X = 300; 658 717 ES.Y = 380; … … 683 742 void lisaaKeppimittari() 684 743 { 685 744 686 745 Label klapit = new Label("Klapit"); 687 746 klapit.X = -300; … … 697 756 void LuoKeppiMittari() 698 757 { 699 758 700 759 Label keppinaytto = new Label(); 701 760 keppinaytto.BindTo(kepit); … … 735 794 } 736 795 737 void kaytajetpak(PlatformCharacter hahmo, double nopeus) 738 { 739 if (ESmittari.Value > 0.0) 796 bool IsDpadUpDown() 797 { 798 return Microsoft.Xna.Framework.Input.GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One).IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.DPadUp); 799 } 800 801 void kaytajetpak(PlatformCharacter hahmo, double nopeus, double mittariVahennys) 802 { 803 if (ESmittari.Value > 0.0 && (Keyboard.GetKeyState(Key.Up) == ButtonState.Down || IsDpadUpDown() || ControllerOne.LeftThumbDirection.Y >= 0.15)) 740 804 { 741 805 hahmo.Push(new Vector(0, nopeus)); 742 ESmittari.Value -= 0.035;806 ESmittari.Value -= mittariVahennys; 743 807 pelaaja1.AnimWalk = null; 744 808 pelaaja1.AnimIdle = null; 745 809 pelaaja1.PlayAnimation(LentoAnimaatio); 746 } 747 } 810 onkoilmassa = true; 811 } 812 813 } 814 815 void leijunta(PlatformCharacter hahmo, bool leijuuko) 816 { 817 if (ESmittari.Value > 0.0) 818 { 819 pelaaja1.AnimWalk = null; 820 pelaaja1.AnimIdle = null; 821 pelaaja1.PlayAnimation(LentoAnimaatio); 822 ESmittari.Value -= 0.02; 823 pelaaja1.IgnoresGravity = leijuuko; 824 } 825 else 826 { 827 pelaaja1.IgnoresGravity = false; 828 } 829 } 830 831 PhysicsObject ase; 748 832 749 833 void hakkaa(PlatformCharacter hahmo) 750 834 { 751 pelaaja1.Width = 170; 752 753 pelaaja1.AnimIdle = null; 754 pelaaja1.AnimWalk = null; 755 756 //pelaaja1. 835 // pelaaja1.AnimIdle = null; 836 // pelaaja1.AnimWalk = null; 837 ase = new PhysicsObject(75, 35); 838 ase.IgnoresCollisionResponse = true; 839 ase.Y = pelaaja1.Y; 840 if (Keyboard.GetKeyState(Key.Up) == ButtonState.Down || IsDpadUpDown()|| ControllerOne.LeftThumbDirection.Y >= 0.18) 841 { 842 843 if ( pelaaja1.FacingDirection == Direction.Right)// masaKatsooOikealle) 844 { 845 ase.X = pelaaja1.X - 75; 846 847 848 } 849 850 else 851 { 852 ase.X = pelaaja1.X + 75; 853 } 854 855 ase.IgnoresGravity = true; 856 Add(ase); 857 AxleJoint liitos = new AxleJoint(pelaaja1, ase, pelaaja1.Position); 858 Add(liitos); 859 //ase.MomentOfInertia = 10; 860 861 normaaliOhjaus.Disable(); 862 pelaaja1.IgnoresGravity = true; 863 pelaaja1.Stop(); 864 865 866 867 ase.Hit(new Vector(0, /*ase.MomentOfInertia **/ 500 + pelaaja1.Acceleration.Y)); 868 Timer.SingleShot(0.8, toinenAjastinlaukesi); 869 Timer.SingleShot(0.875, vielYksAjastinlaukesi); 870 } 871 872 else 873 { 874 875 876 877 if (masaKatsooOikealle) 878 { 879 ase.X = pelaaja1.X + 75; 880 ase.CanRotate = false; 881 Add(ase); 882 AxleJoint liitos = new AxleJoint(pelaaja1, ase, pelaaja1.Position); 883 Add(liitos); 884 885 ase.X = pelaaja1.X - 75; 886 } 887 else 888 { 889 ase.X = pelaaja1.X - 75; 890 ase.CanRotate = false; 891 Add(ase); 892 AxleJoint liitos = new AxleJoint(pelaaja1, ase, pelaaja1.Position); 893 Add(liitos); 894 895 ase.X = pelaaja1.X + 75; 896 } 897 Timer.SingleShot(0.11, ajastinlaukesi); 898 } 899 AddCollisionHandler(ase, "laatikko", osuLaatikkoon); 900 AddCollisionHandler(ase, "vasenloukku", hakkaaLoukkua); 901 AddCollisionHandler(ase, "loukku", hakkaaLoukkua); 902 AddCollisionHandler(ase, "loukkuJumissa", hakkaaLoukkua); 903 904 Keyboard.Disable(Key.Z); 905 ControllerOne.Disable(Button.X); 906 907 757 908 if (!onkoilmassa) 758 909 { 759 Keyboard.Disable(Key.Down);760 910 Keyboard.Disable(Key.Left); 761 911 Keyboard.Disable(Key.Right); 762 Keyboard.Disable(Key.Space); 763 Keyboard.Disable(Key.Up); 912 ControllerOne.Disable(Button.DPadRight); 913 ControllerOne.Disable(Button.DPadLeft); 914 ControllerOne.Disable(AnalogControl.LeftStick); 915 ControllerOne.Disable(AnalogControl.RightStick); 916 764 917 765 918 pelaaja1.Velocity = new Vector(0, 0); … … 769 922 { 770 923 //pelaaja1.Image = masahakkaaVasen; 771 pelaaja1.Image = masahakkaaOikea;772 pelaaja1.Shape = Shape.FromImage(masahakkaaVasen);924 // pelaaja1.Image = masahakkaaOikea; 925 // pelaaja1.Shape = Shape.FromImage(masahakkaaVasen); 773 926 } 774 927 else 775 928 { 776 pelaaja1.Image = masahakkaaOikea; 777 pelaaja1.Shape = Shape.FromImage(masahakkaaOikea); 778 } 779 780 781 Timer.SingleShot(0.11, ajastinlaukesi); 929 // pelaaja1.Image = masahakkaaOikea; 930 // pelaaja1.Shape = Shape.FromImage(masahakkaaOikea); 931 } 932 } 933 934 void asetaAseKontrollit () 935 { 936 Keyboard.Listen(Key.Z, ButtonState.Pressed, hakkaa, "Hakkaa kitaralla", pelaaja1); 937 ControllerOne.Listen(Button.X, ButtonState.Pressed, hakkaa, "Hakkaa kitaralla", pelaaja1); 782 938 } 783 939 … … 786 942 if (pelaaja1.FacingDirection == Direction.Left) 787 943 { 788 pelaaja1.Image = masahakkaaOikeaPAM;789 pelaaja1.Shape = Shape.FromImage(masahakkaaVasenTUM); 944 // pelaaja1.Image = masahakkaaOikeaPAM; 945 790 946 } 791 947 else 792 948 { 793 pelaaja1.Image = masahakkaaOikeaPAM; 794 pelaaja1.Shape = Shape.FromImage(masahakkaaOikeaPAM); 795 } 796 797 masaLyo = true; 949 950 // pelaaja1.Image = masahakkaaOikeaPAM; 951 952 } 953 954 798 955 Timer.SingleShot(0.06, toinenAjastinlaukesi); 799 956 Timer.SingleShot(0.135, vielYksAjastinlaukesi); 800 957 } 801 958 802 959 void toinenAjastinlaukesi() 803 960 { 961 962 ase.Destroy(); 804 963 PelaajanAnimaatiot(); 805 pelaaja1.Width = 75; 806 masaLyo = false; 807 808 if (masaKatsooOikealle) 809 { 810 pelaaja1.Shape = Shape.FromImage(pelaajanKuvaOikea); 811 } 812 else 813 { 814 pelaaja1.Shape = Shape.FromImage(pelaajanKuvaVasen); 815 } 964 pelaaja1.IgnoresGravity = false; 965 normaaliOhjaus.Enable(); 966 967 968 969 970 /* if (masaKatsooOikealle) 971 { 972 pelaaja1.Shape = Shape.FromImage(pelaajanKuvaOikea); 973 } 974 else 975 { 976 pelaaja1.Shape = Shape.FromImage(pelaajanKuvaVasen); 977 }*/ 978 816 979 } 817 980 818 981 void vielYksAjastinlaukesi() 819 { 820 Keyboard.EnableAll(); 821 } 982 { 983 Keyboard.EnableAll(); 984 ControllerOne.EnableAll(); 985 } 986 987 void liikutaTatilla(AnalogState tatinTila, PlatformCharacter hahmo, double nopeus) 988 { 989 liikuta(hahmo, tatinTila.StateVector.X * nopeus); 990 } 822 991 823 992 void liikuta(PlatformCharacter hahmo, double nopeus) … … 830 999 masaKatsooOikealle = true; 831 1000 832 if (Liikeesto != Math.Sign(nopeus)) 1001 PhysicsObject seina = etsiviereinenseina(hahmo); 1002 PhysicsObject lattia = etsiLattia(hahmo); 1003 1004 if (seina != null && lattia == null) 1005 { 1006 if (masaKatsooOikealle) 1007 { 1008 masaKatsooOikealle = false; 1009 hahmo.Turn(Direction.Left); 1010 } 1011 else 1012 { 1013 masaKatsooOikealle = true; 1014 hahmo.Turn(Direction.Right); 1015 } 1016 } 1017 if (Liikeesto != Math.Sign(nopeus)) 833 1018 { 834 1019 if (Liikeesto == 1) … … 846 1031 } 847 1032 } 848 1033 849 1034 } 850 1035 else SkipFrame = false; … … 858 1043 } 859 1044 } 860 //IntMeter hyppyvoima = new IntMeter(18);861 void hyppaa(PlatformCharacter hahmo, double nopeus)1045 //IntMeter hyppyvoima = new IntMeter(18); 1046 void hyppaa(PlatformCharacter hahmo, double nopeus) 862 1047 { 863 1048 … … 869 1054 if (seina != null) 870 1055 { 1056 871 1057 Timer ajastin = new Timer(); 872 1058 Timer ajastin2 = new Timer(); … … 880 1066 }; 881 1067 ajastin.Start(); 1068 onkoilmassa = true; 882 1069 ajastin2.Start(); 883 Timer.SingleShot(0.25, delegate() { 884 ajastin.Stop(); 885 1070 Timer.SingleShot(0.25, delegate() 1071 { 1072 ajastin.Stop(); 1073 886 1074 }); 887 1075 Timer.SingleShot(0.62, delegate() 888 1076 { 1077 889 1078 Liikeesto = 0; 890 1079 }); … … 899 1088 900 1089 //tätä ei ehkä tarvi: 901 // if (hahmo.Jump(nopeus)) hyppyvoima = new IntMeter(18); 902 // else if (hyppyvoima.Value-- > 0) hahmo.ForceJump(35); 903 } 904 1090 // if (hahmo.Jump(nopeus)) hyppyvoima = new IntMeter(18); 1091 // else if (hyppyvoima.Value-- > 0) hahmo.ForceJump(35); 1092 } 1093 1094 PhysicsObject etsiLattia(PlatformCharacter hahmo) 1095 { 1096 return (PhysicsObject)GetFirstObject(olio => 1097 ( 1098 (Math.Abs(olio.Y - (hahmo.Y - hahmo.Height / 2 - 10)) < hahmo.Height) && 1099 (Math.Abs(olio.X - hahmo.X) < olio.Width / 2) && 1100 (olio is PhysicsObject) && 1101 (double.IsInfinity(((PhysicsObject)olio).Mass)) 1102 ) 1103 ); 1104 } 905 1105 PhysicsObject etsiviereinenseina(PlatformCharacter hahmo) 906 1106 { … … 909 1109 ( 910 1110 (Math.Abs(olio.Y - hahmo.Y) < hahmo.Height) && 911 (Math.Abs(olio.X - (hahmo.X + etaisyys)) < olio.Width / 2 1111 (Math.Abs(olio.X - (hahmo.X + etaisyys)) < olio.Width / 2) && 912 1112 (olio is PhysicsObject) && 913 1113 (double.IsInfinity(((PhysicsObject)olio).Mass)) … … 916 1116 } 917 1117 1118 918 1119 void maassa(PhysicsObject hahmo, PhysicsObject kohde) 919 1120 { 920 1121 if 921 (kohde.Y < pelaaja1.Y )1122 (kohde.Y < pelaaja1.Y && double.IsInfinity(kohde.Mass)) 922 1123 { 923 1124 onkoilmassa = false; … … 948 1149 void isoVihollishyokkaus(Loukku isoLoukku) 949 1150 { 950 if ( 1151 if (isoLoukku.X - pelaaja1.X > 0 && isoLoukku.X - pelaaja1.X < 550 && isoLoukku.Y - pelaaja1.Y < 540 && isoLoukku.Y - pelaaja1.Y > -300) 951 1152 { 952 1153 … … 962 1163 Ylaosa.Y = isoLoukku.Y += 300; 963 1164 Add(Ylaosa, 3); 964 PhysicsObject Alaosa = new PhysicsObject(400, 150);1165 PhysicsObject Alaosa = new PhysicsObject(400, 150); 965 1166 Alaosa.Shape = Shape.FromImage(alaosator); 966 1167 Alaosa.Image = alaosa; … … 971 1172 Alaosa.X = isoLoukku.X; 972 1173 Alaosa.Y = isoLoukku.Y - 400; 973 Add 1174 Add(Alaosa, 3); 974 1175 975 1176 isoLoukku.X += 8; 976 1177 isoLoukku.Y -= 185; 977 1178 isoLoukku.Velocity = new Vector(-650, 0); 978 1179 979 1180 isoLoukku.Height = 280; 980 1181 isoLoukku.Width = 400; 981 1182 isoLoukku.Image = isoloukkuhyokkausvasen; 982 1183 983 1184 isoLoukku.HyokkaysTimer.Stop(); 984 1185 985 1186 } 986 1187 } … … 997 1198 void osuPlussaan(PhysicsObject hahmo, PhysicsObject kohde) 998 1199 { 999 // if (kohde.Tag.ToString() == "ESplus")1200 // if (kohde.Tag.ToString() == "ESplus") 1000 1201 //{ 1001 1002 1003 // }1202 // mittari.MaxValue += 10; 1203 1204 // } 1004 1205 } 1005 1206 … … 1013 1214 } 1014 1215 1216 void hakkaaLoukkua(PhysicsObject ase, PhysicsObject kohde) 1217 { 1218 int pMaara = 50; 1219 double x = kohde.X; 1220 double y = kohde.Y; 1221 1222 hajotus2.AddEffect(x, y, pMaara); 1223 kohde.Destroy(); 1224 } 1225 1015 1226 void osuLoukkuun(PhysicsObject hahmo, PhysicsObject kohde) 1016 1227 { 1017 if (kohde.Tag.ToString() == "vasenloukku" && (masaLyo == true) || (kohde.Tag.ToString() == "loukkuJumissa" && (masaLyo == true))) 1018 { 1019 1020 1021 1022 int pMaara = 50; 1023 double x = kohde.X; 1024 double y = kohde.Y; 1025 1026 hajotus2.AddEffect(x, y, pMaara); 1027 kohde.Destroy(); 1028 } 1029 else if (kohde.Tag.ToString() == "vasenloukku") 1030 { 1031 1032 Timer ajastin = new Timer(); 1033 Elama.Value -= 2.5; 1034 Timer.SingleShot(0.01, delegate() 1035 1036 { 1037 Keyboard.Disable(Key.Down); 1038 Keyboard.Disable(Key.Left); 1039 Keyboard.Disable(Key.Right); 1040 Keyboard.Disable(Key.Space); 1041 Keyboard.Disable(Key.Up); 1042 1043 ajastin.Interval = 0.001; 1044 ajastin.Timeout += delegate() { pelaaja1.Velocity = new Vector(-700, 750); }; 1045 ajastin.Start(); 1046 1047 }); 1048 1049 Timer.SingleShot(0.24745, delegate() 1050 { 1051 ajastin.Stop(); 1052 Keyboard.EnableAll(); 1053 //Gravity = new Vector(0, -2800); 1054 }); 1055 } 1056 1057 1058 else if (kohde.Tag.ToString() == "loukku") 1059 { 1060 Elama.Value -= 2.5; 1061 } 1228 Timer ajastin = new Timer(); 1229 Elama.Value -= 2.5; 1230 Timer.SingleShot(0.01, delegate() 1231 { 1232 1233 1234 //Keyboard.Disable(Key.Z); 1235 //Keyboard.Disable(Key.Left); 1236 //Keyboard.Disable(Key.Right); 1237 //Keyboard.Disable(Key.X); 1238 //Keyboard.Disable(Key.Up); 1239 1240 normaaliOhjaus.Disable(); 1241 1242 ajastin.Interval = 0.001; 1243 ajastin.Timeout += delegate() { pelaaja1.Velocity = new Vector(-700, 750); }; 1244 ajastin.Start(); 1245 1246 }); 1247 1248 Timer.SingleShot(0.265, delegate() 1249 { 1250 ajastin.Stop(); 1251 // Keyboard.EnableAll(); 1252 normaaliOhjaus.Enable(); 1253 //Gravity = new Vector(0, -2800); 1254 }); 1255 1062 1256 if (Elama.Value == 0) 1063 1257 { 1064 1258 //aloitapeli(kenttatilanne); 1065 Begin();1259 UusiPeli(); 1066 1260 } 1067 1261 … … 1074 1268 Timer Ajastin = new Timer(); 1075 1269 Elama.Value -= 3.5; 1076 Timer.SingleShot (0.01, delegate() 1077 1270 Timer.SingleShot(0.01, delegate() 1078 1271 { 1079 Keyboard.Disable(Key.Down); 1272 normaaliOhjaus.Disable(); 1273 /* Keyboard.Disable(Key.Down); 1080 1274 Keyboard.Disable(Key.Left); 1081 1275 Keyboard.Disable(Key.Right); 1082 1276 Keyboard.Disable(Key.Space); 1083 Keyboard.Disable(Key.Up); 1084 pelaaja1.Velocity = new Vector(0, 0); 1085 1086 Ajastin.Interval = 0.001; 1087 Ajastin.Timeout += delegate() { pelaaja1.Velocity = new Vector(-700, 750); }; 1088 Ajastin.Start(); 1089 1090 Timer.SingleShot(0.24745, delegate() 1091 { 1092 1093 Ajastin.Stop(); 1094 Keyboard.EnableAll(); 1095 1096 Gravity = new Vector(0, -2800); 1097 }); 1277 Keyboard.Disable(Key.Up);*/ 1278 pelaaja1.Velocity = new Vector(0, 0); 1279 1280 Ajastin.Interval = 0.001; 1281 Ajastin.Timeout += delegate() { pelaaja1.Velocity = new Vector(-700, 750); }; 1282 Ajastin.Start(); 1283 1284 Timer.SingleShot(0.24745, delegate() 1285 { 1286 1287 Ajastin.Stop(); 1288 // Keyboard.EnableAll(); 1289 normaaliOhjaus.Enable(); 1290 1291 Gravity = new Vector(0, -2800); 1292 }); 1098 1293 }); 1099 1294 Timer.SingleShot(0.35, delegate() … … 1105 1300 if (Elama.Value <= 0) 1106 1301 { 1107 Begin();1302 UusiPeli(); 1108 1303 } 1109 1304 } … … 1119 1314 loukku.MakeStatic(); 1120 1315 //loukku.Shape = Shape.Rectangle; 1121 loukku.Shape = Shape.FromImage 1316 loukku.Shape = Shape.FromImage(loukkutör); 1122 1317 loukku.IgnoresCollisionResponse = false; 1123 1318 loukku.Tag = "loukkuJumissa"; 1124 1319 } 1125 1126 } 1127 1320 } 1128 1321 1129 1322 void osuKitaraan(PhysicsObject hahmo, PhysicsObject kohde) … … 1131 1324 if (kohde.Tag.ToString() == "Kitara") 1132 1325 { 1326 onkoAse = true; 1133 1327 Label label = new Label("Masa majava: Kitara...mitä minä tällä tekisin? Soittaisin musiikkia?"); 1134 1328 label.TextColor = Color.Black; … … 1141 1335 { 1142 1336 label.Destroy(); 1143 // Add(label2);1337 // Add(label2); 1144 1338 } 1145 1339 ); 1146 1340 Timer.SingleShot(8, label2.Destroy); 1147 1341 1148 Keyboard.Listen(Key.Z, ButtonState.Pressed, hakkaa, "Hakkaa kitaralla", pelaaja1);1342 asetaAseKontrollit(); 1149 1343 kohde.Destroy(); 1150 1344 } 1151 1345 } 1152 1346 1153 void osuLaatikkoon(PhysicsObject hahmo, PhysicsObject kohde)1154 { 1155 if (!masaLyo)1347 void osuLaatikkoon(PhysicsObject ase, PhysicsObject kohde) 1348 { 1349 /*if (!masaLyo) 1156 1350 { 1157 1351 hahmo.Hit(new Vector(-Math.Sign(kohde.X - hahmo.X) * 100, 0)); 1158 1352 return; 1159 } 1160 1353 }*/ 1354 1161 1355 1162 1356 … … 1171 1365 label.TextColor = Color.Black; 1172 1366 label.Color = Color.White; 1173 // Add(label);1367 // Add(label); 1174 1368 Timer.SingleShot(3, delegate() 1175 1369 { … … 1186 1380 if (kohde.Tag.ToString() == "jetpak") 1187 1381 { 1188 onkoJetPak= true;1382 jetPakKeratty = true; 1189 1383 1190 1384 Label label = new Label("Masa majava: Voi pojat, jetpack! Tällähän voi lentää painamalla 'Ylös'!"); … … 1213 1407 Add(jetpak); 1214 1408 1409 jetPackOhjaimet.Enable(); 1410 1215 1411 kohde.Destroy(); 1216 1412 AddCollisionHandler(pelaaja1, osuES); 1217 Keyboard.Listen(Key.Up, ButtonState.Down, kaytajetpak, "Käyttää Jetpakiä", pelaaja1, lentonopeus);1218 Keyboard.Listen(Key.Up, ButtonState.Released, PelaajanAnimaatiot, "Lopettaa lennon");1219 ControllerOne.Listen(Button.DPadUp, ButtonState.Down, kaytajetpak, "Käyttää Jetpakiä", pelaaja1, lentonopeus);1220 ControllerOne.Listen(Button.DPadUp, ButtonState.Released, PelaajanAnimaatiot, "Lopettaa lennon");1221 1413 } 1222 1414 } … … 1227 1419 { 1228 1420 1229 1421 1230 1422 kohde.Destroy(); 1231 1423 ESmittari.Value += 5; … … 1238 1430 { 1239 1431 kenttatilanne += 1; 1240 1432 1241 1433 //Timer zoomaaja = new Timer(); 1242 // zoomaaja.Interval = 0.00000001;1243 // zoomaaja.Timeout += teeSiirtyma;1244 // zoomaaja.Start();1434 // zoomaaja.Interval = 0.00000001; 1435 // zoomaaja.Timeout += teeSiirtyma; 1436 // zoomaaja.Start(); 1245 1437 //teeSiirtyma(); 1246 1438 aloitapeli(kenttatilanne); … … 1253 1445 //private void teeSiirtyma() 1254 1446 //{ 1255 // Camera.Zoom (zoom);1447 // Camera.Zoom (zoom); 1256 1448 1257 1449 … … 1277 1469 label2.TextColor = Color.Black; 1278 1470 label2.Color = Color.White; 1279 Timer.SingleShot(3, delegate()1280 {1281 label.Destroy();1282 // Add(label2);1283 Timer.SingleShot(3, delegate()1284 {1285 label2.Destroy();1286 });1287 });1471 Timer.SingleShot(3, delegate() 1472 { 1473 label.Destroy(); 1474 // Add(label2); 1475 Timer.SingleShot(3, delegate() 1476 { 1477 label2.Destroy(); 1478 }); 1479 }); 1288 1480 } 1289 1481 } -
2013/27/HenrikS/Masa Majava/MasaMajavanMaailma/MasaMajavanMaailma/kentta1.txt
r4501 r4738 36 36 SS SSSSSS 37 37 SS S 38 * ISS S38 * SS S 39 39 SS E S 40 40 OOOOOOSS S -
2013/27/HenrikS/Masa Majava/MasaMajavanMaailma/MasaMajavanMaailma/kentta2a.txt
r4501 r4738 5 5 SSSSSS l k S 6 6 SSSSSS S 7 SSSSSS SSSSSS 8 SSSSSS S SSSSSSS SSSSSSSSSSS7 SSSSSS SSSSSSSS SSSSSSSSSSS 8 SSSSSS S SSSSSS SSSSSSSSSSS 9 9 SSSSSS SS SSSSSS SSS 10 10 SSSSSS SSSSS SSSSSSSSSSSSSSSSS
Note: See TracChangeset
for help on using the changeset viewer.