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 Peli : PhysicsGame |
---|
10 | { PhysicsObject pallo; |
---|
11 | |
---|
12 | public override void Begin() |
---|
13 | { |
---|
14 | LuoKenttä(); |
---|
15 | AsetaOhjaimet(); |
---|
16 | Aloitapeli (); |
---|
17 | |
---|
18 | |
---|
19 | } |
---|
20 | void LuoKenttä () |
---|
21 | { |
---|
22 | pallo = new PhysicsObject(150, 150); |
---|
23 | pallo.Shape = Shape.Circle; |
---|
24 | Add(pallo); |
---|
25 | pallo.X = 200.0; |
---|
26 | pallo.Y = 0.0; |
---|
27 | Level.CreateBorders(1.0, false); |
---|
28 | pallo.Restitution = 1.0; |
---|
29 | Level.BackgroundColor = Color.Black; |
---|
30 | Camera.ZoomToLevel(); |
---|
31 | LuoMaila(Level.Left + 20.0, 0.00); |
---|
32 | LuoMaila(Level.Right - 20.0, 0.00); |
---|
33 | |
---|
34 | } |
---|
35 | |
---|
36 | void Aloitapeli() |
---|
37 | { |
---|
38 | pallo.Y = 0.0; |
---|
39 | Vector impulssi = new Vector(800.0, 555.0); |
---|
40 | pallo.Hit(impulssi); |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | void LuoMaila ( double x, double y) |
---|
46 | { |
---|
47 | PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); |
---|
48 | maila.Shape = Shape.Rectangle; |
---|
49 | maila.X = x; |
---|
50 | maila.Y = y; |
---|
51 | maila.Restitution = 1.0; |
---|
52 | Add(maila); |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | void AsetaOhjaimet() |
---|
58 | { |
---|
59 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "poistu" ); |
---|
60 | Keyboard.Listen(Key.A,ButtonState.Down,LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös" ); |
---|
61 | Keyboard.Listen(Key.A,ButtonState.Released, PysaytaMaila, null ); |
---|
62 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "poistu" ); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|