source: 2017/30/MikaelH/Pong/Pong/Pong/Pong.cs @ 9046

Revision 9046, 1.2 KB checked in by npo17_66, 6 years ago (diff)
Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8
9public 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.