source: 2012/30/MarkusV/PoNG/PoNG/PoNG/PoNG.cs @ 3705

Revision 3705, 2.1 KB checked in by anlakane, 7 years ago (diff)

Talletus.

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    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){
51PhysicsObject 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");
60Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus,"pelaaja 1. liikuttaa mailaa ylös", maila1, nopeusylos);
61Keyboard.Listen(Key.A, ButtonState.Released,AsetaNopeus,null, null, maila1, Vector.Zero);
62Keyboard.Listen(Key.up,ButtonState.Down,Asetanopeus,"pelaja 2 liikuttaa mailaa ylös",maila2, nopeusylos);
63Keyboard.Listen(Key.Z,ButtonState.Down,Asetanopeus,null,Vector.Zero);
64Keyboard.Listen(Key.up,ButtonState.Released,Asetanopeus,null,
65Keyboard.Listen(Key.Z,ButtonState.Released
66  }
67}
68}
Note: See TracBrowser for help on using the repository browser.