source: 2013/24/OnniV/pong/pong/pong/pong.cs @ 4050

Revision 4050, 1.6 KB checked in by onosvevi, 10 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        asetaohjaimet();
17        aloitapeli();
18       
19       
20    }
21
22    void LuoKentta()
23    {
24        pallo = new PhysicsObject(70.0, 70.0);
25        Add(pallo);
26        pallo.Shape = Shape.Circle;
27        pallo.Color = Color.Lime;
28        pallo.X = 0.0;
29        pallo.Y = 0.0;
30        Level.CreateBorders(1.0, false);
31        pallo.Restitution = 0.8;
32        Level.BackgroundColor = Color.Black;
33        luomaila(Level.Left + 20.0, 0.0);
34        luomaila(Level.Right - 20.0, 0.0);
35        Camera.ZoomToLevel();
36
37
38
39
40    }
41
42    void aloitapeli()
43    {
44        Vector impulssi = new Vector(700.0, 0.0);
45        pallo.Hit(impulssi);
46    }
47    void luomaila(double X, double Y)
48    {
49        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0);
50        maila.Shape = Shape.Rectangle;
51        maila.X = X;
52        maila.Y = Y;
53        maila.Restitution = 1.0;
54        Add(maila);
55    }
56
57    void asetaohjaimet()
58    {
59
60        Keyboard.Listen(Key.A, ButtonState.Down, LiikutaMaila1Ylös, "pelaaja1: liikuta mailaa ylös");
61        Keyboard.listen(Key.A, ButtonState.Released, PysäytäMaila1, null);
62        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
63    }
64   
65}
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80   
81   
82
83   
84
Note: See TracBrowser for help on using the repository browser.