Changeset 4236


Ignore:
Timestamp:
2013-06-26 14:52:28 (10 years ago)
Author:
miktiili
Message:

Talletus.

Location:
2013/26/MikkoTi
Files:
82 added
1 edited

Legend:

Unmodified
Added
Removed
  • 2013/26/MikkoTi/Pong/Pong/Pong/Pong.cs

    r4195 r4236  
    99public class Pong : PhysicsGame 
    1010{ 
    11     Vector nopeusYlös = new Vector(0, 200); 
    12     Vector nopeusAlas = new Vector(0, -200); 
     11    Vector nopeusYlös = new Vector(0, 500); 
     12    Vector nopeusAlas = new Vector(0, -500); 
    1313 
    1414    PhysicsObject Pallo; 
    1515    PhysicsObject Maila1; 
    1616    PhysicsObject Maila2; 
     17 
     18    PhysicsObject vasenReuna; 
     19    PhysicsObject oikeaReuna; 
    1720 
    1821    IntMeter pelaajan1Pisteet; 
     
    2730        LisaaLaskurit(); 
    2831        AloitaPeli(); 
    29  
     32        
    3033    } 
    3134 
     
    3740        Pallo.X = 200.0; 
    3841        Pallo.Y = 0.0; 
    39         Pallo.Restitution = 1.0; 
     42        Pallo.MomentOfInertia = Double.PositiveInfinity; 
     43        Pallo.Restitution = 3.0; 
     44        AddCollisionHandler(Pallo, KasittelePallonTormays); 
    4045 
    4146        Maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
    4247        Maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
    4348 
    44         Level.CreateBorders(1.0, false); 
     49        vasenReuna = Level.CreateLeftBorder(); 
     50        vasenReuna.Restitution = 1.0; 
     51        vasenReuna.KineticFriction = 0.0; 
     52        vasenReuna.IsVisible = false; 
     53 
     54        oikeaReuna = Level.CreateRightBorder(); 
     55        oikeaReuna.Restitution = 1.0; 
     56        oikeaReuna.KineticFriction = 0.0; 
     57        oikeaReuna.IsVisible = false; 
     58 
     59        PhysicsObject ylaReuna = Level.CreateTopBorder(); 
     60        ylaReuna.Restitution = 1.0; 
     61        ylaReuna.KineticFriction = 0.0; 
     62        ylaReuna.IsVisible = false; 
     63 
     64        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     65        alaReuna.Restitution = 1.0; 
     66        alaReuna.KineticFriction = 0.0; 
     67        alaReuna.IsVisible = false; 
     68         
    4569        Level.BackgroundColor = Color.Black; 
    4670 
     
    7094            pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
    7195        } 
     96    void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
     97    { 
     98        if (kohde == oikeaReuna) 
     99        { 
     100            pelaajan1Pisteet.Value += 1; 
     101        } 
     102        else if (kohde == vasenReuna) 
     103        { 
     104            pelaajan2Pisteet.Value += 1; 
     105        } 
     106    } 
     107 
     108 
     109 
    72110    IntMeter LuoPisteLaskuri(double x, double y) 
    73111    { 
Note: See TracChangeset for help on using the changeset viewer.