Ignore:
Timestamp:
2014-07-24 15:01:38 (9 years ago)
Author:
aajualal
Message:

fail

File:
1 edited

Legend:

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

    r5627 r5646  
    2222public class AdventureOfStarKid : PhysicsGame 
    2323{ 
     24    int kenttaNro = 1; 
    2425    private Image[] running = LoadImages("running1", "running2"); 
    2526    private Image[] standinganimation = LoadImages("shootinganimation"); 
     
    2829    private Image[] lifelost = LoadImages("LifeLost"); 
    2930    private Image[] damage = LoadImages("Damage"); 
     31    private Image OneUP = LoadImage("1UP"); 
     32    private Image Healing = LoadImage("Healing"); 
    3033    const double nopeus = 200; 
    3134    const double hyppyNopeus = 750; 
    3235    const int RUUDUN_KOKO = 40; 
    33    PlasmaCannon pelaajan1Ase; 
    34    DoubleMeter health; 
    35     
     36    PlasmaCannon pelaajan1Ase; 
     37    DoubleMeter health; 
     38 
    3639 
    3740    PlatformCharacter pelaaja1; 
     
    5255    { 
    5356        ClearAll(); 
    54         Gravity = new Vector(0, -1000); 
    55  
    56         LuoKentta(); 
     57        
     58 
     59        SeuraavaKentta(); 
    5760        LisaaNappaimet(); 
    58         LuoPistelaskuri(); 
    59  
    60         Camera.Follow(pelaaja1); 
    61         Camera.ZoomFactor = 1.2; 
    62         Camera.StayInLevel = true; 
    63     } 
    64  
    65     void LuoKentta() 
    66     { 
    67         TileMap kentta = TileMap.FromLevelAsset("kentta1"); 
     61        
     62    } 
     63 
     64    void LuoKentta(string kenttaTiedostonNimi) 
     65    { 
     66        TileMap kentta = TileMap.FromLevelAsset(kenttaTiedostonNimi); 
    6867        kentta.SetTileMethod('#', LisaaTaso); 
    6968        kentta.SetTileMethod('*', Lisaastumper); 
    7069        kentta.SetTileMethod('N', LisaaPelaaja); 
     70        kentta.SetTileMethod('1', Lisaa1UP); 
     71        kentta.SetTileMethod('H', LisaaHealing); 
    7172        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    7273        Level.CreateBorders(); 
    7374        Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
     75    } 
     76    void Lisaa1UP(Vector paikka, double leveys, double korkeus) 
     77    { 
     78        AddItem(paikka, leveys, korkeus, OneUP, "1UP"); 
     79    } 
     80    void LisaaHealing(Vector paikka, double leveys, double korkeus) 
     81    { 
     82        AddItem(paikka, leveys, korkeus, Healing, "Heal"); 
     83 
     84    } 
     85 
     86    void AddItem(Vector paikka, double leveys, double korkeus, Image Kuva, String tagi) 
     87    { 
     88        PhysicsObject Item = new PhysicsObject(leveys, korkeus); 
     89        Item.Position = paikka; 
     90        Add(Item); 
     91        Item.Image = Kuva; 
     92        Item.Tag = tagi; 
    7493    } 
    7594 
     
    84103    void Lisaastumper(Vector paikka, double leveys, double korkeus) 
    85104    { 
    86         Vihu stumper = new Vihu(leveys-4, korkeus-4); 
     105        Vihu stumper = new Vihu(leveys - 4, korkeus - 4); 
    87106        stumper.IgnoresCollisionResponse = false; 
    88107        stumper.Position = paikka; 
     
    99118    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
    100119    { 
    101         pelaaja1 = new PlatformCharacter(leveys*0.5, korkeus); 
     120        pelaaja1 = new PlatformCharacter(leveys * 0.5, korkeus); 
    102121        pelaaja1.Position = paikka; 
    103122        pelaaja1.Mass = 4.0; 
     
    105124        AddCollisionHandler(pelaaja1, "stumper", TormaaTahteen); 
    106125        Add(pelaaja1); 
     126        AddCollisionHandler(pelaaja1, "1UP", tormaaOneUP); 
     127        AddCollisionHandler(pelaaja1, "Heal", tormaaHealingiin); 
    107128        pelaaja1.AnimWalk = new Animation(running); 
    108129        pelaaja1.AnimIdle = new Animation(shootinganimation); 
    109130        pelaaja1.AnimJump = new Animation(jumpinganimation); 
    110131        pelaaja1.AnimFall = new Animation(jumpinganimation); 
    111          
     132 
    112133        pelaajan1Ase = new PlasmaCannon(1.0, 1.0); 
    113134        pelaajan1Ase.InfiniteAmmo = true; 
     
    134155        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
    135156        Keyboard.Listen(Key.Space, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    136         Keyboard.Listen(Key. C, ButtonState.Pressed, Ammu, "Ampuu", pelaajan1Ase); 
     157        Keyboard.Listen(Key.C, ButtonState.Pressed, Ammu, "Ampuu", pelaajan1Ase); 
    137158 
    138159 
     
    180201        health.MinValue = 0; 
    181202        health.LowerLimit += PelaajaHaviaa; 
    182          
     203 
    183204        health.Changed += delegate 
    184205        { 
     
    189210            Timer.SingleShot(1, delegate { invincible = false; }); 
    190211        }; 
    191          
     212 
    192213        ProgressBar healthMeter = new ProgressBar(150, 20); 
    193214        healthMeter.X = Screen.Left + 150; 
     
    195216        healthMeter.BindTo(health); 
    196217        Add(healthMeter); 
    197         
     218 
    198219        healthMeter.Angle = Angle.RightAngle; 
    199220        healthMeter.Color = Color.Transparent; 
     
    202223 
    203224 
    204          
     225 
    205226    } 
    206227    void PelaajaHaviaa() 
     
    216237        Timer.SingleShot(5, AloitaPeli); 
    217238    } 
     239    void tormaaOneUP(PhysicsObject pelaaja1, PhysicsObject OneUP) 
     240    { 
     241        health.Value = health.MaxValue; 
     242        OneUP.Destroy(); 
     243    } 
     244    void tormaaHealingiin(PhysicsObject pelaaja1, PhysicsObject Healing) 
     245    { 
     246        health.Value += 3; 
     247        Healing.Destroy(); 
     248 
     249    } 
     250    void SeuraavaKentta() 
     251    { 
     252        ClearAll(); 
     253        Gravity = new Vector(0, -1000); 
     254        if (kenttaNro == 1) LuoKentta("kentta1"); 
     255        else if (kenttaNro == 2) LuoKentta("kentta2"); 
     256        else if (kenttaNro == 3) LuoKentta("kentta3"); 
     257        else if (kenttaNro > 3) Exit(); 
     258 
     259        LisaaNappaimet(); 
     260        LuoPistelaskuri(); 
     261 
     262        Camera.Follow(pelaaja1); 
     263        Camera.ZoomFactor = 1.2; 
     264        Camera.StayInLevel = true; 
     265    } 
    218266} 
Note: See TracChangeset for help on using the changeset viewer.