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 Water_wey : PhysicsGame |
---|
10 | { |
---|
11 | //------------------------------------------------------------- PhysicsObject |
---|
12 | PhysicsObject vesi; |
---|
13 | PhysicsObject pelaaja; |
---|
14 | double voima = 100000; |
---|
15 | |
---|
16 | public override void Begin() |
---|
17 | { |
---|
18 | PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); |
---|
19 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
20 | // Keyboard.Listen(Key.Right, ButtonState.Pressed, Gravity, new Vector(-100, 0); |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | luopelaaja(); |
---|
25 | lisaaohjaimet(); |
---|
26 | |
---|
27 | Gravity = new Vector(0, -100); |
---|
28 | Level.CreateBorders(); |
---|
29 | int i = 0; |
---|
30 | |
---|
31 | while (i < 1000) |
---|
32 | { |
---|
33 | vesi = new PhysicsObject(10, 10); |
---|
34 | vesi.Shape = Shape.Circle; |
---|
35 | vesi.Color = Color.Blue; |
---|
36 | vesi.Mass = 0.5; |
---|
37 | vesi.X = RandomGen.NextDouble(Level.Left, Level.Right); |
---|
38 | vesi.Y = RandomGen.NextDouble(Level.Bottom, Level.Top); |
---|
39 | Add(vesi); |
---|
40 | i++; |
---|
41 | } |
---|
42 | } |
---|
43 | //-----------------------------------------------------------------------Aliohjelmat |
---|
44 | void luopelaaja()//Vector paikka, double leveys, double korkeus |
---|
45 | { |
---|
46 | pelaaja = new PhysicsObject(50, 50); |
---|
47 | //pelaaja.Shape = Shape.; |
---|
48 | //pelaaja.Position = paikka; |
---|
49 | pelaaja.Mass = 100; |
---|
50 | pelaaja.Image = LoadImage("Untitled"); |
---|
51 | //(pelaaja.Tag = "";) |
---|
52 | Add(pelaaja); |
---|
53 | |
---|
54 | |
---|
55 | // AddCollisionHandler(pelaaja, "palikka", PysaytaPelaaja); |
---|
56 | } |
---|
57 | void lisaaohjaimet() |
---|
58 | { |
---|
59 | Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-voima, 0)); |
---|
60 | Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(voima, 0)); |
---|
61 | Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, voima)); |
---|
62 | Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -voima)); |
---|
63 | |
---|
64 | //Keyboard.Listen(Key.Left, ButtonState.Released, PysaytaPelaajaX, null); |
---|
65 | //Keyboard.Listen(Key.Right, ButtonState.Released, PysaytaPelaajaX, null); |
---|
66 | //Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaPelaajaY, null); |
---|
67 | //Keyboard.Listen(Key.Down, ButtonState.Released, PysaytaPelaajaY, null); |
---|
68 | } |
---|
69 | void LiikutaPelaajaa(Vector liikuttaja) |
---|
70 | { |
---|
71 | //if (pelaajia > 2) |
---|
72 | //{ |
---|
73 | // liikuttaja = liikuttaja + Vector.FromLengthAndAngle(20, liikuttaja.Angle); |
---|
74 | //} |
---|
75 | pelaaja.Push(liikuttaja); |
---|
76 | pelaaja.Angle = liikuttaja.Angle + Angle.FromDegrees(90); |
---|
77 | } |
---|
78 | } |
---|