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 | Vector nopeusylos = new Vector(0,200); |
---|
12 | Vector nopeusalas = new Vector(0, -200); |
---|
13 | PhysicsObject pallo; |
---|
14 | PhysicsObject maila1; |
---|
15 | PhysicsObject maila2; |
---|
16 | public override void Begin() |
---|
17 | { |
---|
18 | Luokentta(); |
---|
19 | aloitapeli(); |
---|
20 | |
---|
21 | Vector impulssi = new Vector(1000, 0); |
---|
22 | pallo.Hit(impulssi); |
---|
23 | |
---|
24 | PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); |
---|
25 | } |
---|
26 | |
---|
27 | void Luokentta() |
---|
28 | { |
---|
29 | pallo = new PhysicsObject(30.0, 30.0); |
---|
30 | Add(pallo); |
---|
31 | pallo.Shape = Shape.Circle; |
---|
32 | pallo.Color = Color.Orange; |
---|
33 | pallo.X = 100; |
---|
34 | pallo.Y = 170; |
---|
35 | maila1 = luomaila(Level.Left + 20.0, 0.0); |
---|
36 | maila2 = luomaila(Level.Right - 20.0, 0.0); |
---|
37 | Level.CreateBorders(1.0, false); |
---|
38 | pallo.Restitution = 200.0; |
---|
39 | Level.BackgroundColor = Color.DarkJungleGreen; |
---|
40 | |
---|
41 | Camera.ZoomToLevel(); |
---|
42 | luomaila(20, 20); |
---|
43 | } |
---|
44 | |
---|
45 | void aloitapeli() |
---|
46 | { |
---|
47 | Vector impulssi = new Vector(1000, 0); |
---|
48 | pallo.Hit(impulssi); |
---|
49 | } |
---|
50 | PhysicsObject 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 | return maila; |
---|
58 | void astenappaimet() |
---|
59 | {Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
60 | Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus,"pelaaja 1. liikuttaa mailaa ylös", maila1, nopeusylos); |
---|
61 | Keyboard.Listen(Key.A, ButtonState.Released,AsetaNopeus,null, null, maila1, Vector.Zero); |
---|
62 | Keyboard.Listen(Key.up,ButtonState.Down,Asetanopeus,"pelaja 2 liikuttaa mailaa ylös",maila2, nopeusylos); |
---|
63 | Keyboard.Listen(Key.Z,ButtonState.Down,Asetanopeus,null,Vector.Zero); |
---|
64 | Keyboard.Listen(Key.up,ButtonState.Released,Asetanopeus,null, |
---|
65 | Keyboard.Listen(Key.Z,ButtonState.Released |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|