Ignore:
Timestamp:
2013-06-11 14:58:46 (10 years ago)
Author:
taeekotr
Message:

Talletus.

Location:
2013/24/EemeliK/KillSlender/KillSlender
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2013/24/EemeliK/KillSlender/KillSlender/KillSlender/KillSlender.cs

    r4060 r4074  
    1111    PhysicsObject pelaaja; 
    1212    Image tyyppi = LoadImage("tyyppi"); 
     13    int kenttaNro = 1; 
     14 
     15    Color[] kenttienTaustavarit = { Color.LightBlue, Color.LightBlue, Color.Black }; 
     16 
    1317    public override void Begin() 
     18    { 
     19        // TODO:  
    1420 
    1521 
     22        seuraavakentta(); 
     23 
     24 
     25    } 
     26    void seuraavakentta() 
    1627    { 
    17         // TODO:  
    18         PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    19         Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    20         pelaaja = new PhysicsObject(50, 100); 
    21         pelaaja.Shape = Shape.Rectangle; 
    22         Add(pelaaja); 
    23         pelaaja.Image = tyyppi; 
    24         Gravity = new Vector(0.0, -800.0); 
    25         TileMap ruudut = TileMap.FromLevelAsset("kentta1"); 
    26         ruudut.SetTileMethod('1', LuoPelaaja); 
    27         ruudut.SetTileMethod('=', LuoPalikka); 
    28         ruudut.SetTileMethod('*', LuoTahti); 
    29         ruudut.Execute(20, 20); 
    30         Keyboard.Listen(Key.Left, ButtonState.Down, 
    31     LiikutaPelaajaa, null, new Vector(-1000, 0)); 
    32         Keyboard.Listen(Key.Right, ButtonState.Down, 
    33           LiikutaPelaajaa, null, new Vector(1000, 0)); 
    34         Keyboard.Listen(Key.Up, ButtonState.Down, 
    35           LiikutaPelaajaa, null, new Vector(0, 1000)); 
    36         Keyboard.Listen(Key.Down, ButtonState.Down, 
    37           LiikutaPelaajaa, null, new Vector(0, -1000)); 
    38         Keyboard.Listen(Key.P, ButtonState.Pressed, Pause, "Pysäyttää pelin"); 
    39         IsPaused = true; PhysicsObject slender = new PhysicsObject(50, 150); 
    40         slender.Shape = Shape.Rectangle; 
    41         Add(slender); 
    42         FollowerBrain seuraajanAivot = new FollowerBrain(pelaaja); 
    43         slender.Brain = seuraajanAivot; 
    44         seuraajanAivot.Speed = 175; 
    45         Image olionKuva = LoadImage("slender"); 
    46         slender.Image = olionKuva; 
    47         Camera.Follow(pelaaja); 
     28        ClearAll(); 
     29 
     30        if (kenttaNro == 1) LuoKentta("kentta1"); 
     31        else if (kenttaNro == 2) LuoKentta("kentta2"); 
     32        else if (kenttaNro == 3) LuoKentta("kentta3"); 
     33        else if (kenttaNro > 3) Exit(); 
     34 
    4835    } 
     36 
     37 
    4938    void LuoPalikka(Vector paikka, double leveys, double korkeus) 
    5039    { 
     
    5645 
    5746    } 
    58     void LuoTahti(Vector paikka, double leveys, double korkeus) 
     47    void LuoTNT(Vector paikka, double leveys, double korkeus) 
    5948    { 
    60         PhysicsObject tahti = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    61         tahti.Position = paikka; 
    62         tahti.Shape = Shape.Rectangle; 
    63         tahti.Color = Color.Gray; 
    64         Add(tahti); 
     49        PhysicsObject tnt = PhysicsObject.CreateStaticObject(50, 150); 
     50        tnt.Position = paikka; 
     51        tnt.Shape = Shape.Rectangle; 
     52        tnt.Color = Color.Gray; 
     53        Add(tnt); 
     54        Image olionKuva = LoadImage("TNT"); 
     55        tnt.Image = olionKuva; 
     56        AddCollisionHandler(tnt, CollisionHandler.ExplodeBoth(200, true)); 
     57        AddCollisionHandler(tnt, "slender", VaihdaKentta); 
    6558    } 
    6659    void LiikutaPelaajaa(Vector vektori) 
     
    6861        pelaaja.Push(vektori); 
    6962    } 
    70     void LuoPelaaja(Vector paikka, double leveys, double korkeus)  
     63    void LuoPelaaja(Vector paikka, double leveys, double korkeus, Image kuva) 
    7164    { 
    7265        pelaaja.Position = paikka; 
     66        pelaaja.Image = kuva; 
    7367    } 
     68    void VaihdaKentta(PhysicsObject tormaaja, PhysicsObject kohde) 
     69    { 
     70        kenttaNro++; 
     71        seuraavakentta(); 
     72        MessageDisplay.Add("Pääsit läpi"); 
    7473 
    75              
     74    } 
     75    void LuoKentta(String Kenttatiedosto) 
     76    { 
     77        ClearAll(); 
     78        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
     79        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     80        pelaaja = new PhysicsObject(50, 100); 
     81        pelaaja.Shape = Shape.Rectangle; 
     82        Add(pelaaja); 
     83        pelaaja.Destroyed += PelaajaKuoli; 
     84        pelaaja.Image = tyyppi; 
     85        Gravity = new Vector(0.0, -800.0); 
     86        TileMap ruudut = TileMap.FromLevelAsset(Kenttatiedosto); 
     87        ruudut.SetTileMethod('S', LuoSlender); 
     88        ruudut.SetTileMethod('1', LuoPelaaja, LoadImage("tyyppi")); 
     89        ruudut.SetTileMethod('2', LuoPelaaja, LoadImage("tyyppi2")); 
     90        ruudut.SetTileMethod('=', LuoPalikka); 
     91        ruudut.SetTileMethod('*', LuoTNT); 
     92        ruudut.SetTileMethod('E', LuoEyes); 
     93        ruudut.Execute(20, 20); 
     94        Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-1000, 0)); 
     95        Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(1000, 0)); 
     96        Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, 1000)); 
     97        Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -1000)); 
     98        Keyboard.Listen(Key.P, ButtonState.Pressed, Pause, "Pysäyttää pelin"); 
     99        IsPaused = true; 
     100        Camera.Follow(pelaaja); 
     101        pelaaja.LifetimeLeft = TimeSpan.FromSeconds(60.0); 
     102        Level.BackgroundColor = kenttienTaustavarit[kenttaNro - 1]; 
     103    } 
     104    void LuoSlender(Vector paikka, double leveys, double korkeus) 
     105    { 
     106        PhysicsObject slender = new PhysicsObject(50, 150); 
     107        slender.Shape = Shape.Rectangle; 
     108        slender.Tag = "slender"; 
     109        Add(slender); 
     110        FollowerBrain seuraajanAivot = new FollowerBrain(pelaaja); 
     111        slender.Brain = seuraajanAivot; 
     112        seuraajanAivot.Speed = 258; 
     113        Image olionKuva = LoadImage("slender"); 
     114        slender.Image = olionKuva; 
     115        AddCollisionHandler(pelaaja, slender, CollisionHandler.ExplodeObject(100, true)); 
     116        slender.Position = paikka; 
     117 
     118    } 
     119    void PelaajaKuoli() 
     120    { 
     121        //Sama kenttä ladataan alusta jos kenttänumeroa ei kasvateta: 
     122        seuraavakentta(); 
     123    } 
     124    void vaihdakentta(PhysicsObject tormaaja, PhysicsObject kohde) 
     125    { 
     126        kenttaNro++; 
     127        seuraavakentta(); 
     128        MessageDisplay.Add("Pääsit läpi"); 
     129    } 
     130    void LuoEyes(Vector paikka, double leveys, double korkeus) 
     131    { 
     132        PhysicsObject eyes = new PhysicsObject(150, 250); 
     133        eyes.Shape = Shape.Rectangle; 
     134        eyes.Tag = "eyes"; 
     135        Add(eyes); 
     136        FollowerBrain seuraajanAivot = new FollowerBrain(pelaaja); 
     137        eyes.Brain = seuraajanAivot; 
     138        seuraajanAivot.Speed = 345; 
     139        Image olionKuva = LoadImage("eyes"); 
     140        eyes.Image = olionKuva; 
     141        AddCollisionHandler(pelaaja, eyes, CollisionHandler.ExplodeObject(100, true)); 
     142        eyes.Position = paikka; 
     143 
     144    } 
     145     
    76146} 
    77      
    78147 
    79148 
     149 
     150 
     151 
     152 
     153 
     154 
     155 
     156 
  • 2013/24/EemeliK/KillSlender/KillSlender/KillSlenderContent/KillSlenderContent.contentproj

    r4060 r4074  
    6767    </Compile> 
    6868  </ItemGroup> 
     69  <ItemGroup> 
     70    <Compile Include="TNT.png"> 
     71      <Name>TNT</Name> 
     72      <Importer>TextureImporter</Importer> 
     73      <Processor>TextureProcessor</Processor> 
     74    </Compile> 
     75  </ItemGroup> 
     76  <ItemGroup> 
     77    <Compile Include="kentta2.txt"> 
     78      <Name>kentta2</Name> 
     79      <Importer>TextFileImporter</Importer> 
     80      <Processor>TextFileContentProcessor</Processor> 
     81      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
     82    </Compile> 
     83  </ItemGroup> 
     84  <ItemGroup> 
     85    <Compile Include="kentta3.txt"> 
     86      <Name>kentta3</Name> 
     87      <Importer>TextFileImporter</Importer> 
     88      <Processor>TextFileContentProcessor</Processor> 
     89      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
     90    </Compile> 
     91  </ItemGroup> 
     92  <ItemGroup> 
     93    <Compile Include="tyyppi2.png"> 
     94      <Name>tyyppi2</Name> 
     95      <Importer>TextureImporter</Importer> 
     96      <Processor>TextureProcessor</Processor> 
     97    </Compile> 
     98  </ItemGroup> 
     99  <ItemGroup> 
     100    <Compile Include="eyes.png"> 
     101      <Name>eyes</Name> 
     102      <Importer>TextureImporter</Importer> 
     103      <Processor>TextureProcessor</Processor> 
     104    </Compile> 
     105  </ItemGroup> 
     106  <ItemGroup> 
     107    <Compile Include="rahapussi.png"> 
     108      <Name>rahapussi</Name> 
     109      <Importer>TextureImporter</Importer> 
     110      <Processor>TextureProcessor</Processor> 
     111    </Compile> 
     112  </ItemGroup> 
    69113  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    70114  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2013/24/EemeliK/KillSlender/KillSlender/KillSlenderContent/kentta1.txt

    r4060 r4074  
    2020=                                                                                   =                        
    2121=                                                                                   = 
    22 =                                                                                   = 
     22=                                                                     S             = 
    2323=                                                                                   = 
    2424=                                                                                   = 
     
    5353=                                                                                   = 
    5454=                                                                                   = 
    55 =                                                                                   = 
     55=                               *                                                   = 
    5656=                                                                                   = 
    5757=                                                                                   = 
Note: See TracChangeset for help on using the changeset viewer.