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 | |
---|
13 | public override void Begin() |
---|
14 | { |
---|
15 | LuoKentta(); |
---|
16 | AloitaPeli(); |
---|
17 | |
---|
18 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
19 | } |
---|
20 | |
---|
21 | void LuoKentta() |
---|
22 | { |
---|
23 | pallo = new PhysicsObject(40.0, 40.0); |
---|
24 | pallo.Shape = Shape.Circle; |
---|
25 | pallo.X = -200.0; |
---|
26 | pallo.Y = 0.0; |
---|
27 | pallo.Restitution = 1.0; |
---|
28 | Add(pallo); |
---|
29 | |
---|
30 | LuoMaila(Level.Left + 20.0, 0.0); |
---|
31 | LuoMaila(Level.Right - 20.0, 0.0); |
---|
32 | |
---|
33 | Level.CreateBorders(1.0, false); |
---|
34 | Level.BackgroundColor = Color.Lime; |
---|
35 | |
---|
36 | Camera.ZoomToLevel(); |
---|
37 | } |
---|
38 | |
---|
39 | void AloitaPeli() |
---|
40 | { |
---|
41 | Vector impulssi = new Vector(500.0, 0.0); |
---|
42 | pallo.Hit(impulssi); |
---|
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 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.