Changeset 2215


Ignore:
Timestamp:
2011-06-28 12:39:21 (8 years ago)
Author:
vilmarju
Message:

Talletus.

Location:
2011/26/VilleK/ponggi/ponggi/ponggi
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/VilleK/ponggi/ponggi/ponggi/Peli.cs

    r2200 r2215  
    88 
    99public class Peli : PhysicsGame 
    10 {Vector nopeusYlos = new Vector( 0, 200 ); 
    11     Vector nopeusAlas = new Vector( 0, -200 ); 
     10{ 
     11    Vector nopeusYlos = new Vector(0, 200); 
     12    Vector nopeusAlas = new Vector(0, -200); 
    1213 
    1314    PhysicsObject pallo; 
    1415    PhysicsObject maila1; 
    1516    PhysicsObject maila2; 
     17     
    1618 
    1719 
     
    2931        pallo = new PhysicsObject(70.0, 70.0); 
    3032        Add(pallo); 
    31         pallo.Shape = Shape.Circle; 
     33        pallo.Shape = Shape.Triangle; 
    3234        pallo.Color = Color.DarkViolet; 
    3335        pallo.X = -200.0; 
     
    4244    } 
    4345    void AsetaOhjaimet() 
     46    { 
     47        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
     48        Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 
     49        Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     50        Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
     51        Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    4452 
    45          { 
    46              Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
    47              Keyboard.Listen( Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös",maila1,nopeusYlos); 
    48              Keyboard.Listen( Key.A, ButtonState.Released, AsetaNopeus, null,maila1,Vector.Zero ); 
    49     Keyboard.Listen( Key.Z,      ButtonState.Down,     AsetaNopeus,     "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas ); 
    50     Keyboard.Listen( Key.Z,      ButtonState.Released, AsetaNopeus,     null,                             maila1, Vector.Zero ); 
     53        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 
     54        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     55        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 
     56        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
    5157 
    52     Keyboard.Listen( Key.Up,     ButtonState.Down,     AsetaNopeus,     "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos ); 
    53     Keyboard.Listen( Key.Up,     ButtonState.Released, AsetaNopeus,     null,                             maila2, Vector.Zero ); 
    54     Keyboard.Listen( Key.Down,   ButtonState.Down,     AsetaNopeus,     "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas ); 
    55     Keyboard.Listen( Key.Down,   ButtonState.Released, AsetaNopeus,     null,                             maila2, Vector.Zero ); 
     58        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
     59    ControllerOne.Listen( Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila1, nopeusYlos ); 
     60    ControllerOne.Listen( Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero ); 
     61    ControllerOne.Listen( Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila1, nopeusAlas ); 
     62    ControllerOne.Listen( Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero ); 
    5663 
    57     Keyboard.Listen( Key.F1,     ButtonState.Pressed,  ShowControlHelp, "Näytä ohjeet" ); 
     64    ControllerTwo.Listen( Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila2, nopeusYlos ); 
     65    ControllerTwo.Listen( Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero ); 
     66    ControllerTwo.Listen( Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila2, nopeusAlas ); 
     67    ControllerTwo.Listen( Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero ); 
    5868 
    59          } 
    60 void AsetaNopeus( PhysicsObject maila, Vector nopeus ) 
    61 { 
    62    maila.Velocity = nopeus; 
    63 } 
     69    ControllerOne.Listen( Button.Back, ButtonState.Pressed, Exit, "Poistu" ); 
     70    ControllerTwo.Listen( Button.Back, ButtonState.Pressed, Exit, "Poistu" ); 
     71 
     72    } 
     73       void AsetaNopeus( PhysicsObject maila, Vector nopeus ) 
     74    { 
     75        if ( (nopeus.Y < 0) && (maila.Bottom < Level.Bottom) ) 
     76        { 
     77            maila.Velocity = Vector.Zero; 
     78            return; 
     79        } 
     80        if ( (nopeus.Y > 0) && (maila.Top > Level.Top) ) 
     81        { 
     82            maila.Velocity = Vector.Zero; 
     83            return; 
     84        } 
     85 
     86 
     87 
     88 
     89 
     90 
     91        maila.Velocity = nopeus; 
     92    } 
     93 
    6494 
    6595    PhysicsObject LuoMaila(double x, double y) 
Note: See TracChangeset for help on using the changeset viewer.