Revision 880,
1.3 KB
checked in by danmarti, 13 years ago
(diff) |
Aloitettiin Vantaa 2001. Lisättiin pelihahmo.
|
Line | |
---|
1 | using System; |
---|
2 | using Jypeli; |
---|
3 | using Jypeli.ScreenObjects; |
---|
4 | using Jypeli.Assets; |
---|
5 | |
---|
6 | public class Peli : PhysicsGame |
---|
7 | { |
---|
8 | PlatformCharacter Player; |
---|
9 | |
---|
10 | const double Speed = 200; |
---|
11 | const double JumpStr = 3000; |
---|
12 | |
---|
13 | protected override void Begin() |
---|
14 | { |
---|
15 | StartGame(); |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | void StartGame() |
---|
21 | { |
---|
22 | Gravity = new Vector(0, -1000); |
---|
23 | CreateLevel(); |
---|
24 | CreatePlayer(); |
---|
25 | Camera.Follow(Player); |
---|
26 | |
---|
27 | Controls(); |
---|
28 | } |
---|
29 | |
---|
30 | void CreatePlayer() |
---|
31 | { |
---|
32 | Player = new PlatformCharacter(30,60); |
---|
33 | Player.Mass = 4.0; |
---|
34 | Add(Player); |
---|
35 | Player.Color = Color.Black; |
---|
36 | Player.KineticFriction = 1.0; |
---|
37 | Player.StaticFriction = 0; |
---|
38 | |
---|
39 | } |
---|
40 | |
---|
41 | void CreateLevel() |
---|
42 | { |
---|
43 | Level.CreateBorders(); |
---|
44 | } |
---|
45 | |
---|
46 | void Controls() |
---|
47 | { |
---|
48 | Keyboard.Listen(Key.Left, ButtonState.Down, Walk, "Move left", Player, -Speed); |
---|
49 | Keyboard.Listen(Key.Right, ButtonState.Down, Walk, "Move right", Player, Speed); |
---|
50 | Keyboard.Listen(Key.Space, ButtonState.Down, Jump, "Jump", Player, JumpStr); |
---|
51 | } |
---|
52 | |
---|
53 | void Walk(PlatformCharacter Character, double Speed) |
---|
54 | { |
---|
55 | Character.Walk(Speed); |
---|
56 | } |
---|
57 | |
---|
58 | void Jump(PlatformCharacter Character, double JumpStr) |
---|
59 | { |
---|
60 | Character.Jump(JumpStr); |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.