source: 2011/26/HenriH/Alien Empire/Alien Empire/Alien Empire/Peli.cs @ 2230

Revision 2230, 2.1 KB checked in by jahebahu, 12 years ago (diff)

Talletus.

Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8using System.Collections.Generic;
9using Jypeli.Controls;
10
11public 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}
Note: See TracBrowser for help on using the repository browser.