Line | |
---|
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 FysiikkaPeli1 : PhysicsGame |
---|
10 | { |
---|
11 | PhysicsObject raketti; |
---|
12 | public override void Begin() |
---|
13 | { |
---|
14 | luoraketti(); |
---|
15 | LuoKentta(); |
---|
16 | |
---|
17 | LuoOhjaimet(); |
---|
18 | } |
---|
19 | |
---|
20 | void luoraketti() |
---|
21 | { |
---|
22 | raketti = new PhysicsObject(80, 30); |
---|
23 | raketti.Shape = Shape.Hexagon; |
---|
24 | raketti.Angle = Angle.FromDegrees(90); |
---|
25 | Add(raketti); |
---|
26 | raketti.Color = Color.Black; |
---|
27 | raketti.Y = -300.0; |
---|
28 | raketti.X = -580.0; |
---|
29 | } |
---|
30 | |
---|
31 | void LuoKentta() |
---|
32 | { |
---|
33 | Level.Background.Color = Color.White; |
---|
34 | TileMap kentta = TileMap.FromLevelAsset("Kentta1"); |
---|
35 | |
---|
36 | kentta.SetTileMethod('#', LisaaTaso); |
---|
37 | kentta.Execute(); |
---|
38 | |
---|
39 | } |
---|
40 | void LisaaTaso(Vector paikka, double leveys, double korkeus) |
---|
41 | { |
---|
42 | PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); |
---|
43 | taso.Position = paikka; |
---|
44 | taso.Color = Color.Blue; |
---|
45 | Add(taso); |
---|
46 | } |
---|
47 | void LuoOhjaimet() |
---|
48 | { |
---|
49 | PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); |
---|
50 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
51 | Keyboard.Listen(Key.Right, ButtonState.Down, kaanna, "",- 1.0); |
---|
52 | Keyboard.Listen(Key.Left, ButtonState.Down, kaanna, "", 1.0); |
---|
53 | |
---|
54 | |
---|
55 | } |
---|
56 | |
---|
57 | void kaanna(double turn) |
---|
58 | { |
---|
59 | raketti.Angle += Angle.FromDegrees(turn); |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.