Ignore:
Timestamp:
2011-06-30 14:57:44 (12 years ago)
Author:
saselamp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/JimiL/Pelit/pelit22/world of Chuckland fix fix/world of Chuckland fix fix/Peli.cs

    r2365 r2372  
    77using Jypeli.Widgets; 
    88 
    9  
    10  
    11  
    12  
    139public class Peli : PhysicsGame 
     10{ 
     11    const double nopeus = 300; 
     12    const double hyppyNopeus = 1000; 
     13    // const double InventaarioX = Screen.Left 
    1414     
    15 { 
    16     const double nopeus = 500; 
    17     const double hyppyNopeus = 1000; 
    1815    const int RUUDUN_KOKO = 40; 
    1916 
    20      PlatformCharacter pelaaja1; 
    21      
    22  
    23     GameObject heppu; 
     17    PlatformCharacter pelaaja1; 
     18 
     19 
     20    PhysicsObject heppu; 
    2421    Image paikallaanvasemmalle1 = LoadImage("heppuleft1"); 
    2522    Image paikallaanoikelle1 = LoadImage("heppu"); 
     
    3027    Image paikallaanvasemmalle = LoadImage("hahmo"); 
    3128    Image paikallaanoikelle = LoadImage("hahmo"); 
    32      
    33     Image[] kavelyoikelle = LoadImages("hahmoright1","hahmoright2"); 
     29 
     30    Image[] kavelyoikelle = LoadImages("hahmoright1", "hahmoright2"); 
    3431    Image[] kavelyvasemmalle; 
    3532    Image pelaajanKuva = LoadImage("hahmo"); 
     
    4744    Image ruohokuva = LoadImage("ruoho"); 
    4845    Image koivukuva = LoadImage("koivu"); 
    49  
    50  
     46    Widget Inventory; 
    5147 
    5248    SoundEffect maaliAani = LoadSoundEffect("maali"); 
     49 
     50    List<PhysicsObject> keratytTavarat = new List<PhysicsObject>(); 
    5351 
    5452    public override void Begin() 
     
    6058        kavelyoikelle1 = Image.Mirror(kavelyvasemmalle1); 
    6159 
    62         
    63          
    64  
    65  
    66  
    6760        Gravity = new Vector(0, -1000); 
    68          
    69  
    70  
    7161 
    7262        luoKentta(); 
     
    9383        kentta['='] = lisaaruoho; 
    9484        kentta[')'] = lisaakoivu; 
    95         
    96  
    97  
    98  
     85        kentta['x'] = lisaaKerattava; 
    9986 
    10087        kentta.Insert(50, 50); 
    10188        Level.CreateBorders(); 
    102         Level.Background.CreateGradient(Color.White, Color.SkyBlue);  
    103     } 
    104     RandomMoverBrain Satunnaisaivot = new RandomMoverBrain(10000); 
    105  
    106      
    107     
     89        Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
     90    } 
     91    RandomMoverBrain Satunnaisaivot = new RandomMoverBrain(12000); 
     92 
     93 
     94    PhysicsObject lisaaKerattava() 
     95    { 
     96        PhysicsObject kerattava = new PhysicsObject(20, 20); 
     97        kerattava.Tag = "kerattava1"; 
     98        return kerattava; 
     99    } 
    108100 
    109101    PhysicsObject lisaakoivu() 
     
    112104        koivu.Image = koivukuva; 
    113105        koivu.Tag = "koivu"; 
    114  
    115         Add(koivu); 
    116106        return koivu; 
    117107    } 
     
    205195 
    206196        heppu.Brain = Satunnaisaivot; 
    207         Satunnaisaivot.ChangeMovementSeconds = 5; 
     197        Satunnaisaivot.ChangeMovementSeconds = RandomGen.NextDouble(2.3, 5.5); 
    208198        heppu.Tag = "heppu"; 
    209199        heppu.Image = heppukuva; 
     
    222212        pelaaja1.Image = pelaajanKuva; 
    223213        pelaaja1.Tag = "pelaaja1"; 
    224          
    225          
    226          
     214 
     215 
     216 
    227217        pelaaja1.LeftIdleAnimation = new Animation(paikallaanvasemmalle); 
    228218        pelaaja1.RightIdleAnimation = new Animation(paikallaanoikelle); 
     
    234224        return pelaaja1; 
    235225 
    236          
    237          
    238  
    239     } 
    240  
    241       
    242      
     226 
     227 
     228 
     229    } 
     230 
     231 
     232 
    243233 
    244234    void lisaaNappaimet() 
     
    246236        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    247237        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    248          
     238        Keyboard.Listen(Key.E, ButtonState.Pressed, avaainventory, "avaa inventoryn"); 
     239        Keyboard.Listen(Key.E, ButtonState.Released, sulkeeinventory, "sulkee inventoryn"); 
    249240 
    250241        Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
     
    268259        hahmo.Jump(nopeus); 
    269260    } 
    270     void osupelaajaan(PhysicsObject pelaaja, PhysicsObject heppu) 
     261 
     262 
     263    void osupelaajaan(PhysicsObject pelaaja, PhysicsObject kohde) 
    271264    { 
    272265        if (pelaaja.Tag.ToString() == "pelaaja1") 
    273  
    274266        { 
    275             if (heppu.Tag.ToString() == "heppu") 
     267            if (kohde.Tag.ToString() == "heppu") 
    276268            { 
    277                  
    278269                maaliAani.Play(); 
    279270                MessageDisplay.Add("Die"); 
    280271                pelaaja.Destroy(); 
    281  
    282                  
    283  
    284  
    285                 
     272            } 
     273 
     274            if (kohde.Tag.ToString() == "kerattava1") 
     275            { 
     276                keratytTavarat.Add(kohde); 
     277                kohde.Destroy(); 
    286278            } 
    287279        } 
    288280    } 
    289     void OsuEsineeseen(PlatformCharacter pelaaja1, PhysicsObject kohde) 
    290     { 
    291          
    292  
    293  
    294     } 
    295  
    296  
    297      
    298     } 
    299  
     281    void AvaaInventory() 
     282    { 
     283        Inventory = new Widget(253.0, 388.0); 
     284        Inventory.X = Screen.LeftSafe + 1000; 
     285        Inventory.Y = Screen.TopSafe - 400; 
     286 
     287        Inventory.Image = LoadImage("inventory"); 
     288        Add(Inventory); 
     289 
     290        for (int i = 0; i < keratytTavarat.Count; i++) 
     291        { 
     292            if (keratytTavarat[i].Tag.ToString() == "kerattava1") 
     293            { 
     294                Widget aseWidget = new Widget(35, 35); 
     295                aseWidget.X = Screen.LeftSafe + 1000; 
     296                aseWidget.Y = Screen.TopSafe - 400; 
     297                Add(aseWidget); 
     298            } 
     299        } 
     300 
     301    } 
     302 
     303 
     304    void avaainventory() 
     305    { 
     306        AvaaInventory(); 
     307 
     308    } 
     309    void sulkeeinventory() 
     310    { 
     311        Inventory.Destroy(); 
     312 
     313    } 
     314} 
     315 
Note: See TracChangeset for help on using the changeset viewer.