Changeset 8042


Ignore:
Timestamp:
2016-07-08 11:35:46 (3 years ago)
Author:
saalniit
Message:

Viimeistelyä

Location:
2016/27/SamuelN
Files:
9 added
13 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/PlatformJumper.cs

    r7971 r8042  
    1414    const int RUUDUN_KOKO = 40; 
    1515 
    16     double epsilon = 0.2; 
     16    double epsilon = 1; 
    1717 
    1818    PlatformCharacter pelaaja1; 
    1919 
    2020    Image pelaajanKuva = LoadImage("sieni"); 
    21     Image tahtiKuva = LoadImage("coin"); 
     21    Image rahaKuva = LoadImage("coin"); 
     22    Image timanttiKuva = LoadImage("timantti"); 
    2223    Image ruohokuva = LoadImage("ruoho"); 
    2324    Image vihukuva = LoadImage("invader"); 
     25    Image cubekuva = LoadImage("cube"); 
    2426 
    2527 
     
    2830    SoundEffect hitAani = LoadSoundEffect("ouch"); 
    2931    SoundEffect jupAani = LoadSoundEffect("jup"); 
     32    SoundEffect timanttiAani = LoadSoundEffect("timu"); 
     33    SoundEffect boxAani = LoadSoundEffect("box"); 
    3034 
    3135 
     
    4044        TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
    4145        kentta.SetTileMethod('#', LisaaTaso); 
    42         kentta.SetTileMethod('t', LisaaTahti); 
     46        kentta.SetTileMethod('t', LisaaKerattava,rahaKuva,"raha"); 
    4347        kentta.SetTileMethod('p', LisaaPelaaja); 
    4448        kentta.SetTileMethod('v', LisaaVihu); 
     49        kentta.SetTileMethod('a', LisaaKerattava,timanttiKuva,"timantti"); 
     50        kentta.SetTileMethod('b', LisaaBox); 
    4551        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    4652        Level.CreateBorders(); 
     
    5763    } 
    5864 
    59     void LisaaTahti(Vector paikka, double leveys, double korkeus) 
    60     { 
    61         PhysicsObject tahti = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    62         tahti.IgnoresCollisionResponse = true; 
    63         tahti.Position = paikka; 
    64         tahti.Image = tahtiKuva; 
    65         tahti.Tag = "tahti"; 
    66         Add(tahti); 
     65    void LisaaKerattava(Vector paikka, double leveys, double korkeus,Image kuva, string nimi) 
     66    { 
     67        PhysicsObject kerattava = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     68        kerattava.IgnoresCollisionResponse = true; 
     69        kerattava.Position = paikka; 
     70        kerattava.Image = kuva; 
     71        kerattava.Tag = nimi; 
     72        Add(kerattava); 
    6773    } 
    6874 
     
    7379        pelaaja1.Mass = 4.0; 
    7480        pelaaja1.Image = pelaajanKuva; 
    75         AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 
     81        AddCollisionHandler(pelaaja1, "raha", TormaaTahteen); 
     82        AddCollisionHandler(pelaaja1, "timantti", TormaaTahteen); 
    7683        AddCollisionHandler(pelaaja1, "invader", TormaaVihuun); 
     84        AddCollisionHandler(pelaaja1, "box", TormaaBoxiin); 
    7785        Add(pelaaja1); 
    7886    } 
     
    104112    void Hyppaa(PlatformCharacter hahmo, double nopeus) 
    105113    { 
    106         hahmo.Jump(nopeus); 
     114        hahmo.Jump(hyppyNopeus); 
    107115        jumpAani.Play(); 
    108     } 
    109  
    110     void TormaaTahteen(PhysicsObject hahmo, PhysicsObject tahti) 
    111     { 
    112         coinAani.Play(); 
    113         pisteLaskuri.Value += 1; 
    114         tahti.Destroy(); 
     116         
     117    } 
     118 
     119    void TormaaTahteen(PhysicsObject hahmo, PhysicsObject kerattava) 
     120    { 
     121        if (kerattava.Tag.Equals("raha")) 
     122        { 
     123            coinAani.Play(); 
     124            pisteLaskuri.Value += 1; 
     125        } 
     126        else if (kerattava.Tag.Equals("timantti")) 
     127        { 
     128            timanttiAani.Play(); 
     129            pisteLaskuri.Value += 100; 
     130        } 
     131        kerattava.Destroy(); 
    115132 
    116133    } 
     
    156173    { 
    157174        Timer vihuAjastin = new Timer(); 
    158         vihuAjastin.Interval = 3; 
     175        vihuAjastin.Interval = 5; 
    159176        vihuAjastin.Timeout += delegate 
    160177        { 
     
    194211        Camera.StayInLevel = true; 
    195212    } 
     213    void LisaaBox(Vector paikka, double leveys, double korkeus) 
     214    { 
     215        PhysicsObject box = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     216        box.Position = paikka; 
     217        box.Image = cubekuva; 
     218        box.Tag = "box"; 
     219        Add(box); 
     220    } 
     221    void TormaaBoxiin(PhysicsObject pelaaja1, PhysicsObject box) 
     222    { 
     223        if (Math.Abs(box.Bottom - pelaaja1.Top) < epsilon) 
     224        {  
     225            Timer.SingleShot(1, delegate 
     226             { 
     227            box.Destroy(); 
     228            boxAani.Play(); 
     229            Explosion rajahdys = new Explosion(50); 
     230            rajahdys.Position = box.Position; 
     231            rajahdys.Sound = null; 
     232            Add(rajahdys); 
     233             }); 
     234        } 
     235 
     236    } 
    196237} 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/PlatformJumper.csproj.Debug.cachefile

    r7971 r8042  
    99Content\jup.xnb 
    1010Content\coin.xnb 
     11Content\timantti.xnb 
     12Content\timu.xnb 
     13Content\cube.xnb 
     14Content\box.xnb 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml

    r7971 r8042  
    99      <Options>None</Options> 
    1010      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\kentta1.xnb</Output> 
    11       <Time>2016-07-07T15:00:46.2794626+03:00</Time> 
     11      <Time>2016-07-08T11:29:04.3446344+03:00</Time> 
    1212    </Item> 
    1313    <Item> 
     
    9292      <Time>2016-07-07T15:01:49.008662+03:00</Time> 
    9393    </Item> 
     94    <Item> 
     95      <Source>timantti.png</Source> 
     96      <Name>timantti</Name> 
     97      <Importer>TextureImporter</Importer> 
     98      <Processor>TextureProcessor</Processor> 
     99      <Options>None</Options> 
     100      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\timantti.xnb</Output> 
     101      <Time>2016-07-08T09:59:59.5288633+03:00</Time> 
     102    </Item> 
     103    <Item> 
     104      <Source>timu.wav</Source> 
     105      <Name>timu</Name> 
     106      <Importer>WavImporter</Importer> 
     107      <Processor>SoundEffectProcessor</Processor> 
     108      <Options>None</Options> 
     109      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\timu.xnb</Output> 
     110      <Time>2016-07-08T10:11:07.3169104+03:00</Time> 
     111    </Item> 
     112    <Item> 
     113      <Source>cube.png</Source> 
     114      <Name>cube</Name> 
     115      <Importer>TextureImporter</Importer> 
     116      <Processor>TextureProcessor</Processor> 
     117      <Options>None</Options> 
     118      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\cube.xnb</Output> 
     119      <Time>2016-07-08T10:49:28.3573025+03:00</Time> 
     120    </Item> 
     121    <Item> 
     122      <Source>box.wav</Source> 
     123      <Name>box</Name> 
     124      <Importer>WavImporter</Importer> 
     125      <Processor>SoundEffectProcessor</Processor> 
     126      <Options>None</Options> 
     127      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\box.xnb</Output> 
     128      <Time>2016-07-08T11:07:35.8331025+03:00</Time> 
     129    </Item> 
    94130    <BuildSuccessful>true</BuildSuccessful> 
    95131    <Settings> 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/obj/x86/Debug/PlatformJumper.csproj.FileListAbsolute.txt

    r7971 r8042  
    1717C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\jup.xnb 
    1818C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\coin.xnb 
     19C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\timantti.xnb 
     20C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\timu.xnb 
     21C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\cube.xnb 
     22C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\box.xnb 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt

    r7971 r8042  
    99Content\jup.xnb 
    1010Content\coin.xnb 
     11Content\timantti.xnb 
     12Content\timu.xnb 
     13Content\cube.xnb 
     14Content\box.xnb 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumperContent/PlatformJumperContent.contentproj

    r7971 r8042  
    115115    </Compile> 
    116116  </ItemGroup> 
     117  <ItemGroup> 
     118    <Compile Include="timantti.png"> 
     119      <Name>timantti</Name> 
     120      <Importer>TextureImporter</Importer> 
     121      <Processor>TextureProcessor</Processor> 
     122    </Compile> 
     123  </ItemGroup> 
     124  <ItemGroup> 
     125    <Compile Include="timu.wav"> 
     126      <Name>timu</Name> 
     127      <Importer>WavImporter</Importer> 
     128      <Processor>SoundEffectProcessor</Processor> 
     129    </Compile> 
     130  </ItemGroup> 
     131  <ItemGroup> 
     132    <Compile Include="cube.png"> 
     133      <Name>cube</Name> 
     134      <Importer>TextureImporter</Importer> 
     135      <Processor>TextureProcessor</Processor> 
     136    </Compile> 
     137  </ItemGroup> 
     138  <ItemGroup> 
     139    <Compile Include="box.wav"> 
     140      <Name>box</Name> 
     141      <Importer>WavImporter</Importer> 
     142      <Processor>SoundEffectProcessor</Processor> 
     143    </Compile> 
     144  </ItemGroup> 
    117145  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    118146  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumperContent/kentta1.txt

    r7971 r8042  
    11v.....................................v 
    2 t.....................................t 
    3 #################.....################# 
     2................a.....a................ 
     3#################..b..################# 
    44....................................... 
    55...................t................... 
     
    2121...###............###............###... 
    2222....................................... 
    23 .t...................................t. 
     23.t...........b...........b...........t. 
    2424###.................................### 
    2525....................................... 
     
    3333............####.......####............ 
    3434..................###.................. 
    35 ...............###...###............... 
    36 ............###....t....###............ 
     35...............###.v.###............... 
     36............###....a....###............ 
    3737.........###......###......###......... 
    3838......###.....................###...... 
     
    4040...............###...###............... 
    4141###.........###.........###.........### 
    42 ..t###...###......###......###...###t.. 
    43 .##...###......###...###......###...##. 
    44 ...................v................... 
     42v..###...###......###......###...###..v 
     43......###......###...###......###...... 
     44....................................... 
    4545....................................... 
    4646##################...################## 
    47 ....................................... 
    48 ....................................... 
    49 ....................................... 
    50 ....................................... 
    51 ....................................... 
    52 ....................................... 
    53 ....................................... 
    54 ....................................... 
    55 ....................................... 
    56 ....................................... 
    57 ....................................... 
    58 ....................................... 
     47.....................b................. 
     48..b.................................... 
     49...............b......b..........b..... 
     50.........b....................b.......b 
     51..........................b............ 
     52...b............b...................... 
     53.............................b......... 
     54..........b........b.....b............b 
     55....b.........b.................b...... 
     56...b...............b................... 
     57....b..................b...........b... 
    5958####################################### 
    6059....................................... 
     60 
     61 
     62 
     63 
     64 
     65 
     66 
     67 
     68 
Note: See TracChangeset for help on using the changeset viewer.