Changeset 7750


Ignore:
Timestamp:
2016-07-05 10:46:02 (7 years ago)
Author:
karkaite
Message:
 
Location:
2016/27/AnttiN
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/AnttiN/pong/pong/pong/pong.cs

    r7725 r7750  
    1616    PhysicsObject maila1; 
    1717    PhysicsObject maila2; 
     18 
     19    PhysicsObject vasenReuna; 
     20    PhysicsObject oikeaReuna; 
    1821 
    1922    const double PALLON_MIN_NOPEUS = 500; 
     
    4750        pallo.X = -200.0; 
    4851        pallo.Y = 0.0; 
     52        pallo.Restitution = 1.0; 
     53        pallo.KineticFriction = 0.0; 
     54        pallo.MomentOfInertia = Double.PositiveInfinity; 
     55        pallo.Color = Color.Blue; 
    4956        Add(pallo); 
    50         pallo.Restitution = 1.0; 
    51         pallo.Color = Color.Blue; 
     57        AddCollisionHandler(pallo, KasittelePallonTormays); 
    5258 
    5359        maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
    5460        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
    5561 
     62        vasenReuna = Level.CreateLeftBorder(); 
     63        vasenReuna.Restitution = 1.0; 
     64        vasenReuna.IsVisible = false; 
     65        vasenReuna.KineticFriction = 0.0; 
     66 
     67        oikeaReuna = Level.CreateRightBorder(); 
     68        oikeaReuna.Restitution = 1.0; 
     69        oikeaReuna.IsVisible = false; 
     70        oikeaReuna.KineticFriction = 0.0; 
     71 
     72        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     73        alaReuna.Restitution = 1.0; 
     74        alaReuna.IsVisible = false; 
     75        alaReuna.KineticFriction = 0.0; 
     76 
     77        PhysicsObject ylaReuna = Level.CreateTopBorder(); 
     78        ylaReuna.Restitution = 1.0; 
     79        ylaReuna.IsVisible = false; 
     80        ylaReuna.KineticFriction = 0.0; 
     81 
    5682        Level.Background.Color = Color.Green; 
    57         Level.CreateBorders(1.0, false); 
    5883 
    5984        Camera.ZoomToLevel(); 
     85         
    6086    } 
    6187 
     
    75101        maila.Y = y; 
    76102        maila.Restitution = 1.0; 
     103        maila.KineticFriction = 0.0; 
    77104        Add(maila); 
    78105        maila.Color = Color.Yellow; 
     
    148175    } 
    149176 
     177    void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
     178    { 
     179        if (kohde == oikeaReuna) 
     180        { 
     181            pelaajan1Pisteet.Value += 1; 
     182        } 
     183        else if (kohde == vasenReuna) 
     184        { 
     185            pelaajan2Pisteet.Value += 1; 
     186        } 
     187    } 
     188 
     189 
    150190} 
Note: See TracChangeset for help on using the changeset viewer.