Ignore:
Timestamp:
2011-06-30 15:00:28 (12 years ago)
Author:
jokrhiet
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/JoelH/THPeli/THPeli/Peli.cs

    r2310 r2381  
    99public class Peli : PhysicsGame 
    1010{ 
     11    int pMaxMaara = 200; 
     12    ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("explosio"), 500); 
     13     
     14    List<Label> valikonKohdat; 
    1115    const double nopeus = 300; 
    12     const double hyppyNopeus = 900; 
     16    const double hyppyNopeus = 1000; 
    1317    const int RUUDUN_KOKO = 40; 
    1418    PlatformCharacter pelaaja1; 
     
    1721    Image tahtiKuva = LoadImage("tahti"); 
    1822    Image piikkikuva = LoadImage("piikit"); 
     23    Image norsuleft = LoadImage("norsuwalkingleft"); 
     24    Image norsuIdle = LoadImage("norsuidle"); 
     25    Image norsuRight = LoadImage("anothernorsu"); 
    1926    Image splashscreen = LoadImage("Knife's Edge"); 
     27    Image exploosio = LoadImage("explosio"); 
    2028 
    2129    public override void Begin() 
    2230    { 
    23         PhysicsObject splash = new PhysicsObject( 400.0, 400.0 ); 
    24         splash.Shape = Shape.Rectangle; 
    25         splash.Image = splashscreen; 
    26          
     31        Valikko(); 
     32        ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("explosio"), 50); 
     33 
    2734        MediaPlayer.Play("Game Theme"); 
    2835        MediaPlayer.IsRepeating = true; 
     36    } 
     37 
     38    private void alotapeli() 
     39    { 
     40        ClearAll(); 
     41        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); 
     42 
    2943        Gravity = new Vector(0, -800); 
    3044 
     
    3549        Camera.ZoomFactor = 3.0; 
    3650        Camera.StayInLevel = true; 
     51    } 
     52 
     53 
     54        void Valikko() 
     55    { 
     56        ClearAll(); 
     57        valikonKohdat = new List<Label>(); 
     58        Level.Background.Image = splashscreen; 
     59        Level.BackgroundColor = Color.Black; 
     60        Label kohta1 = new Label("New Game"); 
     61        kohta1.Position = new Vector(0, 40); 
     62        valikonKohdat.Add(kohta1); 
     63 
     64        Label kohta2 = new Label("Exit"); 
     65        kohta2.Position = new Vector(0, -40); 
     66        valikonKohdat.Add(kohta2); 
     67 
     68        foreach (Label valikonKohta in valikonKohdat) 
     69        { 
     70            Add(valikonKohta); 
     71        } 
     72 
     73        Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, alotapeli, null); 
     74        Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 
     75         
     76        Mouse.IsCursorVisible = true; 
     77        Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 
     78        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 
     79    } 
     80 
     81    void ValikossaLiikkuminen(AnalogState hiirenTila) 
     82    { 
     83        foreach (Label kohta in valikonKohdat) 
     84        { 
     85            if (Mouse.IsCursorOn(kohta)) 
     86            { 
     87                kohta.TextColor = Color.Green; 
     88            } 
     89            else 
     90            { 
     91                kohta.TextColor = Color.White; 
     92            } 
     93 
     94        } 
    3795    } 
    3896 
     
    47105        Level.CreateBorders(); 
    48106        Level.Background.CreateGradient(Color.Black, Color.Pink); 
     107        IsMouseVisible = false; 
    49108         
    50109    } 
     
    69128        pelaaja1 = new PlatformCharacter(30, 40); 
    70129        pelaaja1.Mass = 10.0; 
    71         pelaaja1.Image = pelaajanKuva; 
     130        pelaaja1.LeftWalkingAnimation = norsuleft; 
     131        pelaaja1.RightWalkingAnimation = norsuRight; 
    72132        AddCollisionHandler(pelaaja1, osuTahteen); 
    73133        return pelaaja1; 
     
    76136 
    77137 
    78  
    79138    void lisaaNappaimet() 
    80139    { 
    81         Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    82140 
    83141        Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
     
    103161        if (kohde.Tag.ToString() == "tahti") 
    104162        { 
    105             MessageDisplay.Add("Kristalli kerätty!"); 
     163            Add(rajahdys); 
     164            //double X = 0; 
     165            //double Y = 0; 
     166            int pMaara = 600; 
     167            rajahdys.MaxScale = 6; 
     168            rajahdys.MinScale = 1; 
     169            rajahdys.MinLifetime = 0.1; 
     170            rajahdys.MaxLifetime = 0.5; 
     171            rajahdys.AddEffect( kohde.Position, pMaara ); 
     172 
    106173            kohde.Destroy(); 
    107  
     174            MessageDisplay.Add("Keräsit kristallin!!"); 
     175            MessageDisplay.TextColor = Color.White; 
    108176        } 
    109177    } 
Note: See TracChangeset for help on using the changeset viewer.