Line | |
---|
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 Pong : PhysicsGame |
---|
10 | { |
---|
11 | PhysicsObject pallo; |
---|
12 | public override void Begin() |
---|
13 | { |
---|
14 | |
---|
15 | |
---|
16 | LuoKentta(); |
---|
17 | AloitaPeli(); |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | // PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); |
---|
22 | |
---|
23 | |
---|
24 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
25 | } |
---|
26 | void LuoKentta() |
---|
27 | { |
---|
28 | pallo = new PhysicsObject(40.0, 40.0); |
---|
29 | Add(pallo); |
---|
30 | pallo.Shape = Shape.Circle; |
---|
31 | pallo.X = -200.0; |
---|
32 | pallo.Y = 0.0; |
---|
33 | pallo.Restitution = 1.0; |
---|
34 | |
---|
35 | PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); |
---|
36 | maila.Shape = Shape.Rectangle; |
---|
37 | maila.X = Level.Left + 20.0; |
---|
38 | maila.Y = 0.0; |
---|
39 | maila.Restitution = 1.0; |
---|
40 | Add(maila); |
---|
41 | |
---|
42 | Level.CreateBorders(0.85, false); |
---|
43 | Level.Background.Color = Color.Black; |
---|
44 | Camera.ZoomToLevel(); |
---|
45 | } |
---|
46 | void AloitaPeli() |
---|
47 | { Vector impulssi = new Vector(700.0, 0.0); |
---|
48 | pallo.Hit(impulssi); |
---|
49 | } |
---|
50 | void LuoMaila(double x, double y) |
---|
51 | { PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); |
---|
52 | maila.Shape = Shape.Rectangle; |
---|
53 | maila.X = x; |
---|
54 | maila.Y = y; |
---|
55 | maila.Restitution = 1.0; |
---|
56 | Add(maila); |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | |
---|
Note: See
TracBrowser
for help on using the repository browser.