Ignore:
Timestamp:
2015-06-11 16:39:37 (8 years ago)
Author:
jotapoti
Message:

Lisätty viholliselle tekoäly ja pelaajalle elämälaskuri

Location:
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki.cs

    r6021 r6033  
    1313    const int RUUDUN_KOKO = 40; 
    1414 
    15     PlatformCharacter pelaaja1; 
     15    Pelaaja pelaaja1; 
    1616 
    1717    Image pelaajanKuva = LoadImage("norsu"); 
    1818    Image tahtiKuva = LoadImage("tahti"); 
     19    Image viholliskuva = LoadImage("sininenpahis"); 
    1920 
    2021    SoundEffect maaliAani = LoadSoundEffect("maali"); 
     
    2324    int kenttaNro = 1; 
    2425 
     26    // TODO lisää pelaajan elämälaskurille näyttö 
     27 
    2528    public override void Begin() 
    2629    { 
     30        SmoothTextures = false; 
    2731        //IsFullScreen = true; 
    2832        VaihdaKenttaa(); 
     
    5559        kentta.SetTileMethod('*', LisaaTahti); 
    5660        kentta.SetTileMethod('N', LisaaPelaaja); 
     61        kentta.SetTileMethod('v', LisaaVihollinen); 
    5762        kentta.SetTileMethod('m', LisaaMaali); 
    5863        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
     
    97102    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
    98103    { 
    99         pelaaja1 = new PlatformCharacter(leveys, korkeus); 
     104        pelaaja1 = new Pelaaja(leveys, korkeus); 
    100105        pelaaja1.Position = paikka; 
    101106        pelaaja1.Mass = 4.0; 
     
    103108        AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 
    104109        AddCollisionHandler(pelaaja1, "maali", TormaaMaaliin); 
     110        AddCollisionHandler(pelaaja1, "pahis", TormaaViholliseen); 
    105111        Add(pelaaja1); 
     112    } 
     113     
     114    void LisaaVihollinen(Vector paikka, double leveys, double korkeus) 
     115    { 
     116        PlatformCharacter vihollinen = new PlatformCharacter(leveys, korkeus); 
     117        vihollinen.Position = paikka; 
     118        vihollinen.Image = viholliskuva; 
     119        vihollinen.Tag = "pahis"; 
     120        Add(vihollinen); 
     121 
     122        PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 
     123        tasoAivot.Speed = 100; 
     124        tasoAivot.JumpSpeed = 700; 
     125        tasoAivot.TriesToJump = true; 
     126        tasoAivot.FallsOffPlatforms = true; 
     127        vihollinen.Brain = tasoAivot; 
    106128    } 
    107129 
     
    110132        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    111133        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     134        Keyboard.Listen(Key.R, ButtonState.Pressed, VaihdaKenttaa, "Aloita kenttä alusta"); 
    112135 
    113136        Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
     
    140163        tahti.Destroy(); 
    141164    } 
     165 
     166    void TormaaViholliseen(PhysicsObject hahmo, PhysicsObject vihu) 
     167    { 
     168        MessageDisplay.Add("Osuit viholliseen!"); 
     169        ((Pelaaja)hahmo).Elamalaskuri.Value -= 1; 
     170        if (((Pelaaja)hahmo).Elamalaskuri.Value == ((Pelaaja)hahmo).Elamalaskuri.MinValue) 
     171        { 
     172            Timer.SingleShot(5.0, VaihdaKenttaa); 
     173        } 
     174    } 
    142175} 
  • 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki.csproj

    r6021 r6033  
    112112  <ItemGroup> 
    113113    <Compile Include="Ohjelma.cs" /> 
     114    <Compile Include="Pelaaja.cs" /> 
    114115    <Compile Include="Tasohyppelyesimerkki.cs" /> 
    115116    <Compile Include="Properties\AssemblyInfo.cs" /> 
  • 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki.csproj.Debug.cachefile

    r6021 r6033  
    44Content\kentta1.xnb 
    55Content\kentta2.xnb 
     6Content\sininenpahis.xnb 
  • 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml

    r6021 r6033  
    3636      <Options>None</Options> 
    3737      <Output>C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\kentta1.xnb</Output> 
    38       <Time>2015-06-11T08:40:57.6186043+03:00</Time> 
     38      <Time>2015-06-11T14:14:59.5789158+03:00</Time> 
    3939    </Item> 
    4040    <Item> 
     
    4646      <Output>C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\kentta2.xnb</Output> 
    4747      <Time>2015-06-11T08:53:32.5080801+03:00</Time> 
     48    </Item> 
     49    <Item> 
     50      <Source>sininenpahis.png</Source> 
     51      <Name>sininenpahis</Name> 
     52      <Importer>TextureImporter</Importer> 
     53      <Processor>TextureProcessor</Processor> 
     54      <Options>None</Options> 
     55      <Output>C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\sininenpahis.xnb</Output> 
     56      <Time>2015-06-11T13:49:43.5248407+03:00</Time> 
    4857    </Item> 
    4958    <BuildSuccessful>true</BuildSuccessful> 
  • 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/obj/x86/Debug/Tasohyppelyesimerkki.csproj.FileListAbsolute.txt

    r6021 r6033  
    1212C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\obj\x86\Debug\Tasohyppelyesimerkki.csprojResolveAssemblyReference.cache 
    1313C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\kentta2.xnb 
     14C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\sininenpahis.xnb 
  • 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt

    r6021 r6033  
    44Content\kentta1.xnb 
    55Content\kentta2.xnb 
     6Content\sininenpahis.xnb 
  • 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/TasohyppelyesimerkkiContent/TasohyppelyesimerkkiContent.contentproj

    r6021 r6033  
    7474    </Compile> 
    7575  </ItemGroup> 
     76  <ItemGroup> 
     77    <Compile Include="sininenpahis.png"> 
     78      <Name>sininenpahis</Name> 
     79      <Importer>TextureImporter</Importer> 
     80      <Processor>TextureProcessor</Processor> 
     81    </Compile> 
     82  </ItemGroup> 
    7683  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    7784  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/TasohyppelyesimerkkiContent/kentta1.txt

    r6021 r6033  
    1414.##..##..##..##..##... 
    1515...................... 
    16 ........N..........m.. 
     16........N..#..v....m.. 
    1717###################### 
Note: See TracChangeset for help on using the changeset viewer.