source: 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs @ 6538

Revision 6538, 1.4 KB checked in by sieerinn, 4 years ago (diff)

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

Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8
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
25public partial class TheLegendOfGabriel : PhysicsGame
26{
27    public const int TILE_SIZE = 20;
28
29    private Creature player;
30
31    public override void Begin()
32    {
33        SmoothTextures = false;
34        StartGame();
35    }
36
37    private void StartGame()
38    {
39        ClearAll();
40        CreateLevel("testlevel2");
41        CreatePlayer(new Vector(30, -30));
42        SetControls();
43        Camera.ZoomToLevel();
44    }
45
46    void SetControls()
47    {
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
53        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null);
54    }
55}
Note: See TracBrowser for help on using the repository browser.