Changeset 536


Ignore:
Timestamp:
2010-06-08 11:26:58 (13 years ago)
Author:
jealmaki
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2010/23/jealmaki/poing/jealmaki Peli.cs

    r520 r536  
    99    { 
    1010        PhysicsObject pallo; 
    11  
     11        PhysicsObject maila1; 
     12        PhysicsObject maila2; 
    1213        protected override void Begin() 
    1314        { 
    1415            LuoKentta(); 
    15             Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
     16            AsetaOhjaimet(); 
    1617            AloitaPeli(); 
    1718            Vector impulssi = new Vector(300.0, 1.0); 
     
    3031            pallo.Hit(impulssi); 
    3132 
    32             LuoMaila(Level.Left + 20.0, 0.0); 
    33             LuoMaila(Level.Right - 20.0, 0.0); 
     33            maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
     34            maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
    3435 
    3536            Level.CreateBorders(1.0, false); 
     
    5455            return maila; 
    5556        } 
     57        void LiikutaMailaaYlos(PhysicsObject maila) 
     58        { 
     59            if (maila.Y >= Level.Top) 
     60            { 
     61                maila.Velocity = Vector.Zero; 
     62                return; 
     63            } 
     64 
     65                Vector nopeus = new Vector(0, 200); 
     66                maila.Velocity = nopeus; 
     67             
     68        } 
     69         
     70        void PysaytaMaila(PhysicsObject maila) 
     71        { 
     72            maila.Velocity = Vector.Zero; 
     73        } 
     74 
     75        void LiikutaMailaaAlas(PhysicsObject maila) 
     76        { 
     77            { 
     78 
     79                Vector nopeus = new Vector(0, -200); 
     80                maila.Velocity = nopeus; 
     81 
     82            } 
     83        } 
    5684        void AsetaOhjaimet() 
    5785        { 
    58             Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
     86 
     87            Keyboard.Listen(Key.W, ButtonState.Down, LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös", maila1); 
     88            Keyboard.Listen(Key.W, ButtonState.Released, PysaytaMaila, null, maila1); 
     89            Keyboard.Listen(Key.S, ButtonState.Down, LiikutaMailaaAlas, "Pelaaja 1: Liikuta mailaa alas", maila1); 
     90            Keyboard.Listen(Key.S, ButtonState.Released, PysaytaMaila, null, maila1); 
     91 
     92            Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaMailaaYlos, "Pelaaja 2: Liikuta mailaa ylös", maila2); 
     93            Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaMaila, null, maila2); 
     94            Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaMailaaAlas, "Pelaaja 2: Liikuta mailaa alas", maila2); 
     95            Keyboard.Listen(Key.Down, ButtonState.Released, PysaytaMaila, null, maila2); 
     96 
     97            Keyboard.Listen(Key.F1, ButtonState.Down, ShowControlHelp, "Näytä ohjeet"); 
     98            Keyboard.Listen(Key.Escape, ButtonState.Down, Exit, "Poistu"); 
     99 
    59100        } 
    60  
    61  
     101             
    62102    } 
    63103 
Note: See TracChangeset for help on using the changeset viewer.