Changeset 7540 for 2016/26


Ignore:
Timestamp:
2016-06-28 10:57:18 (7 years ago)
Author:
jonnurmi
Message:
 
Location:
2016/26/JonniN/Pong8)
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2016/26/JonniN/Pong8)/Pong8)/Pong8_/Pong8_.cs

    r7529 r7540  
    1313 
    1414    PhysicsObject pallo; 
    15  
     15    IntMeter laskuri; 
    1616    PhysicsObject maila1; 
    1717    PhysicsObject maila2; 
     
    5858 
    5959        pallo.Restitution = 1.0; 
    60         Level.Background.Color = Color.Black; 
     60        Level.Background.Color = Color.DarkAzure; 
    6161        pallo.Color = Color.Yellow; 
    6262 
     
    130130        pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 
    131131        pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
     132        pelaajan1Pisteet.UpperLimit += NollaaLaskuri; 
     133        pelaajan2Pisteet.UpperLimit += NollaaLaskuri; 
    132134 
    133135    } 
     
    142144            pelaajan2Pisteet.Value += 1; 
    143145        } 
     146         
     147    } 
     148    const double PALLON_MIN_NOPEUS = 500; 
     149     
     150    protected override void Update(Time time) 
     151    { 
     152        if(pallo !=null && Math.Abs(pallo.Velocity.X) < PALLON_MIN_NOPEUS) 
     153        { 
     154            pallo.Velocity = new Vector(pallo.Velocity.X * 1.1, pallo.Velocity.Y); 
     155        } 
     156        base.Update(time); 
     157    } 
     158    void NollaaLaskuri() 
     159    { 
     160        pelaajan1Pisteet.Value = 0; 
     161        pelaajan2Pisteet.Value = 0; 
     162    } 
     163    void VoittoViesti1(int voittaja) 
     164    { 
     165        if (voittaja == 1) 
     166        { 
     167            MessageDisplay.Add("Pelaaja 1 voitti!"); 
     168        } 
     169        else 
     170        { 
     171            MessageDisplay.Add("Pelaaja 2 voitti!"); 
     172        } 
     173 
    144174    } 
    145175} 
Note: See TracChangeset for help on using the changeset viewer.