Ignore:
Timestamp:
2015-06-29 16:51:35 (6 years ago)
Author:
sieerinn
Message:

Uusi testikenttä. Osa tiilistä voi olla PhysicsObjecteja?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs

    r6536 r6538  
    77using Jypeli.Widgets; 
    88 
     9class Creature : PhysicsObject 
     10{ 
     11    public double MovementSpeed { get; set; } 
     12 
     13    public Creature(double width, double height) 
     14        : base(width, height) 
     15    { 
     16        LinearDamping = 0.5; 
     17    } 
     18 
     19    public void Move(Direction direction) 
     20    { 
     21        Push(direction.GetVector() * MovementSpeed); 
     22    } 
     23} 
     24 
    925public partial class TheLegendOfGabriel : PhysicsGame 
    1026{ 
     27    public const int TILE_SIZE = 20; 
     28 
     29    private Creature player; 
     30 
    1131    public override void Begin() 
    1232    { 
     
    1838    { 
    1939        ClearAll(); 
    20         CreateLevel("testlevel"); 
     40        CreateLevel("testlevel2"); 
     41        CreatePlayer(new Vector(30, -30)); 
    2142        SetControls(); 
    2243        Camera.ZoomToLevel(); 
     
    2546    void SetControls() 
    2647    { 
     48        Keyboard.Listen(Key.Left, ButtonState.Down, player.Move, null, Direction.Left); 
     49        Keyboard.Listen(Key.Right, ButtonState.Down, player.Move, null, Direction.Right); 
     50        Keyboard.Listen(Key.Up, ButtonState.Down, player.Move, null, Direction.Up); 
     51        Keyboard.Listen(Key.Down, ButtonState.Down, player.Move, null, Direction.Down); 
     52 
    2753        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 
    2854    } 
Note: See TracChangeset for help on using the changeset viewer.