Changeset 1987 for 2011


Ignore:
Timestamp:
2011-06-14 14:57:15 (12 years ago)
Author:
vievkang
Message:
 
Location:
2011/24/VilmaK
Files:
31 added
1 edited

Legend:

Unmodified
Added
Removed
  • 2011/24/VilmaK/Pong/Pong/Pong/Peli.cs

    r1973 r1987  
    1212    Vector nopeusYlos = new Vector(0, 200); 
    1313    Vector nopeusAlas = new Vector ( 0, -200); 
     14    PhysicsObject vasenReuna; 
     15    PhysicsObject oikeaReuna; 
     16 
    1417 
    1518    PhysicsObject pallo; 
    1619    PhysicsObject maila1; 
    1720    PhysicsObject maila2; 
     21    IntMeter pelaajan1Pisteet; 
     22    IntMeter pelaajan2Pisteet; 
     23 
    1824 
    1925    public override void Begin() 
     
    2531        AloitaPeli(); 
    2632        MessageDisplay.TextColor = Color.White; 
     33    } 
    2734        // TODO: Kirjoita ohjelmakoodisi tähän 
    2835 
    2936        void LisaaLaskurit() 
    3037        { 
    31             IntMeter 
     38            pelaajan1Pisteet = LuoPisteLaskuri ( Screen.Left + 100.0, Screen.Top -100.0); 
     39            pelaajan2Pisteet = LuoPisteLaskuri ( Screen.Right -100.0, Screen.Top -100.0); 
     40           
    3241        } 
    33  
    34  
    35  
    36  
    37  
    38  
    39  
    40  
    41  
    42  
    43  
    44  
    45  
     42    IntMeter LuoPisteLaskuri ( double x, double y) 
     43    { 
     44        IntMeter Laskuri = new IntMeter ( 0 ); 
     45        Laskuri.MaxValue = 10; 
     46        Label naytto = new Label(); 
     47        naytto.BindTo ( Laskuri ); 
     48        naytto. X = x; 
     49        naytto. Y = y; 
     50        naytto.TextColor = Color.White; 
     51        naytto.BorderColor = Level.BackgroundColor; 
     52        naytto.Color = Level.BackgroundColor; 
     53        Add ( naytto ); 
     54        return Laskuri; 
    4655    } 
     56     
    4757    
    4858    void LuoKentta() 
     
    5767        maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
    5868        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
     69        AddCollisionHandler(pallo, KasittelePallonTormays); 
    5970 
    6071 
    6172 
    62         Level.CreateBorders(1.0, false); 
    63         pallo.Restitution = 1.0; 
     73        vasenReuna = Level.CreateLeftBorder (); 
     74        vasenReuna.Restitution = 1.0; 
     75        vasenReuna.IsVisible = false; 
     76        oikeaReuna = Level.CreateRightBorder (); 
     77        oikeaReuna.Restitution = 1.0; 
     78        oikeaReuna.IsVisible = false; 
     79        PhysicsObject alaReuna = Level.CreateBottomBorder (); 
     80        alaReuna.Restitution = 1.0; 
     81        alaReuna.IsVisible = false; 
     82        PhysicsObject ylaReuna = Level.CreateTopBorder (); 
     83        ylaReuna.Restitution = 1.0 ; 
     84        ylaReuna.IsVisible = false; 
     85 
     86        pallo.Restitution = 1.0;  
    6487        Level.BackgroundColor = Color.Black; 
    6588        Camera.ZoomToLevel(); 
     89 
     90         
     91                
    6692        
    6793 
     
    119145 
    120146    } 
     147    void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
     148{ 
     149    if ( kohde == oikeaReuna ) 
     150{ 
     151    pelaajan1Pisteet. Value  += 1; 
     152} 
     153else if ( kohde == vasenReuna ) 
     154{ 
     155pelaajan2Pisteet. Value  += 1; 
     156} 
    121157 
    122158 
     159} 
    123160 
    124161 
Note: See TracChangeset for help on using the changeset viewer.