Changeset 4070


Ignore:
Timestamp:
2013-06-11 14:56:50 (10 years ago)
Author:
onosvevi
Message:
 
Location:
2013/24/OnniV
Files:
54 added
4 edited

Legend:

Unmodified
Added
Removed
  • 2013/24/OnniV/pong/pong/pong/pong.cs

    r4050 r4070  
    99public class pong : PhysicsGame 
    1010{ 
     11    Vector nopeusYlös = new Vector(0, 200); 
     12    Vector nopeusAlas = new Vector(0, -200); 
     13 
    1114    PhysicsObject pallo; 
     15 
     16    PhysicsObject maila1; 
     17    PhysicsObject maila2; 
    1218 
    1319    public override void Begin() 
     
    3137        pallo.Restitution = 0.8; 
    3238        Level.BackgroundColor = Color.Black; 
    33         luomaila(Level.Left + 20.0, 0.0); 
    34         luomaila(Level.Right - 20.0, 0.0); 
     39        maila1 = luomaila(Level.Left + 20.0, 0.0); 
     40        maila2 = luomaila(Level.Right - 20.0, 0.0); 
    3541        Camera.ZoomToLevel(); 
    3642 
     
    4551        pallo.Hit(impulssi); 
    4652    } 
    47     void luomaila(double X, double Y) 
     53    PhysicsObject luomaila(double X, double Y) 
    4854    { 
    4955        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
     
    5359        maila.Restitution = 1.0; 
    5460        Add(maila); 
     61        return maila; 
    5562    } 
    5663 
    5764    void asetaohjaimet() 
    5865    { 
     66        Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, LiikutaMaila1Ylös, "pelaaja1: liikuta mailaa ylös", maila1, nopeusYlös); 
     67        Keyboard.listen(Key.A, ButtonState.Released, AsetaNopeus, PysäytäMaila1, null, maila1, Vector.Zero); 
     68        Keyboard.Listen(Key.Escape, ButtonState.Pressed); 
     69         
    5970 
    60         Keyboard.Listen(Key.A, ButtonState.Down, LiikutaMaila1Ylös, "pelaaja1: liikuta mailaa ylös"); 
    61         Keyboard.listen(Key.A, ButtonState.Released, PysäytäMaila1, null); 
    62         Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     71 
     72 
     73 
    6374    } 
     75    void AsetaNopeus() 
     76    { 
     77        maila1.Velocity = nopeus; 
     78        maila2.Velocity = nopeus; 
     79    } 
     80       
     81 
     82 
     83 
     84    } 
     85} 
    6486     
    65 } 
     87 
    6688 
    6789 
Note: See TracChangeset for help on using the changeset viewer.