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

Revision 5985, 1.7 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(1000, 0);
12    PhysicsObject Pelaaja;
13
14    PhysicsObject Alareuna;
15    PhysicsObject Ylareuna;
16    public override void Begin()
17    {
18
19        LuoMaailma(0, 0);
20       
21
22       
23        Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, "liikuta Pelaajaa Ylös", new Vector (0, 1000));
24        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
25        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
26    }
27
28    void LuoMaailma(double x, double y)
29    {
30        Pelaaja = new PhysicsObject(50, 50);
31        Pelaaja.Shape = Shape.Circle;
32        Pelaaja.Color = Color.GreenYellow;
33        Pelaaja.X = x;
34        Pelaaja.Y = y;
35        Gravity = new Vector(0, -500);
36        Add(Pelaaja);
37
38        Alareuna = Level.CreateBottomBorder(0,true);
39        Alareuna.Width = 2000;
40        Ylareuna = Level.CreateTopBorder(0, true);
41        Ylareuna.Width = 2000;
42        PhysicsObject Este = PhysicsObject.CreateStaticObject(100,500);
43
44        Add(Este);
45
46        //Level.CreateVerticalBorders(0, true, Color.White);
47        Level.Background.Color = Color.Cyan;
48        Camera.Follow(Pelaaja);
49    }
50
51
52    protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
53    {
54        base.Update(gameTime);
55        Pelaaja.Push(new Vector(70, 0));
56        Alareuna.X = Pelaaja.X;
57        Ylareuna.X = Pelaaja.X;
58
59
60    }
61   
62    void LiikutaPelaajaa(Vector vektori)
63    {
64        Pelaaja.Push(vektori);
65    }
66}
67
68
Note: See TracBrowser for help on using the repository browser.