1 | using System; |
---|
2 | using Jypeli; |
---|
3 | using Jypeli.ScreenObjects; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Effects; |
---|
6 | |
---|
7 | public class Peli : PhysicsGame |
---|
8 | { |
---|
9 | ParticleSystem ps; |
---|
10 | ExplosionSystem rajahdys1, rajahdys2, rajahdys3, rajahdys4; |
---|
11 | Flames liekki1, liekki2; |
---|
12 | protected override void Begin() |
---|
13 | { |
---|
14 | Level.BackgroundColor = Color.Black; |
---|
15 | Image expl = LoadImage("Explosion"); |
---|
16 | Image glow = LoadImage("Red"); |
---|
17 | Image glow2 = LoadImage("Yellow"); |
---|
18 | rajahdys1 = new ExplosionSystem(expl, glow, 1000); |
---|
19 | rajahdys2 = new ExplosionSystem(expl, 1000); |
---|
20 | rajahdys3 = new ExplosionSystem(glow, 1000); |
---|
21 | rajahdys4 = new ExplosionSystem(glow2, 10); |
---|
22 | liekki1 = new Flames(glow, glow2, 400, Angle.Degrees(270)); |
---|
23 | liekki2 = new Flames(glow2, 400, Angle.Degrees(270)); |
---|
24 | rajahdys2.MinLifetime = 0.2; |
---|
25 | rajahdys2.MaxLifetime = 0.4; |
---|
26 | rajahdys2.MinVelocity = 10; |
---|
27 | rajahdys2.MaxVelocity = 20; |
---|
28 | rajahdys3.MinLifetime = .5; |
---|
29 | rajahdys3.MaxLifetime = .8; |
---|
30 | rajahdys3.MinVelocity = 150; |
---|
31 | rajahdys3.MaxVelocity = 300; |
---|
32 | rajahdys4.MinLifetime = 1.5; |
---|
33 | rajahdys4.MaxLifetime = 2.8; |
---|
34 | rajahdys4.MinVelocity = 1; |
---|
35 | rajahdys4.MaxVelocity = 2; |
---|
36 | Add(rajahdys1); |
---|
37 | //Add(rajahdys2); |
---|
38 | //Add(rajahdys3); |
---|
39 | //Add(rajahdys4); |
---|
40 | Add(liekki1); |
---|
41 | Add(liekki2); |
---|
42 | |
---|
43 | ps = new ParticleSystem(glow, 10); |
---|
44 | ps.MaxAcceleration = 1; |
---|
45 | ps.MaxLifetime = 1; |
---|
46 | ps.MaxRotation = 0; |
---|
47 | ps.MaxRotationSpeed = 0; |
---|
48 | ps.MaxScale = 1; |
---|
49 | ps.MaxVelocity = 10; |
---|
50 | ps.MinAcceleration = 1; |
---|
51 | ps.MinLifetime = 1; |
---|
52 | ps.MinRotation = 0; |
---|
53 | ps.MinRotationSpeed = 0; |
---|
54 | ps.MinScale = 1; |
---|
55 | ps.MinVelocity = 10; |
---|
56 | Add(ps); |
---|
57 | |
---|
58 | Timer t = new Timer(); |
---|
59 | t.Interval = 1; |
---|
60 | t.Trigger += new Timer.TriggerHandler(t_Trigger1); |
---|
61 | Add(t); |
---|
62 | t.Start(); |
---|
63 | |
---|
64 | Timer t1 = new Timer(); |
---|
65 | t1.Interval = .1; |
---|
66 | t1.Trigger += new Timer.TriggerHandler(t_Trigger2); |
---|
67 | Add(t1); |
---|
68 | t1.Start(); |
---|
69 | |
---|
70 | Timer t2 = new Timer(); |
---|
71 | t2.Interval = .05; |
---|
72 | t2.Trigger += new Timer.TriggerHandler(t_Trigger3); |
---|
73 | Add(t2); |
---|
74 | t2.Start(); |
---|
75 | |
---|
76 | Timer t3 = new Timer(); |
---|
77 | t3.Interval = .01; |
---|
78 | t3.Trigger += new Timer.TriggerHandler(t_Trigger4); |
---|
79 | Add(t3); |
---|
80 | t3.Start(); |
---|
81 | |
---|
82 | //TODO: Alusta peli tässä |
---|
83 | } |
---|
84 | |
---|
85 | void t_Trigger1(Timer sender) |
---|
86 | { |
---|
87 | ps.AddEffect(0, 0, 4); |
---|
88 | rajahdys1.AddEffect(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Top, Level.Bottom), 30); |
---|
89 | rajahdys3.AddEffect(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Top, Level.Bottom), 30); |
---|
90 | } |
---|
91 | |
---|
92 | void t_Trigger2(Timer sender) |
---|
93 | { |
---|
94 | rajahdys2.AddEffect(0, 0, 10); |
---|
95 | } |
---|
96 | |
---|
97 | void t_Trigger3(Timer sender) |
---|
98 | { |
---|
99 | liekki1.AddEffect(-200, 0, 2); |
---|
100 | liekki2.AddEffect(200, 0, 2); |
---|
101 | } |
---|
102 | |
---|
103 | void t_Trigger4(Timer sender) |
---|
104 | { |
---|
105 | rajahdys4.AddEffect(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Top, Level.Bottom), 1); |
---|
106 | } |
---|
107 | } |
---|