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 | Vector nopeusYlos=new Vector(object,200); |
---|
14 | Vector nopeusAlas = new Vector (0, -200); |
---|
15 | |
---|
16 | PhysicsObject maila1; |
---|
17 | PhysicsObject maila2; |
---|
18 | |
---|
19 | public override void Begin() |
---|
20 | { |
---|
21 | // TODO: Kirjoita ohjelmakoodisi tähän |
---|
22 | LuoKentta(); |
---|
23 | AloitaPeli(); |
---|
24 | |
---|
25 | Vector impulssi = new Vector(1000.0, 350.0); |
---|
26 | pallo.Hit(impulssi); |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | } |
---|
31 | |
---|
32 | void LuoKentta() |
---|
33 | { |
---|
34 | //pallo |
---|
35 | |
---|
36 | pallo = new PhysicsObject(60.0, 60.0); |
---|
37 | Add(pallo); |
---|
38 | pallo.Shape = Shape.Circle; |
---|
39 | pallo.X = -200.0; |
---|
40 | pallo.Y = 0.0; |
---|
41 | |
---|
42 | LuoMaila(Level.Left + 20.0, 0.0); |
---|
43 | LuoMaila(Level.Right - 20.0, 0.0); |
---|
44 | |
---|
45 | Level.CreateBorders(0.85, false); |
---|
46 | pallo.Restitution = 1.0; |
---|
47 | |
---|
48 | Level.Background.Color = Color.Crimson; |
---|
49 | |
---|
50 | Camera.ZoomToLevel(); |
---|
51 | } |
---|
52 | |
---|
53 | void AloitaPeli() |
---|
54 | { |
---|
55 | Vector impulssi = new Vector(500.0, 0.0); |
---|
56 | pallo.Hit(impulssi); |
---|
57 | } |
---|
58 | |
---|
59 | void LuoMaila(double x, double y) |
---|
60 | { |
---|
61 | //maila |
---|
62 | |
---|
63 | PhysicsObject maila = PhysicsObject.CreateStaticObject(35.0, 140.0); |
---|
64 | maila.Shape = Shape.Rectangle; |
---|
65 | maila.X = x; |
---|
66 | maila.Y = y; |
---|
67 | maila.Restitution = 1.0; |
---|
68 | Add(maila); |
---|
69 | } |
---|
70 | |
---|
71 | void AsetaOhjaimet() |
---|
72 | { |
---|
73 | Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaMaila1Ylos, "pelaaja 1: Liikuta mailaa ylös"); |
---|
74 | Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaMaila1 "null"); |
---|
75 | |
---|
76 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); |
---|
77 | } |
---|
78 | |
---|
79 | void AsetaNopeus(PhysicsObject maila, Vector nopeus) |
---|
80 | { |
---|
81 | maila.Velocity = nopeus; |
---|
82 | } |
---|
83 | } |
---|