Changeset 3708 for 2012


Ignore:
Timestamp:
2012-07-24 11:24:16 (11 years ago)
Author:
anlakane
Message:

Talletus.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2012/30/AnttiS/pong/pong/pong/pong.cs

    r3706 r3708  
    1616    PhysicsObject maila1; 
    1717    PhysicsObject maila2; 
     18 
     19    IntMeter pelaajan1Pisteet; 
     20    IntMeter pelaajan2Pisteet; 
     21 
     22    PhysicsObject vasenreuna; 
     23    PhysicsObject oikeareuna; 
    1824  
    1925 
     
    2430        AsetaOhjaimet(); 
    2531        Aloitapeli(); 
     32        LisaaLaskurit(); 
     33         
    2634    } 
    2735    void Luokentta() 
     
    3745        maila2 = Luomaila(Level.Right - 20.0, 0.0); 
    3846 
    39         Level.CreateBorders(1.0, false); 
     47        vasenreuna = Level.CreateLeftBorder(); 
     48        vasenreuna.Restitution = 1.0; 
     49        vasenreuna.KineticFriction = 0.0; 
     50        vasenreuna.IsVisible = false; 
     51              
     52        oikeareuna = Level.CreateRightBorder(); 
     53        oikeareuna.Restitution = 1.0; 
     54        oikeareuna.KineticFriction = 0.0; 
     55        oikeareuna.IsVisible = false; 
     56 
     57        PhysicsObject ylaReuna = Level.CreateTopBorder(); 
     58        ylaReuna.Restitution = 1.0; 
     59        ylaReuna.KineticFriction = 0.0; 
     60        ylaReuna.IsVisible = false; 
     61 
     62        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     63        alaReuna.Restitution = 1.0; 
     64        alaReuna.IsVisible = false; 
     65        alaReuna.KineticFriction = 0.0; 
     66 
     67 
     68 
    4069        Level.BackgroundColor = Color.Blue; 
     70 
     71        AddCollisionHandler (pallo, KasittelePallonTormays); 
    4172    } 
    4273    void Aloitapeli() 
     
    90121        maila.Velocity = nopeus; 
    91122    } 
     123    void LisaaLaskurit() 
     124    { 
     125        pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 
     126        pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
     127    } 
     128    IntMeter LuoPisteLaskuri(double x, double y) 
     129    { 
     130        IntMeter laskuri = new IntMeter ( 0 ); 
     131        laskuri.MaxValue = 10; 
     132 
     133        Label naytto = new Label(); 
     134        naytto.BindTo(laskuri); 
     135        naytto.X = x; 
     136        naytto.Y = y; 
     137        naytto.TextColor = Color.Yellow ; 
     138        naytto.BorderColor = Level.BackgroundColor; 
     139        naytto.Color = Level.BackgroundColor; 
     140        Add(naytto); 
     141 
     142        return laskuri; 
     143    } 
     144    void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
     145    { 
     146        if (kohde == oikeareuna) 
     147        { 
     148            pelaajan1Pisteet.Value += 1; 
     149        } 
     150        else if (kohde == vasenreuna) 
     151        { 
     152            pelaajan2Pisteet.Value += 1; 
     153        } 
     154 
     155    } 
    92156 
    93157} 
Note: See TracChangeset for help on using the changeset viewer.