Ignore:
Timestamp:
2014-07-24 10:47:50 (9 years ago)
Author:
aajualal
Message:

hi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2014/30/AarniAR/AdventureOfStarKid/AdventureOfStarKid/AdventureOfStarKid/AdventureOfStarKid.cs

    r5600 r5617  
    1313    private Image[] shootinganimation = LoadImages("shootinganimation"); 
    1414    private Image[] jumpinganimation = LoadImages("jumpinganimation"); 
     15    private Image[] lifelost = LoadImages("LifeLost"); 
    1516    const double nopeus = 200; 
    1617    const double hyppyNopeus = 750; 
    1718    const int RUUDUN_KOKO = 40; 
    1819   PlasmaCannon pelaajan1Ase; 
     20   DoubleMeter health; 
    1921    
    2022 
     
    2830    public override void Begin() 
    2931    { 
     32        SmoothTextures = false; 
     33        AloitaPeli(); 
     34    } 
     35 
     36    void AloitaPeli() 
     37    { 
     38        ClearAll(); 
    3039        Gravity = new Vector(0, -1000); 
    31         SmoothTextures = false; 
    3240 
    3341        LuoKentta(); 
    3442        LisaaNappaimet(); 
     43        LuoPistelaskuri(); 
    3544 
    3645        Camera.Follow(pelaaja1); 
     
    92101        Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
    93102        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
    94         Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     103        Keyboard.Listen(Key.Space, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    95104        Keyboard.Listen(Key. C, ButtonState.Pressed, Ammu, "Ampuu", pelaajan1Ase); 
    96105 
     
    119128        maaliAani.Play(); 
    120129        MessageDisplay.Add("Ouch!"); 
     130        health.Value -= 2; 
     131         
    121132        //stumper.Destroy(); 
    122133    } 
     
    129140    void LuoPistelaskuri() 
    130141    { 
    131         IntMeter pelaajanElamat = new IntMeter(10); 
    132         pelaajanElamat.MinValue = 0; 
    133         pelaajanElamat.LowerLimit += PelaajaHaviaa; 
     142        health = new DoubleMeter(10); 
     143        health.MaxValue = 15; 
     144        health.MinValue = 0; 
     145        health.LowerLimit += PelaajaHaviaa; 
     146        /* 
     147        health.Changed += delegate 
     148        { 
     149            Animation anim = new Animation(lifelost); 
     150            anim.FPS = 2.0; 
     151            pelaaja1.PlayAnimation(anim); 
     152        }; 
     153         */ 
     154        ProgressBar healthMeter = new ProgressBar(150, 20); 
     155        healthMeter.X = Screen.Left + 150; 
     156        healthMeter.Y = Screen.Top - 100; 
     157        healthMeter.BindTo(health); 
     158        Add(healthMeter); 
     159        
     160        healthMeter.Angle = Angle.RightAngle; 
     161        healthMeter.Color = Color.Transparent; 
     162        healthMeter.BarColor = Color.Red; 
     163        healthMeter.BorderColor = Color.Black; 
     164 
     165 
     166         
    134167    } 
    135168    void PelaajaHaviaa() 
    136169    { 
    137170        MessageDisplay.Add("Life Lost..."); 
     171        pelaaja1.Destroy(); 
     172        GameObject kuoli = new GameObject(pelaaja1.Width, pelaaja1.Height); 
     173        kuoli.Image = lifelost[0]; 
     174        kuoli.Position = pelaaja1.Position; 
     175        Add(kuoli); 
     176 
     177        Timer.SingleShot(2, kuoli.Destroy); 
     178        Timer.SingleShot(5, AloitaPeli); 
    138179    } 
    139180} 
Note: See TracChangeset for help on using the changeset viewer.