Line | |
---|
1 | using System; |
---|
2 | using Jypeli; |
---|
3 | using Jypeli.Assets; |
---|
4 | using Jypeli.Controls; |
---|
5 | using Jypeli.Effects; |
---|
6 | using Jypeli.Widgets; |
---|
7 | |
---|
8 | public class Player : GenCharacter |
---|
9 | { |
---|
10 | int speed = 200; |
---|
11 | const int jumpSpeed = 1000; |
---|
12 | |
---|
13 | // Miten voidaan viitata Contentiin? |
---|
14 | //Image portrait = Game.LoadImage("character"); |
---|
15 | |
---|
16 | public Player(double width, double height, Shape shape) |
---|
17 | : base(width, height, shape) |
---|
18 | { |
---|
19 | hitPoints = 100; |
---|
20 | AddedToGame += addControls; |
---|
21 | //this.Image = portrait; |
---|
22 | } |
---|
23 | |
---|
24 | public void addControls() |
---|
25 | { |
---|
26 | Game.Keyboard.Listen(Key.Right, ButtonState.Down, moveRight, "Moves right", speed); |
---|
27 | Game.Keyboard.Listen(Key.Left, ButtonState.Down, moveLeft, "Moves left", speed); |
---|
28 | Game.Keyboard.Listen(Key.Up, ButtonState.Down, jump, "Jumps", jumpSpeed); |
---|
29 | } |
---|
30 | |
---|
31 | public void moveRight(int speed) |
---|
32 | { |
---|
33 | this.Walk(speed); |
---|
34 | } |
---|
35 | |
---|
36 | public void moveLeft(int speed) |
---|
37 | { |
---|
38 | this.Walk(-speed); |
---|
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.