source: 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/Player.cs @ 2222

Revision 2222, 1002 bytes checked in by teeevasa, 8 years ago (diff)

Talletus.

Line 
1using System;
2using Jypeli;
3using Jypeli.Assets;
4using Jypeli.Controls;
5using Jypeli.Effects;
6using Jypeli.Widgets;
7
8public class Player : GenCharacter
9{
10    const int speed = 200;
11    const int jumpSpeed = 1000;
12    Image portrait = Game.LoadImage("character.png");
13
14        public Player(double width, double height, Shape shape)
15        : base(width, height, shape)
16        {
17        hitPoints = 100;
18        addControls();
19        }
20
21    public void addControls()
22    {
23        Game.Keyboard.Listen(Key.Right, ButtonState.Down, moveRight, "Moves right", speed);
24        Game.Keyboard.Listen(Key.Left, ButtonState.Down, moveLeft, "Moves left", speed);
25        Game.Keyboard.Listen(Key.Up, ButtonState.Down, jump, "Jumps", jumpSpeed);
26    }
27
28    public void moveRight(int speed)
29    {
30        this.Walk(speed);
31    }
32
33    public void moveLeft(int speed)
34    {
35        this.Walk(-speed);
36    }
37
38    public void jump(int jumpSpeed)
39    {
40        this.Jump(jumpSpeed);
41    }
42
43}
Note: See TracBrowser for help on using the repository browser.