Changeset 7548 for 2016/26/ViiviV


Ignore:
Timestamp:
2016-06-28 11:30:39 (3 years ago)
Author:
vivivaur
Message:

sain molemmat mailat liikkumaan

Location:
2016/26/ViiviV/Ping pong
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2016/26/ViiviV/Ping pong/Ping pong/Ping_pong/Ping_pong.cs

    r7514 r7548  
    88 
    99public class Ping_pong : PhysicsGame 
     10 
     11 
    1012{ 
     13    Vector nopeusYlos = new Vector(0, 200); 
     14    Vector nopeusAlas = new Vector(0, -200); 
     15    PhysicsObject maila1; 
     16    PhysicsObject maila2; 
     17 
     18 
     19 
     20    PhysicsObject pallo; 
    1121    public override void Begin() 
    1222    { 
    13         // TODO: Kirjoita ohjelmakoodisi tähän 
     23        LuoKentta(); 
     24        AsetaOhjaimet(); 
    1425 
    15         PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    1626        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    1727        
     
    1929        Level.CreateBorders(1.0, false); 
    2030        pallo.Hit(impulssi); 
    21         
    22         
     31 
     32 
    2333    } 
     34 
    2435    void LuoKentta() 
    2536    { 
    26         PhysicsObject pallo = new PhysicsObject(40.0, 40.0); 
     37        pallo = new PhysicsObject(40.0, 40.0); 
    2738        Add(pallo); 
    2839        pallo.Shape = Shape.Circle; 
     
    3142        pallo.Restitution = 1.0; 
    3243        Level.Background.Color = Color.Black; 
    33         Camera.ZoomToLevel(); 
    34     }' 
     44        Camera. ZoomToLevel(); 
     45  maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
     46  maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
    3547 
     48    } 
     49   void Aloitapeli() 
     50    { 
     51        Vector impulssi = new Vector(500.0, 0.0); 
     52        pallo.Hit(impulssi); 
     53        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     54    } 
     55    PhysicsObject LuoMaila(double x, double y) 
     56    { 
     57        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
     58        maila.Shape = Shape.Rectangle; 
     59        maila.X = x; 
     60        maila.Y = y; 
     61        maila.Restitution = 1.0; 
     62        Add(maila); 
     63        return maila; 
     64    } 
     65    void AsetaOhjaimet() 
     66    { 
     67        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopetapeli"); 
     68        Keyboard.Listen(Key.A, ButtonState.Down,AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös",maila1, nopeusYlos); 
     69        Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     70        Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
     71        Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     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        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
     77    } 
     78    void AsetaNopeus(PhysicsObject maila, Vector nopeus) 
     79    { 
     80        maila.Velocity = nopeus; 
     81        if (maila.Top > ) 
     82    } 
     83} 
     84    
Note: See TracChangeset for help on using the changeset viewer.