Changeset 6175


Ignore:
Timestamp:
2015-06-23 13:35:07 (8 years ago)
Author:
empaheik
Message:
 
Location:
2015/26/RonjaT/Pong
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2015/26/RonjaT/Pong/Pong/Pong/Pong.cs

    r6166 r6175  
    1717    PhysicsObject maila2; 
    1818 
     19    PhysicsObject vasenReuna; 
     20    PhysicsObject oikeaReuna; 
     21 
    1922    IntMeter pelaajan1pisteet; 
    2023    IntMeter pelaajan2pisteet; 
     
    2427        LuoKentta(); 
    2528        AsetaOhjaimet(); 
    26  
    2729        LisaaLaskurit(); 
    2830        AloitaPeli(); 
     
    3234    { 
    3335        pallo = new PhysicsObject(40.0, 40.0); 
    34  
    3536        pallo.Shape = Shape.Circle; 
    3637        pallo.X = -200.0; 
     
    3839        pallo.Restitution = 1.0; 
    3940        Add(pallo); 
     41        AddCollisionHandler(pallo, KasittelePallonTormays); 
     42 
     43         
     44 
     45        maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
     46        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
     47 
     48 
     49       vasenReuna = Level.CreateLeftBorder(); 
     50       vasenReuna.Restitution = 1.0; 
     51       vasenReuna.IsVisible = false; 
     52 
     53       oikeaReuna = Level.CreateRightBorder(); 
     54       oikeaReuna.Restitution = 1.0; 
     55       oikeaReuna.IsVisible = false; 
     56 
     57       PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     58       alaReuna.Restitution = 1.0; 
     59       alaReuna.IsVisible = false; 
     60       alaReuna.KineticFriction = 0.0; 
     61 
     62       PhysicsObject yläReuna = Level.CreateTopBorder(); 
     63       yläReuna.Restitution = 1.0; 
     64       yläReuna.IsVisible = false; 
     65  
     66 
     67        Level.Background.Color = Color.Black; 
     68        Camera.ZoomToLevel(); 
     69    } 
    4070 
    4171        void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
    4272        { 
     73            if (kohde == oikeaReuna) 
     74            { 
     75                pelaajan1pisteet.Value += 1; 
     76            } 
     77            else if (kohde == vasenReuna) 
     78            { 
     79                pelaajan2pisteet.Value += 1; 
     80            } 
    4381        } 
    44  
    45         maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
    46         maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
    47  
    48  
    49        PhysicsObject vasenReuna = Level.CreateLeftBorder(); 
    50        vasenReuna.Restution = 1.0; 
    51        vasenReuna.IsVisible = flase; 
    52  
    53        PhysicsObject  
    54  
    55         Level.Background.Color = Color.Black; 
    56         Camera.ZoomToLevel(); 
    57     } 
    58  
    5982    void AloitaPeli() 
    6083    { 
Note: See TracChangeset for help on using the changeset viewer.