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

Revision 2245, 1.1 KB checked in by teeevasa, 10 years ago (diff)

Talletus.

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