Changeset 1229 for 2010/27


Ignore:
Timestamp:
2010-07-09 13:04:48 (13 years ago)
Author:
paaaanro
Message:

OK

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2010/27/heikriin/CrabsAndShrimps/Peli.cs

    r1223 r1229  
    1212    PlatformCharacter rapu; 
    1313 
    14  
    15  
    1614    IntMeter pisteLaskuri; 
    1715    IntMeter katkisElamat, rapuElamat; 
    1816 
    19   
    20  
    2117    protected override void Begin() 
    2218    { 
    23         AloitaPeli(); 
    2419        luoKentta(); 
    2520 
    26  
    27         
    2821        katkis = new PlatformCharacter(220.0, 220.0); 
    2922        Add(katkis); 
     
    3225        katkis.Y = -250.0; 
    3326        katkis.Image = LoadImage("katkis"); 
    34          
    35  
    36         //pannu = new GameObject(500, 500); 
    37         //pannu.Color = Color.Red; 
    38         //pannu.Tag = "pannu"; 
    39         //Add(pannu); 
    40         //katkis.Add(pannu); 
    4127 
    4228        rapu = new PlatformCharacter(300.0, 300.0); 
     
    4733        rapu.Image = LoadImage("rapu"); 
    4834 
    49         //kukka = new GameObject(500, 500); 
    50         //kukka.Color = Color.Red; 
    51         //rapu.Add(kukka); 
    52  
    53          
    54         AddCollisionHandler(katkis, katkisTormaa); 
    55         AddCollisionHandler(rapu, rapuTormaa); 
    5635 
    5736        Level.CreateBorders(false); 
     
    5938 
    6039        Camera.ZoomToLevel(); 
    61          
     40 
    6241        Gravity = new Vector(0.0, -800.0); 
    6342        lisaaNappaimet(); 
     
    7857        Keyboard.Listen(Key.D, ButtonState.Down, liikuta, "Liikkuu oikealle", rapu, 100.0); 
    7958        Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", rapu, hyppyVoima); 
    80         Keyboard.Listen(Key.Q, ButtonState.Pressed, rapuiskee, "Kukka");   
     59        Keyboard.Listen(Key.Q, ButtonState.Pressed, rapuiskee, "Kukka"); 
    8160 
    8261    } 
    83      
    84  
    85      
    86      
    8762 
    8863    void katkisiskee() 
    8964    { 
    90         Image[] katkisKuvat = LoadImages("katkis", "katkisiskee", "katkisiskee", "katkisiskee"); 
     65        Image[] katkisKuvat; 
     66        if (katkis.X > rapu.X) 
     67        { 
     68            katkisKuvat = LoadImages("katkis", "katkisiskee", "katkisiskee", "katkisiskee"); 
     69        } 
     70        else 
     71        { 
     72            katkisKuvat = new Image[]{ 
     73                Image.Mirror(LoadImage("katkis")), 
     74                Image.Mirror(LoadImage("katkisiskee")), 
     75                Image.Mirror(LoadImage("katkisiskee")), 
     76                Image.Mirror(LoadImage("katkisiskee")) 
     77            }; 
     78 
     79        } 
     80 
    9181        katkis.Animation = new Animation(katkisKuvat); 
    9282        katkis.Animation.Start(1); 
    9383        Vector etaisyys = new Vector(katkis.X - rapu.X, katkis.Y - rapu.Y); 
    94         if(etaisyys.Magnitude < 300) 
     84        if (etaisyys.Magnitude < 300) 
    9585        { 
    96             rapuElamat.Value -=5; 
     86            rapuElamat.Value -= 5; 
    9787            ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("bang"), 1); 
    9888            Add(rajahdys); 
     
    10999    void rapuiskee() 
    110100    { 
    111         Image[] rapuKuvat = LoadImages("rapu", "rapuiskee", "rapuiskee", "rapuiskee"); 
     101        Image[] rapuKuvat; 
     102        if (rapu.X < katkis.X) 
     103        { 
     104            rapuKuvat = LoadImages("rapu", "rapuiskee", "rapuiskee", "rapuiskee"); 
     105        } 
     106        else 
     107        { 
     108            rapuKuvat = new Image[] 
     109            { 
     110                Image.Mirror(LoadImage("rapu")), 
     111                Image.Mirror(LoadImage("rapuiskee")), 
     112                Image.Mirror(LoadImage("rapuiskee")), 
     113                Image.Mirror(LoadImage("rapuiskee")) 
     114            }; 
     115        } 
     116 
    112117        rapu.Animation = new Animation(rapuKuvat); 
    113118        rapu.Animation.Start(1); 
    114119        Vector etaisyys = new Vector(katkis.X - rapu.X, katkis.Y - rapu.Y); 
    115120        if (etaisyys.Magnitude < 300) 
    116  
    117121        { 
    118             katkisElamat.Value -=5; 
     122            katkisElamat.Value -= 5; 
    119123 
    120124            ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("loyh"), 1); 
    121125            Add(rajahdys); 
    122126            rajahdys.AddEffect(0, 0, 1); 
    123  
    124127        } 
    125  
    126  
    127128 
    128129        if (katkisElamat.Value <= 0) 
     
    132133        } 
    133134 
    134  
    135          
    136135    } 
    137136 
     
    152151    } 
    153152 
    154     void katkisTormaa(PhysicsObject katkis, PhysicsObject kohde) 
    155     { 
    156         //if (kohde.Tag.ToString() == "pannu") 
    157         //{ 
    158         //    MessageDisplay.Add("katkikseen osui"); 
    159         //} 
    160     } 
    161153 
    162     void rapuTormaa(PhysicsObject rapu, PhysicsObject kohde) 
    163     { 
    164  
    165     } 
    166154    void LuoLaskuri() 
    167155    { 
     
    191179    } 
    192180 
    193      
    194  
    195     void AloitaPeli() 
    196     { } 
    197  
    198181    void LopetusRuutu() 
    199182    { 
    200183        ClearAll(); 
    201          
     184 
    202185        MessageDisplay.TextColor = Color.White; 
    203186        MessageDisplay.Position = new Vector(00, 00); 
    204187 
    205         Keyboard.Listen(Key.V,ButtonState.Pressed, Begin, null); 
     188        Keyboard.Listen(Key.V, ButtonState.Pressed, Begin, null); 
    206189 
    207190 
    208191    } 
    209192 
    210  
    211  
    212      
    213  
    214  
    215  
    216  
    217  
    218193} 
Note: See TracChangeset for help on using the changeset viewer.