1 | using System; |
---|
2 | using Jypeli; |
---|
3 | using Jypeli.Widgets; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Effects; |
---|
6 | |
---|
7 | public class Tasohyppely : PhysicsGame |
---|
8 | { |
---|
9 | PhysicsObject helikopteri; |
---|
10 | double helikopterinNopeus; |
---|
11 | Image helikopterinKuva = LoadImage("Black Hawk"); |
---|
12 | Image helikopterinKuva2; |
---|
13 | PhysicsObject pelaaja1; |
---|
14 | AssaultRifle machinegun; |
---|
15 | |
---|
16 | protected override void Begin() |
---|
17 | { |
---|
18 | LuoKentta(); |
---|
19 | //pelaaja1 = new PhysicsObject(40, 40); |
---|
20 | helikopterinKuva2 = Image.Mirror(LoadImage("Black Hawk")); |
---|
21 | //Add(pelaaja1); |
---|
22 | |
---|
23 | Keyboard.Listen(Key.A, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-100, 0)); |
---|
24 | Keyboard.Listen(Key.D, ButtonState.Down, LiikutaPelaajaa, null, new Vector(100, 0)); |
---|
25 | Keyboard.Listen(Key.W, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, 100)); |
---|
26 | Keyboard.Listen(Key.S, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -100)); |
---|
27 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); |
---|
28 | Keyboard.Listen(Key.Space, ButtonState.Down, machinegun.Use, "Ammu"); |
---|
29 | Keyboard.Listen(Key.Q,ButtonState.Down,KallistaKopteria,null, |
---|
30 | Keyboard.Listen(Key.E,ButtonState.Down,KallistaKopteria,null, |
---|
31 | |
---|
32 | Gravity = new Vector( 0, -80.0 ); |
---|
33 | } |
---|
34 | |
---|
35 | void LuoKentta() |
---|
36 | { |
---|
37 | helikopteri = new PhysicsObject(40.0, 40.0); |
---|
38 | helikopteri.Shape = Shapes.Circle; |
---|
39 | helikopteri.Mass =1.0; |
---|
40 | helikopteri.Image = helikopterinKuva; |
---|
41 | helikopteri.Color = Color.Gray; |
---|
42 | helikopteri.X = -200.0; |
---|
43 | helikopteri.Y = 0.0; |
---|
44 | helikopterinNopeus = 200; |
---|
45 | helikopteri.LinearDamping = 1.0; |
---|
46 | helikopteri.Size = new Vector(150, 55); |
---|
47 | Add(helikopteri); |
---|
48 | |
---|
49 | machinegun = new AssaultRifle(20, 20); |
---|
50 | machinegun.Use(); |
---|
51 | Add(machinegun); |
---|
52 | machinegun.Ammo.Value = int.MaxValue; |
---|
53 | machinegun.BulletCollision = LuotiOsuu; |
---|
54 | Level.CreateBorders(1.0, true); |
---|
55 | int pMaxMaara = 200; |
---|
56 | |
---|
57 | ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("rajahdys"), pMaxMaara); |
---|
58 | double x = 0; |
---|
59 | double y = 0; |
---|
60 | int pMaara = 50; |
---|
61 | rajahdys.AddEffect(x, y, pMaara); |
---|
62 | |
---|
63 | Level.BackgroundColor = Color.Blue; |
---|
64 | Camera.ZoomToLevel(); |
---|
65 | helikopteri.Restitution = 1.0; |
---|
66 | Level.BackgroundColor = Color.Black; |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | } |
---|
71 | |
---|
72 | const double pallonNopeus = 500; |
---|
73 | |
---|
74 | |
---|
75 | protected override void Update( Time time ) |
---|
76 | { |
---|
77 | if (helikopteri.Velocity.X < 0) |
---|
78 | helikopteri.Image = helikopterinKuva2; |
---|
79 | else |
---|
80 | helikopteri.Image = helikopterinKuva; |
---|
81 | base.Update( time ); |
---|
82 | } |
---|
83 | |
---|
84 | void LiikutaPelaajaa( Vector vektori ) |
---|
85 | { |
---|
86 | helikopteri.Hit(vektori); |
---|
87 | } |
---|
88 | |
---|
89 | void LiikutaPelaajaa(AnalogState tatinTila) |
---|
90 | { |
---|
91 | Vector tatinAsento = tatinTila.StateVector; |
---|
92 | } |
---|
93 | |
---|
94 | void KallistaHelikopteria(double kaanto); |
---|
95 | {helikopteri.Angle = Angle.degrees(helikopteri.Angle.Degree +kaanto); |
---|
96 | |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | } |
---|