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 FysiikkaPeli4 : PhysicsGame |
---|
10 | { |
---|
11 | PhysicsObject pelaaja; |
---|
12 | PhysicsObject pelaaja2; |
---|
13 | Image ukeli1 = LoadImage("pelaaja1"); |
---|
14 | Image taustakuva = LoadImage("tausta"); |
---|
15 | Image ukeli2 = LoadImage("pelaaja2"); |
---|
16 | public override void Begin() |
---|
17 | { |
---|
18 | PhysicsObject pallo = new PhysicsObject(40, 40); |
---|
19 | Add(pallo); |
---|
20 | pallo.Shape = Shape.Circle; |
---|
21 | |
---|
22 | pelaaja = new PhysicsObject(50, 50); |
---|
23 | Add(pelaaja); |
---|
24 | pelaaja.Image = ukeli1; |
---|
25 | pelaaja2 = new PhysicsObject(50, 50); |
---|
26 | Add(pelaaja2); |
---|
27 | pelaaja2.Image = ukeli2; |
---|
28 | |
---|
29 | pelaaja.X = -200.0; |
---|
30 | pelaaja.Y = 0.0; |
---|
31 | |
---|
32 | pelaaja2.X = 200.0; |
---|
33 | pelaaja2.Y = 0.0; |
---|
34 | |
---|
35 | |
---|
36 | Keyboard.Listen(Key.Left, ButtonState.Down, |
---|
37 | LiikutaPelaajaa, null, new Vector(-300, 0)); |
---|
38 | Keyboard.Listen(Key.Right, ButtonState.Down, |
---|
39 | LiikutaPelaajaa, null, new Vector(300, 0)); |
---|
40 | Keyboard.Listen(Key.Up, ButtonState.Down, |
---|
41 | LiikutaPelaajaa, null, new Vector(0, 300)); |
---|
42 | Keyboard.Listen(Key.Down, ButtonState.Down, |
---|
43 | LiikutaPelaajaa, null, new Vector(0, -300)); |
---|
44 | |
---|
45 | Keyboard.Listen(Key.A, ButtonState.Down, |
---|
46 | LiikutaPelaaja2, null, new Vector(-300, 0)); |
---|
47 | Keyboard.Listen(Key.D, ButtonState.Down, |
---|
48 | LiikutaPelaaja2, null, new Vector(300, 0)); |
---|
49 | Keyboard.Listen(Key.W, ButtonState.Down, |
---|
50 | LiikutaPelaaja2, null, new Vector(0, 300)); |
---|
51 | Keyboard.Listen(Key.S, ButtonState.Down, |
---|
52 | LiikutaPelaaja2, null, new Vector(0, -300)); |
---|
53 | |
---|
54 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); |
---|
55 | |
---|
56 | Level.CreateBorders(false); |
---|
57 | Level.Background.Image = taustakuva; |
---|
58 | Camera.ZoomToLevel(); |
---|
59 | |
---|
60 | pelaaja.CanRotate = false; |
---|
61 | pelaaja2.CanRotate = false; |
---|
62 | |
---|
63 | } |
---|
64 | void LiikutaPelaajaa(Vector vektori) |
---|
65 | { |
---|
66 | pelaaja.Push(vektori); |
---|
67 | } |
---|
68 | void LiikutaPelaaja2(Vector vektori) |
---|
69 | { |
---|
70 | pelaaja2.Push(vektori); |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | |
---|