1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using Jypeli; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Controls; |
---|
6 | using Jypeli.Effects; |
---|
7 | using Jypeli.Widgets; |
---|
8 | |
---|
9 | public class Impossible : PhysicsGame |
---|
10 | { |
---|
11 | double moveSpeed = 250; |
---|
12 | bool allowMove = false; |
---|
13 | |
---|
14 | PhysicsObject cube; |
---|
15 | |
---|
16 | public override void Begin() |
---|
17 | { |
---|
18 | IsMouseVisible = true; |
---|
19 | Camera.ZoomToLevel(); |
---|
20 | Level.BackgroundColor = Color.Black; |
---|
21 | |
---|
22 | PushButton startButton = new PushButton("Start"); |
---|
23 | startButton.Clicked += new Action(startGame); |
---|
24 | Add(startButton); |
---|
25 | |
---|
26 | PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); |
---|
27 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
28 | } |
---|
29 | |
---|
30 | protected override void Update(Time time) |
---|
31 | { |
---|
32 | base.Update(time); |
---|
33 | |
---|
34 | if (allowMove == true) { move(); } |
---|
35 | } |
---|
36 | |
---|
37 | void startGame() |
---|
38 | { |
---|
39 | ClearAll(); |
---|
40 | Level.CreateBorders(); |
---|
41 | Level.Background.Image = LoadImage("backround"); |
---|
42 | Keyboard.Listen(Key.Space, ButtonState.Down, jump, null); |
---|
43 | |
---|
44 | Gravity = new Vector(0, -5000); |
---|
45 | |
---|
46 | cube = new PhysicsObject(25, 25); |
---|
47 | cube.Shape = Shape.Rectangle; |
---|
48 | cube.Position = new Vector(Level.Left + 25 / 2 + 4, Level.Bottom + 25 / 2 + 4); |
---|
49 | Add(cube); |
---|
50 | allowMove = true; |
---|
51 | Camera.Follow(cube); |
---|
52 | } |
---|
53 | |
---|
54 | void move() |
---|
55 | { |
---|
56 | cube.Move(new Vector(moveSpeed, 0)); |
---|
57 | } |
---|
58 | |
---|
59 | void jump() |
---|
60 | { |
---|
61 | cube.Hit(new Vector(0, 1000)); |
---|
62 | } |
---|
63 | |
---|
64 | void createExplosion(Vector position) |
---|
65 | { |
---|
66 | Explosion explosion = new Explosion(100); |
---|
67 | explosion.Position = position; |
---|
68 | Add(explosion); |
---|
69 | } |
---|
70 | } |
---|