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 | using System.Collections.Generic; |
---|
9 | using Jypeli.Controls; |
---|
10 | |
---|
11 | public class Peli : PhysicsGame |
---|
12 | { |
---|
13 | |
---|
14 | Image taustakuva = LoadImage("SpaceJAText_Modified"); |
---|
15 | List<Label> valikonKohdat; |
---|
16 | PhysicsObject alus1; |
---|
17 | PhysicsObject alus2; |
---|
18 | |
---|
19 | |
---|
20 | public override void Begin() |
---|
21 | { |
---|
22 | // TODO: Kirjoita ohjelmakoodisi tähän |
---|
23 | Valikko(); |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | } |
---|
28 | void Valikko() |
---|
29 | { |
---|
30 | ClearAll(); |
---|
31 | valikonKohdat = new List<Label>(); |
---|
32 | |
---|
33 | Label kohta1 = new Label("Aloita uusi peli"); |
---|
34 | kohta1.Position = new Vector(0, 40); |
---|
35 | valikonKohdat.Add(kohta1); |
---|
36 | |
---|
37 | Label kohta2 = new Label("Lopeta"); |
---|
38 | kohta2.Position = new Vector(0, -40); |
---|
39 | valikonKohdat.Add(kohta2); |
---|
40 | |
---|
41 | foreach (Label valikonKohta in valikonKohdat) |
---|
42 | { |
---|
43 | Add(valikonKohta); |
---|
44 | } |
---|
45 | |
---|
46 | Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); |
---|
47 | Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); |
---|
48 | |
---|
49 | Mouse.IsCursorVisible = true; |
---|
50 | Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); |
---|
51 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); |
---|
52 | |
---|
53 | } |
---|
54 | void ValikossaLiikkuminen(AnalogState Hiirentila) |
---|
55 | { |
---|
56 | foreach (Label kohta in valikonKohdat) |
---|
57 | { |
---|
58 | if (Mouse.IsCursorOn(kohta)) |
---|
59 | { |
---|
60 | kohta.TextColor = Color.Red; |
---|
61 | } |
---|
62 | else |
---|
63 | { |
---|
64 | kohta.TextColor = Color.Black; |
---|
65 | } |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | void AloitaPeli() |
---|
70 | { |
---|
71 | ClearAll(); |
---|
72 | // Tähän tulee kaikki kentän luomiset ym. alustukset... |
---|
73 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); |
---|
74 | Level.Background.Image = taustakuva; |
---|
75 | Level.Background.FitToLevel(); |
---|
76 | alus1 = new PhysicsObject(50.0, 50.0); |
---|
77 | alus2 = new PhysicsObject(50.0, 50.0); |
---|
78 | } |
---|
79 | } |
---|