using System; using Jypeli; using Jypeli.Assets; using Jypeli.Controls; using Jypeli.Effects; using Jypeli.Widgets; public class Player : GenCharacter { int speed = 200; const int jumpSpeed = 1000; // Miten voidaan viitata Contentiin? Image portrait = Game.LoadImage("character.png"); public Player(double width, double height, Shape shape) : base(width, height, shape) { hitPoints = 100; AddedToGame += addControls; this.Image = portrait; } public void addControls() { Game.Keyboard.Listen(Key.Right, ButtonState.Down, moveRight, "Moves right", speed); Game.Keyboard.Listen(Key.Left, ButtonState.Down, moveLeft, "Moves left", speed); Game.Keyboard.Listen(Key.Up, ButtonState.Down, jump, "Jumps", jumpSpeed); } public void moveRight(int speed) { this.Walk(speed); } public void moveLeft(int speed) { this.Walk(-speed); } public void jump(int jumpSpeed) { this.Jump(jumpSpeed); } }