Changeset 7971


Ignore:
Timestamp:
2016-07-07 15:04:47 (3 years ago)
Author:
saalniit
Message:
 
Location:
2016/27/SamuelN
Files:
11 added
4 deleted
13 edited

Legend:

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

    r7937 r7971  
    1414    const int RUUDUN_KOKO = 40; 
    1515 
     16    double epsilon = 0.2; 
     17 
    1618    PlatformCharacter pelaaja1; 
    1719 
    18     Image pelaajanKuva = LoadImage("player"); 
    19     Image tahtiKuva = LoadImage("Diamond"); 
     20    Image pelaajanKuva = LoadImage("sieni"); 
     21    Image tahtiKuva = LoadImage("coin"); 
    2022    Image ruohokuva = LoadImage("ruoho"); 
    2123    Image vihukuva = LoadImage("invader"); 
     
    2426    SoundEffect coinAani = LoadSoundEffect("pickup"); 
    2527    SoundEffect jumpAani = LoadSoundEffect("Jump"); 
     28    SoundEffect hitAani = LoadSoundEffect("ouch"); 
     29    SoundEffect jupAani = LoadSoundEffect("jup"); 
    2630 
    2731 
     
    2933    public override void Begin() 
    3034    { 
    31         Gravity = new Vector(0, -1000); 
    32  
    33         LuoKentta(); 
    34         LisaaNappaimet(); 
    35         LuoPistelaskuri(); 
    36  
    37         Camera.Follow(pelaaja1); 
    38         Camera.ZoomFactor = 1.2; 
    39         Camera.StayInLevel = true; 
     35        AloitaAlusta(); 
    4036    } 
    4137 
     
    7874        pelaaja1.Image = pelaajanKuva; 
    7975        AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 
     76        AddCollisionHandler(pelaaja1, "invader", TormaaVihuun); 
    8077        Add(pelaaja1); 
    8178    } 
     
    8986        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
    9087        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     88        Keyboard.Listen(Key.R, ButtonState.Pressed, AloitaAlusta, "Restart"); 
    9189 
    9290        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
     
    134132    void LisaaVihu(Vector paikka, double korkeus, double leveys) 
    135133    { 
     134        LuoVihuAjastin(paikka, korkeus, leveys); 
     135        LuoVihu(paikka, korkeus, leveys); 
     136    } 
     137 
     138    void LuoVihu(Vector paikka, double korkeus, double leveys) 
     139    { 
    136140        PlatformCharacter vihu = new PlatformCharacter(korkeus, leveys); 
     141        vihu.Tag = "invader"; 
    137142        vihu.Position = paikka; 
    138143        vihu.Image = vihukuva; 
     
    146151        tasoAivot.JumpSpeed = 700; 
    147152        tasoAivot.TriesToJump = true; 
     153    } 
    148154 
     155    void LuoVihuAjastin(Vector paikka, double korkeus, double leveys) 
     156    { 
     157        Timer vihuAjastin = new Timer(); 
     158        vihuAjastin.Interval = 3; 
     159        vihuAjastin.Timeout += delegate 
     160        { 
     161            LuoVihu(paikka, korkeus, leveys); 
     162        }; 
     163        vihuAjastin.Start(); 
     164    } 
     165 
     166    void TormaaVihuun(PhysicsObject pelaaja1, PhysicsObject vihu) 
     167    { 
     168        if (Math.Abs(pelaaja1.Bottom - vihu.Top) < epsilon) 
     169        { 
     170            (pelaaja1 as PlatformCharacter).ForceJump(hyppyNopeus); 
     171            pisteLaskuri.Value += 1; 
     172            vihu.Destroy(); 
     173            jupAani.Play(); 
     174        } 
     175        else 
     176        {  
     177 
     178            hitAani.Play(); 
     179            AloitaAlusta(); 
     180        } 
     181    } 
     182    void AloitaAlusta() 
     183    { 
     184        ClearAll(); 
     185        Gravity = new Vector(0, -1000); 
     186 
     187        LuoKentta(); 
     188        LisaaNappaimet(); 
     189        LuoPistelaskuri(); 
     190 
     191        IsFullScreen = true; 
     192        Camera.Follow(pelaaja1); 
     193        Camera.ZoomFactor = 1.2; 
     194        Camera.StayInLevel = true; 
    149195    } 
    150196} 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/PlatformJumper.csproj.Debug.cachefile

    r7937 r7971  
    11Content\kentta1.xnb 
    2 Content\player.xnb 
    3 Content\Diamond.xnb 
    42Content\ruoho.xnb 
    53Content\wallpaper.xnb 
     
    75Content\pickup.xnb 
    86Content\Jump.xnb 
     7Content\sieni.xnb 
     8Content\ouch.xnb 
     9Content\jup.xnb 
     10Content\coin.xnb 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml

    r7937 r7971  
    99      <Options>None</Options> 
    1010      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\kentta1.xnb</Output> 
    11       <Time>2016-07-07T11:24:05.9606409+03:00</Time> 
    12     </Item> 
    13     <Item> 
    14       <Source>player.png</Source> 
    15       <Name>player</Name> 
    16       <Importer>TextureImporter</Importer> 
    17       <Processor>TextureProcessor</Processor> 
    18       <Options>None</Options> 
    19       <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\player.xnb</Output> 
    20       <Time>2016-07-05T14:58:28.513753+03:00</Time> 
    21     </Item> 
    22     <Item> 
    23       <Source>Diamond.png</Source> 
    24       <Name>Diamond</Name> 
    25       <Importer>TextureImporter</Importer> 
    26       <Processor>TextureProcessor</Processor> 
    27       <Options>None</Options> 
    28       <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\Diamond.xnb</Output> 
    29       <Time>2016-07-06T10:30:26.2281043+03:00</Time> 
     11      <Time>2016-07-07T15:00:46.2794626+03:00</Time> 
    3012    </Item> 
    3113    <Item> 
     
    7355      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\Jump.xnb</Output> 
    7456      <Time>2016-07-07T11:09:36.8611391+03:00</Time> 
     57    </Item> 
     58    <Item> 
     59      <Source>sieni.png</Source> 
     60      <Name>sieni</Name> 
     61      <Importer>TextureImporter</Importer> 
     62      <Processor>TextureProcessor</Processor> 
     63      <Options>None</Options> 
     64      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\sieni.xnb</Output> 
     65      <Time>2016-07-07T12:36:38.1804281+03:00</Time> 
     66    </Item> 
     67    <Item> 
     68      <Source>ouch.wav</Source> 
     69      <Name>ouch</Name> 
     70      <Importer>WavImporter</Importer> 
     71      <Processor>SoundEffectProcessor</Processor> 
     72      <Options>None</Options> 
     73      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\ouch.xnb</Output> 
     74      <Time>2016-07-07T13:26:03.7611224+03:00</Time> 
     75    </Item> 
     76    <Item> 
     77      <Source>jup.wav</Source> 
     78      <Name>jup</Name> 
     79      <Importer>WavImporter</Importer> 
     80      <Processor>SoundEffectProcessor</Processor> 
     81      <Options>None</Options> 
     82      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\jup.xnb</Output> 
     83      <Time>2016-07-07T14:32:12.0898009+03:00</Time> 
     84    </Item> 
     85    <Item> 
     86      <Source>coin.png</Source> 
     87      <Name>coin</Name> 
     88      <Importer>TextureImporter</Importer> 
     89      <Processor>TextureProcessor</Processor> 
     90      <Options>None</Options> 
     91      <Output>C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\coin.xnb</Output> 
     92      <Time>2016-07-07T15:01:49.008662+03:00</Time> 
    7593    </Item> 
    7694    <BuildSuccessful>true</BuildSuccessful> 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/obj/x86/Debug/PlatformJumper.csproj.FileListAbsolute.txt

    r7937 r7971  
    88C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\obj\x86\Debug\PlatformJumper.exe 
    99C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\obj\x86\Debug\PlatformJumper.pdb 
    10 C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\player.xnb 
    11 C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\Diamond.xnb 
    1210C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\ruoho.xnb 
    1311C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\wallpaper.xnb 
     
    1513C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\pickup.xnb 
    1614C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\Jump.xnb 
     15C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\sieni.xnb 
     16C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\ouch.xnb 
     17C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\jup.xnb 
     18C:\MyTemp\SamuelN\PlatformJumper\PlatformJumper\PlatformJumper\bin\x86\Debug\Content\coin.xnb 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumper/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt

    r7937 r7971  
    11Content\kentta1.xnb 
    2 Content\player.xnb 
    3 Content\Diamond.xnb 
    42Content\ruoho.xnb 
    53Content\wallpaper.xnb 
     
    75Content\pickup.xnb 
    86Content\Jump.xnb 
     7Content\sieni.xnb 
     8Content\ouch.xnb 
     9Content\jup.xnb 
     10Content\coin.xnb 
  • 2016/27/SamuelN/PlatformJumper/PlatformJumper/PlatformJumperContent/PlatformJumperContent.contentproj

    r7937 r7971  
    5353  </ItemGroup> 
    5454  <ItemGroup> 
    55     <Compile Include="player.png"> 
    56       <Name>player</Name> 
    57       <Importer>TextureImporter</Importer> 
    58       <Processor>TextureProcessor</Processor> 
    59     </Compile> 
    60   </ItemGroup> 
    61   <ItemGroup> 
    62     <Compile Include="Diamond.png"> 
    63       <Name>Diamond</Name> 
    64       <Importer>TextureImporter</Importer> 
    65       <Processor>TextureProcessor</Processor> 
    66     </Compile> 
    67   </ItemGroup> 
    68   <ItemGroup> 
    6955    <Compile Include="ruoho.jpg"> 
    7056      <Name>ruoho</Name> 
     
    10187    </Compile> 
    10288  </ItemGroup> 
     89  <ItemGroup> 
     90    <Compile Include="sieni.png"> 
     91      <Name>sieni</Name> 
     92      <Importer>TextureImporter</Importer> 
     93      <Processor>TextureProcessor</Processor> 
     94    </Compile> 
     95  </ItemGroup> 
     96  <ItemGroup> 
     97    <Compile Include="ouch.wav"> 
     98      <Name>ouch</Name> 
     99      <Importer>WavImporter</Importer> 
     100      <Processor>SoundEffectProcessor</Processor> 
     101    </Compile> 
     102  </ItemGroup> 
     103  <ItemGroup> 
     104    <Compile Include="jup.wav"> 
     105      <Name>jup</Name> 
     106      <Importer>WavImporter</Importer> 
     107      <Processor>SoundEffectProcessor</Processor> 
     108    </Compile> 
     109  </ItemGroup> 
     110  <ItemGroup> 
     111    <Compile Include="coin.png"> 
     112      <Name>coin</Name> 
     113      <Importer>TextureImporter</Importer> 
     114      <Processor>TextureProcessor</Processor> 
     115    </Compile> 
     116  </ItemGroup> 
    103117  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    104118  <!--  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

    r7937 r7971  
    1 vvvvv.............................vvvvv 
     1v.....................................v 
     2t.....................................t 
    23#################.....################# 
    34....................................... 
     
    2526...................p................... 
    2627..###################################.. 
    27 ...................t................... 
    28 ..............t.#######.t.............. 
     28....................................... 
     29..............t.........t.............. 
    2930####.........###.......###.........#### 
    3031....####.......................####.... 
     
    4344...................v................... 
    4445....................................... 
     46##################...################## 
     47....................................... 
     48....................................... 
     49....................................... 
     50....................................... 
     51....................................... 
     52....................................... 
     53....................................... 
     54....................................... 
     55....................................... 
     56....................................... 
     57....................................... 
     58....................................... 
    4559####################################### 
     60....................................... 
Note: See TracChangeset for help on using the changeset viewer.