Ignore:
Timestamp:
2015-06-23 11:34:51 (8 years ago)
Author:
iisaaira
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2015/26/Tuisku/counter food/counter food/counter food/counter_food.cs

    r6140 r6165  
    99public class counter_food : PhysicsGame 
    1010{ 
     11    Vector liikeOikealle = new Vector (100.0, 0); 
     12    Vector liikeVasemalle = new Vector(-100.0, 0);  
     13    PhysicsObject pelaaja1; 
    1114     
    1215    IntMeter pisteLaskuri; 
    1316    IntMeter pisteLaskuri2; 
     17    Vector nopeus;  
    1418 
    1519 
     
    1721    { 
    1822        kartta(); 
    19         pelaaja1(); 
    20         pelaaja2(); 
     23        LuoPelaaja1(); 
     24        LuoPelaaja2(); 
    2125        LuoPistelaskuri(); 
    2226        LuoPistelaskuri2(); 
     27         
     28         
    2329 
    2430    } 
     
    3440        lattia.Y = (-500.0); 
    3541 
     42         
     43         
     44 
    3645    } 
    3746 
    3847 
    39     void pelaaja1() 
     48    void LuoPelaaja1() 
    4049    { 
    4150        PhysicsObject h = new PhysicsObject(20.0, 20.0); 
     
    4453        Add(h); 
    4554        h.X = (900.0); 
    46         h.Y = (-430); 
    47  
     55        h.Y = (-420); 
     56         
    4857    } 
    4958 
    50     void pelaaja2() 
     59    void LuoPelaaja2() 
    5160    { 
    5261        PhysicsObject p = new PhysicsObject(20.0, 20.0); 
     62 
     63 
     64        //new PhysicsObject(LoadImage("")); 
     65        
    5366        p.Shape = Shape.Circle; 
    5467        p.Color = Color.Red; 
     
    5871 
    5972    } 
    60  
    61      
    62      
    63  
    6473 
    6574    void LuoPistelaskuri() 
     
    8291 
    8392        Label pisteNaytto2 = new Label(); 
    84         pisteNaytto2.X = Screen.Right + 100; 
    85         pisteNaytto2.Y = Screen.Top - 100; 
     93        pisteNaytto2.X = Screen.Right - 100; 
     94        pisteNaytto2.Y = Screen.Top + 100; 
    8695        pisteNaytto2.TextColor = Color.Black; 
    8796        pisteNaytto2.Color = Color.White; 
     
    91100        Add(pisteNaytto2); 
    92101    } 
     102 
     103    void lisaanappaimet() 
     104    { 
     105        Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "pelaaja 1: liiku oikealle", pelaaja1, liikeOikealle); 
     106        Keyboard.Listen(Key.Right, ButtonState.Released, AsetaNopeus, null, pelaaja1, Vector.Zero); 
     107        Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liiku vasemalle", pelaaja1, liikeVasemalle); 
     108        Keyboard.Listen(Key.Left, ButtonState.Released, AsetaNopeus, null, pelaaja1, Vector.Zero); 
     109 
     110 
     111    } 
     112 
     113 
     114 
     115    void AsetaNopeus(PhysicsObject pelaaja1, Vector nopeus) 
     116    { 
     117        if ((nopeus.Y < 0) && (pelaaja1.Bottom < Level.Bottom)) 
     118        { 
     119            pelaaja1.Velocity = Vector.Zero; 
     120            return; 
     121        } 
     122        if ((nopeus.Y > 0) && (pelaaja1.Top > Level.Top)) 
     123        { 
     124            pelaaja1.Velocity = Vector.Zero; 
     125            return; 
     126        } 
     127 
     128        pelaaja1.Velocity = nopeus; 
     129    } 
    93130     
     131 
     132    
    94133 
    95134 
Note: See TracChangeset for help on using the changeset viewer.