Changeset 7736 for 2016/27


Ignore:
Timestamp:
2016-07-04 17:55:43 (3 years ago)
Author:
empaheik
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/ohjaajat/VenienteFragore/VenienteFragore/VenienteFragore/VenienteFragore.cs

    r7735 r7736  
    139139        Add(advenA); 
    140140 
    141         Keyboard.ListenWSAD(ButtonState.Down, Liikuta, "hurdur"); 
    142  
    143     } 
    144  
    145     void Liikuta(Vector suunta) 
    146     { 
    147         if(suunta.Y > 0) 
    148         { 
    149             Jump(advenA); 
    150         } 
    151         advenA.Walk(suunta.X * 200); 
     141        Keyboard.Listen(Key.Right, ButtonState.Down, Walk, null, advenA, 200.0); 
     142        Keyboard.Listen(Key.Left, ButtonState.Down, Walk, null, advenA, -200.0); 
     143        Keyboard.Listen(Key.Up, ButtonState.Down, Jump, null, advenA); 
     144        Keyboard.Listen(Key.Down, ButtonState.Pressed, Crouch, null, advenA, true); 
     145        Keyboard.Listen(Key.Down, ButtonState.Released, Crouch, null, advenA, false); 
     146        Keyboard.Listen(Key.R, ButtonState.Pressed, () => { ClearAll(); Begin(); }, "Lopeta peli"); 
     147        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     148    } 
     149 
     150    void Walk(Player pelaaja, double nopeus) 
     151    { 
     152        pelaaja.Walk(nopeus); 
    152153    } 
    153154 
     
    156157        if (player.IsGrounded) 
    157158            player.Velocity = new Vector(player.Velocity.X, 500); 
     159    } 
     160 
     161    private void Crouch(Player player, bool crouch) 
     162    { 
     163        player.Crouch = crouch; 
    158164    } 
    159165 
Note: See TracChangeset for help on using the changeset viewer.