Changeset 3589 for 2012/27


Ignore:
Timestamp:
2012-07-05 14:22:17 (11 years ago)
Author:
leotoiol
Message:

Talletus.

Location:
2012/27/LeoL/Marsun matkat/Marsun matkat
Files:
9 added
6 edited

Legend:

Unmodified
Added
Removed
  • 2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkat/Marsun_matkat.cs

    r3553 r3589  
    1414 
    1515    PlatformCharacter pelaaja1; 
     16    PlatformCharacter pelaaja2; 
    1617 
    1718    Image pelaajanKuva = LoadImage("norsu"); 
     19    Image pelaajan2Kuva = LoadImage("joke joke"); 
    1820    Image tahtiKuva = LoadImage("tahti"); 
    1921    Image vihunKuva = LoadImage("mulkkis"); 
    2022    Image psyykkisKuva = LoadImage("psyykkis"); 
    2123    Image hyppisKuva = LoadImage("hyppis"); 
     24    Image lurkkisKuva = LoadImage("lurkkis"); 
     25    Image taplisKuva = LoadImage("taplis"); 
     26    Image konnaKuva = LoadImage("konna"); 
    2227 
    2328    IntMeter vihunHp = new IntMeter(3); 
     
    2934    public override void Begin() 
    3035    { 
    31          
     36 
    3237 
    3338        LuoKentta(); 
     
    3944        string kenttaNimi = "kentta1"; 
    4045        if (kentanNro == 2) 
    41         { 
    4246            kenttaNimi = "kentta2"; 
    43         } 
    4447        if (kentanNro == 3) 
    45         { 
    4648            kenttaNimi = "kentta3"; 
    47         } 
     49        if (kentanNro == 4) 
     50            kenttaNimi = "kentta4"; 
     51        if (kentanNro == 5) 
     52            kenttaNimi = "kentta5"; 
     53        if (kentanNro == 6) 
     54            kenttaNimi = "kentta6"; 
    4855        ClearAll(); 
    4956        Gravity = new Vector(0, -1000); 
     
    5259        kentta.SetTileMethod('*', LisaaTahti); 
    5360        kentta.SetTileMethod('N', LisaaPelaaja); 
     61        kentta.SetTileMethod('n', LisaaPelaaja2); 
    5462        kentta.SetTileMethod('V', LisaaVihu1); 
    5563        kentta.SetTileMethod('M', LisaaVihu2); 
    5664        kentta.SetTileMethod('S', LisaaVihu3); 
     65        kentta.SetTileMethod('L', LisaaVihu4); 
     66        kentta.SetTileMethod('O', LisaaVihu5); 
     67        kentta.SetTileMethod('K', LisaaVihu6); 
    5768        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    5869        Level.CreateBorders(); 
    59         Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
    60  
     70 
     71        if (kentanNro == 6) 
     72        { 
     73            Level.Background.CreateGradient(Color.DarkRed, Color.Black); 
     74            MediaPlayer.Play("vika"); 
     75        } 
     76        else 
     77        { 
     78            Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
     79            MediaPlayer.Play("muut"); 
     80        } 
    6181        LisaaNappaimet(); 
    6282        vihunHp.Value = 3; 
     
    97117    } 
    98118 
     119    void LisaaVihu4(Vector paikka, double leveys, double korkeus) 
     120    { 
     121        PhysicsObject vihu = new PhysicsObject(40, 20); 
     122        vihu.Shape = Shape.Rectangle; 
     123        vihu.Mass = 10.5; 
     124        vihu.Tag = "vihu"; 
     125        vihu.Image = lurkkisKuva; 
     126        Add(vihu); 
     127    } 
     128 
     129    void LisaaVihu5(Vector paikka, double leveys, double korkeus) 
     130    { 
     131        PhysicsObject vihu = new PhysicsObject(40, 20); 
     132        vihu.Shape = Shape.Rectangle; 
     133        vihu.Mass = 10.5; 
     134        vihu.Tag = "vihu"; 
     135        vihu.Image = taplisKuva; 
     136        Add(vihu); 
     137    } 
     138 
     139    void LisaaVihu6(Vector paikka, double leveys, double korkeus) 
     140    { 
     141        PhysicsObject vihu = new PhysicsObject(40, 20); 
     142        vihu.Shape = Shape.Rectangle; 
     143        vihu.Mass = 10.5; 
     144        vihu.Tag = "vihu"; 
     145        vihu.Image = konnaKuva; 
     146        Add(vihu); 
     147    } 
     148 
    99149    void LisaaTaso(Vector paikka, double leveys, double korkeus) 
    100150    { 
    101151        PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    102152        taso.Position = paikka; 
    103         taso.Color = Color.Green; 
     153        if (kentanNro == 6) 
     154            taso.Image = LoadImage("tiili"); 
     155        else 
     156            taso.Image = LoadImage("maa"); 
     157        taso.Tag = "taso"; 
    104158        Add(taso); 
    105159    } 
     
    121175        pelaaja1.Mass = 4.0; 
    122176        pelaaja1.Image = pelaajanKuva; 
    123         AddCollisionHandler(pelaaja1, Tormaa); 
     177        AddCollisionHandler(pelaaja1, "tahti", TormattiinTahteen); 
     178        AddCollisionHandler(pelaaja1, "vihu", TormattiinVihuun); 
    124179        Add(pelaaja1); 
     180    } 
     181 
     182    void LisaaPelaaja2(Vector paikka, double leveys, double korkeus) 
     183    { 
     184        pelaaja2 = new PlatformCharacter(leveys, korkeus); 
     185        pelaaja2.Position = paikka; 
     186        pelaaja2.Mass = 4.0; 
     187        pelaaja2.Image = pelaajan2Kuva; 
     188        AddCollisionHandler(pelaaja2, "tahti", TormattiinTahteen); 
     189        AddCollisionHandler(pelaaja2, "vihu", TormattiinVihuun); 
     190        Add(pelaaja2); 
    125191    } 
    126192 
     
    135201        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    136202 
     203        Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, -nopeus); 
     204        Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, nopeus); 
     205        Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja2, hyppyNopeus); 
     206 
    137207        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    138208 
     
    154224    } 
    155225 
    156     void Tormaa(PhysicsObject hahmo, PhysicsObject kohde) 
    157     { 
    158         if (kohde.Tag.ToString() == "vihu") 
    159         { 
    160             if (hahmo.Bottom >= kohde.Top) 
     226    void TormattiinVihuun(PhysicsObject hahmo, PhysicsObject kohde) 
     227    { 
     228        if (hahmo.Bottom >= kohde.Top) 
     229        { 
     230            vihunHp.Value--; 
     231            bool sijaintiSopiva = false; 
     232            Vector tulevaSijainti = RandomGen.NextVector(Level.Left, Level.Bottom, Level.Right, Level.Top); 
     233            while (!sijaintiSopiva) 
    161234            { 
    162                 vihunHp.Value--; 
    163                 kohde.Position = RandomGen.NextVector(Level.Left, Level.Bottom, Level.Right, Level.Top); 
     235                foreach (GameObject go in GetObjectsWithTag("taso")) 
     236                { 
     237                    if (!go.IsInside(tulevaSijainti)) 
     238                    { 
     239                        sijaintiSopiva = true; 
     240                    } 
     241                    else 
     242                    { 
     243                        sijaintiSopiva = false; 
     244                        tulevaSijainti = RandomGen.NextVector(Level.Left, Level.Bottom, Level.Right, Level.Top); 
     245                        break; 
     246                    } 
     247 
     248                } 
    164249            } 
    165             if (vihunHp.Value <= 0) 
    166             { 
    167                 kohde.Destroy(); 
    168                 kentanNro++; 
    169                 LuoKentta(); 
    170             } 
    171  
    172         } 
    173  
    174         if (kohde.Tag.ToString() == "tahti") 
    175         { 
    176             maaliAani.Play(); 
    177             MessageDisplay.Add("Keräsit tähden!"); 
     250            kohde.Position = tulevaSijainti; 
     251        } 
     252 
     253        if (vihunHp.Value <= 0) 
     254        { 
    178255            kohde.Destroy(); 
    179         } 
    180     } 
    181  
     256            kentanNro++; 
     257            LuoKentta(); 
     258        } 
     259    } 
     260 
     261    void TormattiinTahteen(PhysicsObject hahmo, PhysicsObject kohde) 
     262    { 
     263        maaliAani.Play(); 
     264        MessageDisplay.Add("Keräsit tähden!"); 
     265        kohde.Destroy(); 
     266    } 
    182267} 
  • 2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/Marsun matkatContent.contentproj

    r3553 r3589  
    108108    </Compile> 
    109109  </ItemGroup> 
     110  <ItemGroup> 
     111    <Compile Include="lurkkis.png"> 
     112      <Name>lurkkis</Name> 
     113      <Importer>TextureImporter</Importer> 
     114      <Processor>TextureProcessor</Processor> 
     115    </Compile> 
     116  </ItemGroup> 
     117  <ItemGroup> 
     118    <Compile Include="taplis.png"> 
     119      <Name>taplis</Name> 
     120      <Importer>TextureImporter</Importer> 
     121      <Processor>TextureProcessor</Processor> 
     122    </Compile> 
     123  </ItemGroup> 
     124  <ItemGroup> 
     125    <Compile Include="kentta5.txt"> 
     126      <Name>kentta5</Name> 
     127      <Importer>TextFileImporter</Importer> 
     128      <Processor>TextFileContentProcessor</Processor> 
     129    </Compile> 
     130  </ItemGroup> 
     131  <ItemGroup> 
     132    <Compile Include="konna.png"> 
     133      <Name>konna</Name> 
     134      <Importer>TextureImporter</Importer> 
     135      <Processor>TextureProcessor</Processor> 
     136    </Compile> 
     137  </ItemGroup> 
     138  <ItemGroup> 
     139    <Compile Include="kentta6.txt"> 
     140      <Name>kentta6</Name> 
     141      <Importer>TextFileImporter</Importer> 
     142      <Processor>TextFileContentProcessor</Processor> 
     143    </Compile> 
     144  </ItemGroup> 
     145  <ItemGroup> 
     146    <Compile Include="vika.mp3"> 
     147      <Name>vika</Name> 
     148      <Importer>Mp3Importer</Importer> 
     149      <Processor>SongProcessor</Processor> 
     150    </Compile> 
     151  </ItemGroup> 
     152  <ItemGroup> 
     153    <Compile Include="muut.mp3"> 
     154      <Name>muut</Name> 
     155      <Importer>Mp3Importer</Importer> 
     156      <Processor>SongProcessor</Processor> 
     157    </Compile> 
     158  </ItemGroup> 
     159  <ItemGroup> 
     160    <Compile Include="joke joke.png"> 
     161      <Name>joke joke</Name> 
     162      <Importer>TextureImporter</Importer> 
     163      <Processor>TextureProcessor</Processor> 
     164    </Compile> 
     165  </ItemGroup> 
     166  <ItemGroup> 
     167    <Compile Include="maa.png"> 
     168      <Name>maa</Name> 
     169      <Importer>TextureImporter</Importer> 
     170      <Processor>TextureProcessor</Processor> 
     171    </Compile> 
     172  </ItemGroup> 
     173  <ItemGroup> 
     174    <Compile Include="tiili.png"> 
     175      <Name>tiili</Name> 
     176      <Importer>TextureImporter</Importer> 
     177      <Processor>TextureProcessor</Processor> 
     178    </Compile> 
     179  </ItemGroup> 
    110180  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    111181  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta1.txt

    r3553 r3589  
    1         
     1 
    22          
    33 
     
    1717                ########### 
    1818                            #  
    19                                                N 
     19                                              nN 
    2020##############   ######################## 
    2121############               ************ 
  • 2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta2.txt

    r3553 r3589  
    33 
    44 
    5   N 
     5n  N 
    66##############  
    77 
  • 2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta3.txt

    r3553 r3589  
    11## 
    22           N                                   ##             ## 
    3           ##    ##      ##     ## 
     3     n     ##    ##      ##     ## 
    44##   ##                                ##  ##           ##      S 
    55              ##        ##        ##                           ## 
  • 2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta4.txt

    r3553 r3589  
    11 
    2                                                                                        ######################## 
    3                                                                                                                            L 
    4                                                ###########                 ##############                            ############ 
     2                                                                                       ############################ 
     3                                                                                     #                             #         L 
     4                                         #  #  ###########                 ##############                            ############ 
     5                                                            ###         ### 
     6                             ###########                          #### 
    57 
    6                              ########### 
    7  
    8                                                  ########################## 
     8                          ####                       ########################## 
    99 
    1010                ####### 
    1111 
    12                            ## 
    13                            ########### 
    14  
     12                        #### 
     13                           ######### 
     14                                                                                                                                                        
    1515                           ############## 
    1616 
    1717                  ##############                    N 
    18  
     18                                                                   n 
    1919################################       #######    #####          ###### 
Note: See TracChangeset for help on using the changeset viewer.