Changeset 4237 for 2013/26


Ignore:
Timestamp:
2013-06-26 14:53:06 (10 years ago)
Author:
wiaukota
Message:

Talletus.

Location:
2013/26/WilleK/Ensimmäinen Peli/Ensimmäinen Peli
Files:
16 added
5 edited

Legend:

Unmodified
Added
Removed
  • 2013/26/WilleK/Ensimmäinen Peli/Ensimmäinen Peli/Ensimmäinen Peli/Ensimmäinen_Peli.cs

    r4214 r4237  
    99public class Ensimmäinen_Peli : PhysicsGame 
    1010{ 
    11     IntMeter nopeus = new IntMeter(200); 
    12     IntMeter hyppyNopeus = new IntMeter(700); 
     11    IntMeter nopeus; 
     12    IntMeter hyppyNopeus; 
    1313    const int RUUDUN_KOKO = 40; 
    1414 
    15     Vector alkupiste;  
     15    Vector alkupiste; 
    1616 
    1717    PlatformCharacter pelaaja1; 
     
    2222    Image LisäVoima = LoadImage("Voima"); 
    2323    Image Ruoho = LoadImage("GrassTexture"); 
     24    Image Palikka2 = LoadImage("alkuun"); 
     25    Image tyyppiLyoKuva = LoadImage("TyyppiLyo"); 
     26    Image nyrkkikuva = LoadImage("Nyrkki"); 
    2427 
    2528    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    26  
    2729    DoubleMeter elamaLaskuri; 
    2830 
     
    3436    public void AloitaPeli() 
    3537    { 
     38        nopeus = new IntMeter(200); 
     39        hyppyNopeus = new IntMeter(700); 
     40 
    3641        ClearAll(); 
    3742        Gravity = new Vector(0, -1000); 
     
    4348        Camera.ZoomFactor = 1.2; 
    4449        Camera.StayInLevel = true; 
     50        MediaPlayer.Play("GroundTheme"); 
     51        MediaPlayer.IsRepeating = true; 
     52        MediaPlayer.Volume = 0.2; 
    4553    } 
    4654 
     
    5462        kentta.SetTileMethod("FF0000", LisaaVihu); 
    5563        kentta.SetTileMethod("B6FF00", LisaaRuoho); 
     64        kentta.SetTileMethod("404040", Palikka3); 
     65        //kentta.SetTileMethod("") 
    5666        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    5767        Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
     68    } 
     69 
     70    void Palikka3(Vector paikka, double leveys, double korkeus) 
     71    { 
     72        PhysicsObject Palikka3 = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     73        Palikka3.Image = Palikka2; 
     74        Palikka3.Position = paikka; 
     75        Add(Palikka3); 
    5876    } 
    5977 
     
    147165        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus, 1); 
    148166        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     167        Keyboard.Listen(Key.Space, ButtonState.Pressed, Lyo, "Pelaaja Lyö", pelaaja1); 
     168 
    149169 
    150170        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
     
    155175 
    156176        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
     177    } 
     178 
     179    void Lyo(PlatformCharacter hahmo) 
     180    { 
     181        hahmo.Image = tyyppiLyoKuva; 
     182        GameObject nyrkki = new GameObject(hahmo.Width, hahmo.Height); 
     183        nyrkki.Image = nyrkkikuva; 
     184        hahmo.Add(nyrkki); 
     185        int suunta = hahmo.FacingDirection == Direction.Right ? 1 : -1; 
     186        if (hahmo.FacingDirection == Direction.Left) nyrkki.Image = Image.Mirror(nyrkki.Image); 
     187        nyrkki.Position = new Vector(suunta * hahmo.Width, 0); 
     188        //nyrkki.Position = hahmo.Position + new Vector(hahmo.Width, 0); 
     189        //Add(nyrkki); 
     190 
     191        List<GameObject> vihutLahella = GetObjectsAt(hahmo.Position + nyrkki.Position, "pahis", nyrkki.Width); 
     192        vihutLahella.ForEach(x => x.Destroy()); 
     193 
     194        Timer.SingleShot(0.2, delegate 
     195        { 
     196            hahmo.Image = pelaajanKuva; 
     197            nyrkki.Destroy(); 
     198        }); 
    157199    } 
    158200 
  • 2013/26/WilleK/Ensimmäinen Peli/Ensimmäinen Peli/Ensimmäinen PeliContent/Ensimmäinen PeliContent.contentproj

    r4214 r4237  
    9090    </Compile> 
    9191  </ItemGroup> 
     92  <ItemGroup> 
     93    <Compile Include="alkuun.png"> 
     94      <Name>alkuun</Name> 
     95      <Importer>TextureImporter</Importer> 
     96      <Processor>TextureProcessor</Processor> 
     97    </Compile> 
     98  </ItemGroup> 
     99  <ItemGroup> 
     100    <Compile Include="TyyppiLyo.png"> 
     101      <Name>TyyppiLyo</Name> 
     102      <Importer>TextureImporter</Importer> 
     103      <Processor>TextureProcessor</Processor> 
     104    </Compile> 
     105  </ItemGroup> 
     106  <ItemGroup> 
     107    <Compile Include="Nyrkki.png"> 
     108      <Name>Nyrkki</Name> 
     109      <Importer>TextureImporter</Importer> 
     110      <Processor>TextureProcessor</Processor> 
     111    </Compile> 
     112  </ItemGroup> 
     113  <ItemGroup> 
     114    <Compile Include="GroundTheme.mp3"> 
     115      <Name>GroundTheme</Name> 
     116      <Importer>Mp3Importer</Importer> 
     117      <Processor>SongProcessor</Processor> 
     118    </Compile> 
     119  </ItemGroup> 
    92120  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    93121  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
Note: See TracChangeset for help on using the changeset viewer.