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 Attack_to_Agora : PhysicsGame |
---|
10 | { |
---|
11 | private Animation chuckinkavely; |
---|
12 | double nopeus = 200; |
---|
13 | double hyppyvoima = 1000; |
---|
14 | |
---|
15 | Image level1 = LoadImage("Agora_paaovi_pixelate"); |
---|
16 | Image taistelijanvarjo = LoadImage("varjo"); |
---|
17 | Image taistelijaolio = LoadImage("olio"); |
---|
18 | |
---|
19 | public override void Begin() |
---|
20 | { |
---|
21 | chuckinkavely = LoadAnimation("pelaajaliikkuu"); |
---|
22 | SmoothTextures = false; |
---|
23 | Level.Background.Image = level1; |
---|
24 | Level.Background.Color = Color.Black; |
---|
25 | //Level.Size = Level.Background.Size; |
---|
26 | Level.Width = 2000; |
---|
27 | Level.Height = 1200; |
---|
28 | Level.Background.FitToLevel(); |
---|
29 | //Camera.Zoom(2); |
---|
30 | //Camera.ZoomToLevel(); |
---|
31 | Gravity = new Vector(0, -2500); |
---|
32 | |
---|
33 | PhysicsObject pohja = Level.CreateBottomBorder(); |
---|
34 | pohja.Y = Level.Bottom + 100; |
---|
35 | pohja.IsVisible = false; |
---|
36 | |
---|
37 | PlatformCharacter taistelija = new PlatformCharacter( 75, 75 ); |
---|
38 | taistelija.Shape = Shape.Circle; |
---|
39 | taistelija.Animation = new Animation(chuckinkavely); |
---|
40 | taistelija.Animation.Start(); |
---|
41 | |
---|
42 | |
---|
43 | GameObject varjo = new GameObject(70, 30); |
---|
44 | varjo.Image = taistelijanvarjo; |
---|
45 | varjo.Y = pohja.Top; |
---|
46 | Add(varjo, -1); |
---|
47 | Timer ajastin = new Timer(); |
---|
48 | ajastin.Interval = 0.01; |
---|
49 | ajastin.Timeout += delegate |
---|
50 | { |
---|
51 | varjo.X = taistelija.X; |
---|
52 | }; |
---|
53 | ajastin.Start(); |
---|
54 | |
---|
55 | taistelija.Mass = 10.0; |
---|
56 | Add( taistelija ); |
---|
57 | Camera.Follow(taistelija); |
---|
58 | Camera.StayInLevel = true; |
---|
59 | |
---|
60 | Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, null, taistelija, -nopeus); |
---|
61 | Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, null, taistelija, nopeus); |
---|
62 | Keyboard.Listen(Key.A, ButtonState.Released, pysahtyy, null, taistelija, -nopeus); |
---|
63 | Keyboard.Listen(Key.D, ButtonState.Released, pysahtyy, null, taistelija, nopeus); |
---|
64 | Keyboard.Listen(Key.Space, ButtonState.Pressed, LiikutaYlos, null, taistelija); |
---|
65 | |
---|
66 | |
---|
67 | PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); |
---|
68 | IsFullScreen = true; |
---|
69 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
70 | } |
---|
71 | void pysahtyy() |
---|
72 | { |
---|
73 | // pelaaja parametriksi ja animaation pysäytys |
---|
74 | } |
---|
75 | void Liikuta(PlatformCharacter pelaaja, double suunta) |
---|
76 | { |
---|
77 | pelaaja.Walk(suunta); |
---|
78 | |
---|
79 | if (!pelaaja.Animation.IsPlaying) |
---|
80 | { |
---|
81 | pelaaja.Animation.Resume(); |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | void LiikutaYlos(PlatformCharacter pelaaja) |
---|
86 | { |
---|
87 | pelaaja.Jump(hyppyvoima); |
---|
88 | |
---|
89 | |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | } |
---|