Changeset 6673 for 2015/27


Ignore:
Timestamp:
2015-07-01 14:02:38 (4 years ago)
Author:
vivahann
Message:

Eemililililililile

Location:
2015/27/VilleHa
Files:
41 added
1 edited

Legend:

Unmodified
Added
Removed
  • 2015/27/VilleHa/Pong/Pong/Pong/Pong.cs

    r6493 r6673  
    99public class Pong : PhysicsGame 
    1010{ 
     11    Vector nopeusYlos = new Vector(0, 200); 
     12    Vector nopeusAlas = new Vector(0, -200); 
     13 
    1114    PhysicsObject pallo; 
     15 
     16    PhysicsObject maila1; 
     17    PhysicsObject maila2; 
     18 
    1219    public override void Begin() 
    1320    { 
     
    1522 
    1623        LuoKentta(); 
     24        AsetaOhjaimet(); 
    1725        AloitaPeli(); 
    1826 
     
    2230         
    2331 
    24         Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     32   
    2533    } 
    2634    void LuoKentta() 
     
    3341        pallo.Restitution = 1.0; 
    3442 
    35         PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
    36         maila.Shape = Shape.Rectangle; 
    37         maila.X = Level.Left + 20.0; 
    38         maila.Y = 0.0; 
    39         maila.Restitution = 1.0; 
    40         Add(maila); 
     43       maila1 = LuoMaila (Level.Left + 20.0, 0.0); 
     44       maila2 = LuoMaila (Level.Right - 20.0, 0.0); 
     45 
     46         
    4147 
    4248       Level.CreateBorders(0.85, false); 
    4349       Level.Background.Color = Color.Black; 
    44         Camera.ZoomToLevel(); 
     50 
     51       Camera.ZoomToLevel(); 
    4552    } 
    4653    void AloitaPeli() 
     
    4855    pallo.Hit(impulssi); 
    4956    } 
    50     void LuoMaila(double x, double y) 
    51     { PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
    52     maila.Shape = Shape.Rectangle; 
    53     maila.X = x; 
    54     maila.Y = y; 
    55     maila.Restitution = 1.0; 
    56     Add(maila); 
     57    PhysicsObject LuoMaila(double x, double y) 
     58    {  
     59        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
     60 
     61        maila.Shape = Shape.Rectangle; 
     62        maila.X = x; 
     63        maila.Y = y; 
     64        maila.Restitution = 1.0; 
     65        Add(maila); 
     66        return maila; 
    5767    } 
     68    void AsetaOhjaimet() 
     69    { 
     70        Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös",maila1, nopeusYlos); 
     71        Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     72        Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, " Pelaaja 1 liikuta mailaa alas", maila1, nopeusAlas); 
     73        Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     74        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 
     75        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     76        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 
     77        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     78        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
     79        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     80 
     81         
     82     
     83    } 
     84 
     85    void AsetaNopeus(PhysicsObject maila, Vector nopeus); 
     86     
     87            
     88    
     89    } 
     90    
     91     
     92 
    5893} 
    5994 
Note: See TracChangeset for help on using the changeset viewer.