1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using Jypeli; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Controls; |
---|
6 | using Jypeli.Effects; |
---|
7 | using Jypeli.Widgets; |
---|
8 | |
---|
9 | public 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 | |
---|