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

Revision 2261, 1.1 KB 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    int speed = 200;
11    const int jumpSpeed = 1000;
12    Image portrait = Game.LoadImage("Images/character");
13
14        public Player(double width, double height, Shape shape)
15        : base(width, height, shape)
16        {
17        hitPoints = 100;
18        AddedToGame += addControls;
19        this.Image = portrait;
20        }
21
22    public void addControls()
23    {
24        Game.Keyboard.Listen(Key.Right, ButtonState.Down, moveRight, "Moves right", speed);
25        Game.Keyboard.Listen(Key.Left, ButtonState.Down, moveLeft, "Moves left", speed);
26        Game.Keyboard.Listen(Key.Up, ButtonState.Down, jump, "Jumps", jumpSpeed);
27    }
28
29    public void moveRight(int speed)
30    {
31        this.Walk(speed);
32        //this.Image = Image.Mirror(portrait);
33    }
34
35    public void moveLeft(int speed)
36    {
37        this.Walk(-speed);
38        this.Image = Image.Mirror(portrait);
39    }
40
41    public void jump(int jumpSpeed)
42    {
43        this.Jump(jumpSpeed);
44    }
45
46}
Note: See TracBrowser for help on using the repository browser.