Changeset 7782


Ignore:
Timestamp:
2016-07-05 14:28:36 (7 years ago)
Author:
karkaite
Message:
 
Location:
2016/27/OnniK/Pong
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/OnniK/Pong/Pong/Pong/Pong.cs

    r7758 r7782  
    1616    PhysicsObject maila1; 
    1717    PhysicsObject maila2; 
     18 
     19    IntMeter pelaajan1Pisteet; 
     20    IntMeter pelaajan2Pisteet; 
    1821    public override void Begin() 
    1922    { 
     
    5154        return maila; 
    5255    } 
     56    void KasittelePallonTormaus(PhysicsObject pallo, PhysicsObject kohde) 
     57    { 
     58        if (kohde == oikeaReuna) 
     59 
     60         
     61            pelaajan1Pisteet.Value += 1; 
     62 
     63 
    5364    void LuoKentta() 
    5465    { 
     
    6576 
    6677 
    67         Level.CreateBorders(1.0, false); 
     78        PhysicsObject vasenReuna = Level.CreateLeftBorder(); 
     79        vasenReuna.Restitution = 1.0; 
     80        vasenReuna.IsVisible = false; 
     81 
     82        PhysicsObject oikeaReuna = Level.CreateRightBorder(); 
     83        oikeaReuna.Restitution = 1.0; 
     84        oikeaReuna.IsVisible = false; 
     85 
     86        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     87        alaReuna.Restitution = 1.0; 
     88        alaReuna.IsVisible = false; 
     89 
     90        PhysicsObject yläReuna = Level.CreateTopBorder(); 
     91        yläReuna.Restitution = 1.0; 
     92        yläReuna.IsVisible = false; 
     93 
    6894        Level.Background.Color = Color.Black; 
    6995 
    7096        Camera.ZoomToLevel(); 
     97    AddCollisionHandler(pallo, KasittelePallonTormaus);  
    7198    } 
    7299    void AloitaPeli() 
     
    98125    void LisaaLaskurit() 
    99126    { 
     127        pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 
     128        pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
    100129 
    101         IntMeter LuoPisteLaskuri() 
    102             { 
    103             IntMeter laskuri = new IntMeter(0); 
    104             laskuri.MaxValue = 10; 
    105             return laskuri; 
    106  
    107         } 
     130         
    108131 
    109132 
     
    111134 
    112135    } 
     136    IntMeter LuoPisteLaskuri(double x, double y) 
     137    { 
     138        IntMeter laskuri = new IntMeter(0); 
     139        laskuri.MaxValue = 10; 
     140 
     141        Label naytto = new Label(); 
     142        naytto.BindTo(laskuri); 
     143        naytto.X = x; 
     144        naytto.Y = y; 
     145        naytto.TextColor = Color.White; 
     146        naytto.BorderColor = Level.Background.Color; 
     147                naytto.Color = Level.Background.Color; 
     148        Add(naytto); 
     149        return laskuri; 
     150 
     151         
     152    } 
    113153} 
    114154     
Note: See TracChangeset for help on using the changeset viewer.