Revision 871,
1.4 KB
checked in by vehakala, 13 years ago
(diff) |
Oma peli hyvässä vaiheessa! ;DDD
|
Line | |
---|
1 | using System; |
---|
2 | using Jypeli; |
---|
3 | using Jypeli.ScreenObjects; |
---|
4 | using Jypeli.Assets; |
---|
5 | |
---|
6 | public class Peli : PhysicsGame |
---|
7 | { |
---|
8 | PhysicsObject pelaaja; |
---|
9 | |
---|
10 | protected override void Begin() |
---|
11 | { |
---|
12 | LuoKentta(); |
---|
13 | LisaaPelaaja(); |
---|
14 | AsetaOhjaimet(); |
---|
15 | |
---|
16 | } |
---|
17 | |
---|
18 | void LuoKentta() |
---|
19 | { |
---|
20 | Level.Width = 1024; |
---|
21 | Level.Height = 768; |
---|
22 | Level.CreateBorders(1.0, false); // Laitetaan kentälle näkyvät reunat |
---|
23 | Level.Background.Image = LoadImage("lamaritausta"); |
---|
24 | Level.Background.Size = new Vector(Level.Width, 513.0/828.0*Level.Width); |
---|
25 | Level.BackgroundColor = Color.White; |
---|
26 | Camera.ZoomToLevel(0.0); |
---|
27 | } |
---|
28 | |
---|
29 | void LisaaPelaaja() |
---|
30 | { |
---|
31 | pelaaja = new PhysicsObject(30.0, 30.0); |
---|
32 | pelaaja.Image = LoadImage("testiukko"); |
---|
33 | Add(pelaaja); |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | void AsetaOhjaimet() |
---|
38 | { |
---|
39 | Keyboard.Listen(Key.Right, ButtonState.Down, Kaanny, "Käännä pelaajaa", Angle.Degrees(-2)); |
---|
40 | Keyboard.Listen(Key.Left, ButtonState.Down, Kaanny, "Käännä pelaajaa", Angle.Degrees(2)); |
---|
41 | Keyboard.Listen(Key.Up, ButtonState.Down, Eteenpain, "Luistele eteenpain"); |
---|
42 | } |
---|
43 | |
---|
44 | void Kaanny(Angle kulma) |
---|
45 | { |
---|
46 | pelaaja.Angle += kulma; |
---|
47 | } |
---|
48 | void Eteenpain() |
---|
49 | { |
---|
50 | |
---|
51 | |
---|
52 | pelaaja.Push(Vector.FromLengthAndAngle(500.0, pelaaja.Angle)); |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.