Changeset 8520 for 2017/24


Ignore:
Timestamp:
2017-06-12 13:13:11 (2 years ago)
Author:
npo17_18
Message:
 
Location:
2017/24/ViljamiM/Pong/Pong/Pong
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 2017/24/ViljamiM/Pong/Pong/Pong/Pong.cs

    r8502 r8520  
    2424 
    2525 
     26 
    2627    } 
    2728 
    2829    void LuoKentta() 
    2930    { 
    30         pallo = new PhysicsObject(40.0, 40.0); 
     31        pallo = new PhysicsObject(35.0, 35.0); 
    3132        pallo.Shape = Shape.Circle; 
    3233        pallo.X = -200.0; 
     
    4950    void AloitaPeli() 
    5051    { 
    51         Vector impulssi = new Vector(500.0, 0.0); 
     52        Vector impulssi = new Vector(600.0, 0.0); 
    5253        pallo.Hit(impulssi); 
    5354    } 
     
    6970        Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    7071 
    71         Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "pelaaja 2:Liikuta mailaa ylös", maila2, nopeusYlos); 
    72         Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2 Vector.Zero); 
    73         Keyboard.Listen(Key.Down, ButtonState.Down AsetaNopeus) 
     72        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 
     73        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     74        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 
     75        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     76 
     77        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    7478        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    7579    } 
     80 
    7681    void AsetaNopeus(PhysicsObject maila, Vector nopeus) 
    7782    { 
    78         maila.Velocity = nopeus; 
     83        if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 
     84        { 
     85            maila.Velocity = Vector.Zero; 
     86            return; 
     87        } 
     88        if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 
     89        { 
     90            maila.Velocity = Vector.Zero; 
     91            return; 
     92 
     93        } 
     94 
     95        maila.Velocity = nopeus * 2; 
    7996    } 
    80 } 
     97    } 
Note: See TracChangeset for help on using the changeset viewer.