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 Dreamcast : PhysicsGame |
---|
10 | { |
---|
11 | |
---|
12 | public override void Begin() |
---|
13 | { |
---|
14 | CreateLevel(); |
---|
15 | |
---|
16 | |
---|
17 | |
---|
18 | // TODO: Kirjoita ohjelmakoodisi tähän |
---|
19 | |
---|
20 | PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); |
---|
21 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
22 | } |
---|
23 | void CreateLevel() |
---|
24 | { |
---|
25 | TileMap boxes = TileMap.FromLevelAsset ("Hassebproject"); |
---|
26 | boxes.SetTileMethod('i', Obstacles ); |
---|
27 | boxes.SetTileMethod('W', Wall); |
---|
28 | boxes.SetTileMethod('#', Ground); |
---|
29 | boxes.SetTileMethod('C', Characters); |
---|
30 | boxes.Execute(20, 20); |
---|
31 | |
---|
32 | } |
---|
33 | void Obstacles(Vector place, double width, double height) |
---|
34 | { |
---|
35 | PhysicsObject obstacles = PhysicsObject.CreateStaticObject(width, height); |
---|
36 | obstacles.Position = place; |
---|
37 | obstacles.Shape = Shape.Rectangle; |
---|
38 | obstacles.Color = Color.GreenYellow; |
---|
39 | obstacles.CollisionIgnoreGroup = 1; |
---|
40 | Add(obstacles); |
---|
41 | } |
---|
42 | |
---|
43 | void Wall(Vector place, double width, double height) |
---|
44 | { |
---|
45 | PhysicsObject wall = PhysicsObject.CreateStaticObject(width, height); |
---|
46 | wall.Position = place; |
---|
47 | wall.Shape = Shape.Rectangle; |
---|
48 | wall.Color = Color.Brown; |
---|
49 | wall.CollisionIgnoreGroup = 1; |
---|
50 | Add(wall); |
---|
51 | } |
---|
52 | void Ground(Vector place, double width, double height) |
---|
53 | { |
---|
54 | PhysicsObject ground = PhysicsObject.CreateStaticObject(width, height); |
---|
55 | ground.Position = place; |
---|
56 | ground.Color = Color.Gray; |
---|
57 | ground.Shape = Shape.Rectangle; |
---|
58 | ground.CollisionIgnoreGroup = 1; |
---|
59 | Add(ground); |
---|
60 | } |
---|
61 | void Characters(Vector place, double height, double width) |
---|
62 | { |
---|
63 | PhysicsObject characters = PhysicsObject.CreateStaticObject(width, height); |
---|
64 | characters.Position = place; |
---|
65 | characters.Color = Color.Red; |
---|
66 | characters.Shape = Shape.Rectangle; |
---|
67 | characters.CollisionIgnoreGroup = 1; |
---|
68 | Add(characters); |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | } |
---|