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 Hypopolis : PhysicsGame |
---|
10 | { |
---|
11 | Image pelihahmo = LoadImage("Pelihahmo2"); |
---|
12 | |
---|
13 | Image taustakuva = LoadImage("Taustakuva"); |
---|
14 | Image taustakuvareuna = LoadImage("TaustakuvaReuna"); |
---|
15 | Image mustaruutu = LoadImage("Mustakuva"); |
---|
16 | |
---|
17 | PlatformCharacter2 pelaaja; |
---|
18 | |
---|
19 | Label tekstikentta; |
---|
20 | |
---|
21 | public override void Begin() |
---|
22 | { |
---|
23 | |
---|
24 | // Aloitus |
---|
25 | MustaRuutu(); |
---|
26 | |
---|
27 | // Musiikki |
---|
28 | MediaPlayer.Play("HypopolisTheme"); |
---|
29 | |
---|
30 | // Laskuri |
---|
31 | Timer ajastin = new Timer(); |
---|
32 | ajastin.Interval = 2.0; |
---|
33 | ajastin.Timeout += LuoSatunnainenRakennusVasemmalta; |
---|
34 | ajastin.Start(); |
---|
35 | |
---|
36 | // Pelaaja |
---|
37 | pelaaja = new PlatformCharacter2(75, 75); |
---|
38 | pelaaja.Shape = Shape.Rectangle; |
---|
39 | pelaaja.Color = Color.Black; |
---|
40 | pelaaja.X = 0; |
---|
41 | pelaaja.Y = Level.Bottom + 100.0; |
---|
42 | pelaaja.LinearDamping = 0.95; |
---|
43 | pelaaja.Restitution = 0.0; |
---|
44 | pelaaja.Image = mustaruutu; |
---|
45 | Gravity = new Vector(0, -2000); |
---|
46 | Add(pelaaja); |
---|
47 | |
---|
48 | // Aliohjelma |
---|
49 | Ohjaimet(); |
---|
50 | |
---|
51 | // Taso |
---|
52 | Surface vasenReuna = new Surface(500, 1200); |
---|
53 | vasenReuna.Restitution = 1.0; |
---|
54 | vasenReuna.X = -800; |
---|
55 | vasenReuna.IsVisible = false; |
---|
56 | vasenReuna.Color = Color.White; |
---|
57 | Add(vasenReuna); |
---|
58 | |
---|
59 | Surface oikeaReuna = new Surface(500, 1200); |
---|
60 | oikeaReuna.Restitution = 1.0; |
---|
61 | oikeaReuna.IsVisible = true; |
---|
62 | oikeaReuna.X = 825; |
---|
63 | oikeaReuna.Y = -1; |
---|
64 | oikeaReuna.Color = Color.White; |
---|
65 | oikeaReuna.Image = mustaruutu; |
---|
66 | Add(oikeaReuna, 2); |
---|
67 | |
---|
68 | Surface yläReuna = new Surface(1400, 100); |
---|
69 | yläReuna.Restitution = 1.0; |
---|
70 | yläReuna.Y = 550; |
---|
71 | yläReuna.IsVisible = false; |
---|
72 | yläReuna.Color = Color.White; |
---|
73 | Add(yläReuna); |
---|
74 | |
---|
75 | Surface alaReuna = new Surface(1400, 100); |
---|
76 | alaReuna.Restitution = 1.0; |
---|
77 | alaReuna.X = 0; |
---|
78 | alaReuna.Y = -515; |
---|
79 | alaReuna.IsVisible = false; |
---|
80 | alaReuna.Color = Color.White; |
---|
81 | Add(alaReuna); |
---|
82 | |
---|
83 | Level.Background.Image = mustaruutu; |
---|
84 | Level.BackgroundColor = Color.Black; |
---|
85 | |
---|
86 | // Poistuminen |
---|
87 | PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); |
---|
88 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli"); |
---|
89 | |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | void Kavele(PlatformCharacter2 pelaaja, Direction liike) |
---|
94 | { |
---|
95 | |
---|
96 | pelaaja.Walk(liike); |
---|
97 | |
---|
98 | } |
---|
99 | |
---|
100 | void Hyppy(PlatformCharacter2 pelaaja) |
---|
101 | { |
---|
102 | |
---|
103 | pelaaja.Jump(2000); |
---|
104 | |
---|
105 | } |
---|
106 | |
---|
107 | void Ohjaimet() |
---|
108 | { |
---|
109 | |
---|
110 | // Liike |
---|
111 | Keyboard.Listen(Key.Left, ButtonState.Down, Kavele, "Vasen", pelaaja, Direction.Left); |
---|
112 | Keyboard.Listen(Key.Right, ButtonState.Down, Kavele, "Oikea", pelaaja, Direction.Right); |
---|
113 | Keyboard.Listen(Key.Up, ButtonState.Down, Hyppy, "Ylös", pelaaja); |
---|
114 | |
---|
115 | } |
---|
116 | |
---|
117 | private void LuoSatunnainenRakennusVasemmalta() |
---|
118 | { |
---|
119 | |
---|
120 | double x = RandomGen.NextDouble(-1800, -1800); |
---|
121 | double y = RandomGen.NextDouble(-370, 400); |
---|
122 | double r = RandomGen.NextDouble(500, 2000); |
---|
123 | double r2 = RandomGen.NextDouble(100, 200); |
---|
124 | Color vari = RandomGen.NextColor(); |
---|
125 | LuoMuoto(Shape.Rectangle, x, y, r, r2, vari); |
---|
126 | |
---|
127 | } |
---|
128 | |
---|
129 | void LuoMuoto(Shape muoto, double x, double y, double sade, double sade2, Color vari) |
---|
130 | { |
---|
131 | |
---|
132 | PhysicsObject olio = new PhysicsObject(sade, sade2); |
---|
133 | olio.Shape = muoto; |
---|
134 | olio.Color = Color.OrangeRed; |
---|
135 | olio.Y = y; |
---|
136 | olio.X = x; |
---|
137 | olio.Move(new Vector(250, 0)); |
---|
138 | olio.MakeStatic(); |
---|
139 | Add(olio); |
---|
140 | |
---|
141 | } |
---|
142 | |
---|
143 | void MustaRuutu() |
---|
144 | { |
---|
145 | |
---|
146 | Label tekstikentta = new Label(2500, 2500, "Aloitus"); |
---|
147 | tekstikentta.X = 0; |
---|
148 | tekstikentta.Y = 0; |
---|
149 | tekstikentta.TextColor = Color.White; |
---|
150 | tekstikentta.Text = "Club Afterlife Presents_"; |
---|
151 | Add(tekstikentta); |
---|
152 | Timer ajastin = new Timer(); |
---|
153 | ajastin.Interval = 5; |
---|
154 | ajastin.Timeout += Aloitus; |
---|
155 | ajastin.Start(1); |
---|
156 | |
---|
157 | } |
---|
158 | |
---|
159 | void Aloitus() |
---|
160 | { |
---|
161 | |
---|
162 | MessageDisplay.Clear(); |
---|
163 | Timer ajastin = new Timer(); |
---|
164 | ajastin.Interval = 2; |
---|
165 | ajastin.Timeout += Aloitus1; |
---|
166 | ajastin.Start(1); |
---|
167 | |
---|
168 | } |
---|
169 | |
---|
170 | void Aloitus1() |
---|
171 | { |
---|
172 | |
---|
173 | MessageDisplay.Clear(); |
---|
174 | tekstikentta.Text = "Powered by XNA_"; |
---|
175 | |
---|
176 | } |
---|
177 | } |
---|