1 | using System; |
---|
2 | using Jypeli; |
---|
3 | using Jypeli.Widgets; |
---|
4 | using Jypeli.Assets; |
---|
5 | |
---|
6 | public class Peli : PhysicsGame |
---|
7 | { |
---|
8 | PlatformCharacter p1; |
---|
9 | PlatformCharacter p2; |
---|
10 | |
---|
11 | |
---|
12 | const int ruudunLeveys = 32; |
---|
13 | const int ruudunKorkeus = 32; |
---|
14 | |
---|
15 | protected override void Begin() |
---|
16 | { |
---|
17 | LuoKentta(); |
---|
18 | AloitaPeli(); |
---|
19 | IsFullScreen = true; |
---|
20 | p1 = LuoHahmo(); |
---|
21 | Add(p1); |
---|
22 | LuoOhjaimet(); |
---|
23 | } |
---|
24 | |
---|
25 | void AloitaPeli() |
---|
26 | { |
---|
27 | GameObject alareuna = Level.CreateBottomBorder(); |
---|
28 | GameObject ylareuna = Level.CreateTopBorder(); |
---|
29 | alareuna.Image = LoadImage("tausta1"); |
---|
30 | ylareuna.Image = LoadImage("tausta1"); |
---|
31 | |
---|
32 | //Level.Background.Image = LoadImage("taustakuva1"); |
---|
33 | //Level.Background.FitToLevel(); |
---|
34 | |
---|
35 | Camera.ZoomToLevel(); |
---|
36 | } |
---|
37 | |
---|
38 | void LuoKentta() |
---|
39 | { |
---|
40 | TileMap ruudut = TileMap.FromFile("TextFile1.txt"); |
---|
41 | |
---|
42 | ruudut['I'] = LuoSeina; |
---|
43 | ruudut.Insert(ruudunLeveys, ruudunKorkeus); |
---|
44 | } |
---|
45 | |
---|
46 | PhysicsObject LuoSeina() |
---|
47 | { |
---|
48 | PhysicsObject seina = PhysicsObject.CreateStaticObject(32.0, 32.0); |
---|
49 | seina.Shape = Shapes.Rectangle; |
---|
50 | seina.Image = LoadImage("tausta1"); |
---|
51 | return seina; |
---|
52 | } |
---|
53 | |
---|
54 | PlatformCharacter LuoHahmo() |
---|
55 | { |
---|
56 | PlatformCharacter ukko = new PlatformCharacter(32, 32); |
---|
57 | |
---|
58 | return ukko; |
---|
59 | } |
---|
60 | |
---|
61 | void LiikutaPelaajaa() |
---|
62 | { |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | void LuoOhjaimet() |
---|
67 | { |
---|
68 | Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null); |
---|
69 | Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null); |
---|
70 | Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null); |
---|
71 | Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null); |
---|
72 | } |
---|
73 | |
---|
74 | } |
---|