Changeset 3553 for 2012/27


Ignore:
Timestamp:
2012-07-04 15:00:47 (11 years ago)
Author:
leotoiol
Message:

Talletus.

Location:
2012/27/LeoL/Marsun matkat/Marsun matkat
Files:
8 added
4 edited

Legend:

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

    r3493 r3553  
    1717    Image pelaajanKuva = LoadImage("norsu"); 
    1818    Image tahtiKuva = LoadImage("tahti"); 
     19    Image vihunKuva = LoadImage("mulkkis"); 
     20    Image psyykkisKuva = LoadImage("psyykkis"); 
     21    Image hyppisKuva = LoadImage("hyppis"); 
     22 
     23    IntMeter vihunHp = new IntMeter(3); 
    1924 
    2025    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    2126 
     27    int kentanNro = 1; 
     28 
    2229    public override void Begin() 
    2330    { 
    24         Gravity = new Vector(0, -1000); 
     31         
    2532 
    2633        LuoKentta(); 
    27         LisaaNappaimet(); 
    2834 
    29         Camera.Follow(pelaaja1); 
    30         Camera.ZoomFactor = 1.2; 
    31         Camera.StayInLevel = true; 
    3235    } 
    3336 
    3437    void LuoKentta() 
    3538    { 
    36         TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
     39        string kenttaNimi = "kentta1"; 
     40        if (kentanNro == 2) 
     41        { 
     42            kenttaNimi = "kentta2"; 
     43        } 
     44        if (kentanNro == 3) 
     45        { 
     46            kenttaNimi = "kentta3"; 
     47        } 
     48        ClearAll(); 
     49        Gravity = new Vector(0, -1000); 
     50        TileMap kentta = TileMap.FromLevelAsset(kenttaNimi); 
    3751        kentta.SetTileMethod('#', LisaaTaso); 
    3852        kentta.SetTileMethod('*', LisaaTahti); 
    3953        kentta.SetTileMethod('N', LisaaPelaaja); 
     54        kentta.SetTileMethod('V', LisaaVihu1); 
     55        kentta.SetTileMethod('M', LisaaVihu2); 
     56        kentta.SetTileMethod('S', LisaaVihu3); 
    4057        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    4158        Level.CreateBorders(); 
    4259        Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
     60 
     61        LisaaNappaimet(); 
     62        vihunHp.Value = 3; 
     63        Camera.Follow(pelaaja1); 
     64        Camera.ZoomFactor = 1.2; 
     65        Camera.StayInLevel = true; 
     66 
     67    } 
     68 
     69    void LisaaVihu1(Vector paikka, double leveys, double korkeus) 
     70    { 
     71        PhysicsObject vihu = new PhysicsObject(40, 20); 
     72        vihu.Shape = Shape.Rectangle; 
     73        vihu.Mass = 10.0; 
     74        vihu.Tag = "vihu"; 
     75        vihu.Image = vihunKuva; 
     76        Add(vihu); 
     77    } 
     78 
     79    void LisaaVihu2(Vector paikka, double leveys, double korkeus) 
     80    { 
     81        PhysicsObject vihu2 = new PhysicsObject(40, 20); 
     82        vihu2.Shape = Shape.Rectangle; 
     83        vihu2.Mass = 10.5; 
     84        vihu2.Tag = "vihu"; 
     85        vihu2.Image = psyykkisKuva; 
     86        Add(vihu2); 
     87    } 
     88 
     89    void LisaaVihu3(Vector paikka, double leveys, double korkeus) 
     90    { 
     91        PhysicsObject vihu2 = new PhysicsObject(40, 20); 
     92        vihu2.Shape = Shape.Rectangle; 
     93        vihu2.Mass = 10.5; 
     94        vihu2.Tag = "vihu"; 
     95        vihu2.Image = hyppisKuva; 
     96        Add(vihu2); 
    4397    } 
    4498 
     
    67121        pelaaja1.Mass = 4.0; 
    68122        pelaaja1.Image = pelaajanKuva; 
    69         AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 
     123        AddCollisionHandler(pelaaja1, Tormaa); 
    70124        Add(pelaaja1); 
    71125    } 
     
    100154    } 
    101155 
    102     void TormaaTahteen(PhysicsObject hahmo, PhysicsObject tahti) 
     156    void Tormaa(PhysicsObject hahmo, PhysicsObject kohde) 
    103157    { 
    104         maaliAani.Play(); 
    105         MessageDisplay.Add("Keräsit tähden!"); 
    106         tahti.Destroy(); 
     158        if (kohde.Tag.ToString() == "vihu") 
     159        { 
     160            if (hahmo.Bottom >= kohde.Top) 
     161            { 
     162                vihunHp.Value--; 
     163                kohde.Position = RandomGen.NextVector(Level.Left, Level.Bottom, Level.Right, Level.Top); 
     164            } 
     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!"); 
     178            kohde.Destroy(); 
     179        } 
    107180    } 
     181 
    108182} 
  • 2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/Marsun matkatContent.contentproj

    r3493 r3553  
    6666    </Compile> 
    6767  </ItemGroup> 
     68  <ItemGroup> 
     69    <Compile Include="mulkkis.png"> 
     70      <Name>mulkkis</Name> 
     71      <Importer>TextureImporter</Importer> 
     72      <Processor>TextureProcessor</Processor> 
     73    </Compile> 
     74  </ItemGroup> 
     75  <ItemGroup> 
     76    <Compile Include="kentta2.txt"> 
     77      <Name>kentta2</Name> 
     78      <Importer>TextFileImporter</Importer> 
     79      <Processor>TextFileContentProcessor</Processor> 
     80    </Compile> 
     81  </ItemGroup> 
     82  <ItemGroup> 
     83    <Compile Include="psyykkis.png"> 
     84      <Name>psyykkis</Name> 
     85      <Importer>TextureImporter</Importer> 
     86      <Processor>TextureProcessor</Processor> 
     87    </Compile> 
     88  </ItemGroup> 
     89  <ItemGroup> 
     90    <Compile Include="hyppis.png"> 
     91      <Name>hyppis</Name> 
     92      <Importer>TextureImporter</Importer> 
     93      <Processor>TextureProcessor</Processor> 
     94    </Compile> 
     95  </ItemGroup> 
     96  <ItemGroup> 
     97    <Compile Include="kentta3.txt"> 
     98      <Name>kentta3</Name> 
     99      <Importer>TextFileImporter</Importer> 
     100      <Processor>TextFileContentProcessor</Processor> 
     101    </Compile> 
     102  </ItemGroup> 
     103  <ItemGroup> 
     104    <Compile Include="kentta4.txt"> 
     105      <Name>kentta4</Name> 
     106      <Importer>TextFileImporter</Importer> 
     107      <Processor>TextFileContentProcessor</Processor> 
     108    </Compile> 
     109  </ItemGroup> 
    68110  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    69111  <!--  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

    r3493 r3553  
    1          * 
    2          ## 
     1        
     2          
    33 
    4        *    * 
    5        ##  ## 
     4        
     5        
    66 
    7      *        * 
    8      ##  ##  ## 
    9  
    10    *    *  *    *      
    11    ##  ##  ##  ## 
    12  
    13  *    *       *   * 
    14  ##  ##  ##  ##  ############ 
    15            ###### 
    16         N 
    17 ###################### 
     7      
     8    
     9  
     10   
     11                                   
     12 *    *       *   * V  * 
     13 ##  ##  ##  ## ############ ########### 
     14                #       #       ************                 
     15                        ####################### 
     16                   # 
     17                ########### 
     18                            #  
     19                                               N 
     20##############   ######################## 
     21############               ************ 
     22######################################### 
Note: See TracChangeset for help on using the changeset viewer.