source: 2015/24/TaneliL/FysiikkaPeli2/FysiikkaPeli2/FysiikkaPeli2/FysiikkaPeli2.cs @ 5958

Revision 5958, 1.2 KB checked in by taliimat, 8 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 FysiikkaPeli2 : PhysicsGame
10{
11    Vector nopeusYlös = new Vector(100, 0);
12    PhysicsObject Pelaaja;
13
14    public override void Begin()
15    {
16
17        LuoPelaaja(0, 0);
18        AsetaNappaimet();
19
20       
21
22        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
23        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
24    }
25
26    void LuoPelaaja(double x, double y)
27    {
28        PhysicsObject Pelaaja = new PhysicsObject(50, 50);
29        Pelaaja.Shape = Shape.Circle;
30        Pelaaja.Color = Color.GreenYellow;
31        Pelaaja.X = x;
32        Pelaaja.Y = y;
33        Gravity = new Vector(0, -100);
34        Add(Pelaaja);
35
36        Level.CreateBorders();
37        Level.Background.Color = Color.Cyan;
38        Camera.ZoomToLevel();
39    }
40
41    void AsetaNappaimet()
42    {
43        Keyboard.Listen(Key.Space, ButtonState.Down, LiikutaPelaajaYlos, "Pelaaja liikkuu ylös");
44
45    }
46    void AsetaNopeus(PhysicsObject Pelaaja, Vector Nopeus)
47    {
48        Pelaaja.Velocity = Nopeus;
49    }
50}
51
52
Note: See TracBrowser for help on using the repository browser.