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 Player : PhysicsObject |
---|
10 | { |
---|
11 | GameObject thrusterEffect; |
---|
12 | Game parent; |
---|
13 | public void rotate(double rotSpeed) |
---|
14 | { |
---|
15 | this.AngularVelocity = rotSpeed; |
---|
16 | } |
---|
17 | public void thrusterStart(double speed) |
---|
18 | { |
---|
19 | this.thrusterEffect.IsVisible = true; |
---|
20 | this.Push(Vector.FromLengthAndAngle(speed * 800, this.Angle + Angle.RightAngle)); |
---|
21 | } |
---|
22 | public void thrusterEnd() |
---|
23 | { |
---|
24 | this.thrusterEffect.IsVisible = false; |
---|
25 | //if this.ids, enable ids |
---|
26 | } |
---|
27 | public Player(Game parent) |
---|
28 | : base(40, 40) |
---|
29 | { |
---|
30 | this.Image = Proto236b.images["player"]; |
---|
31 | this.Shape = Shape.FromImage(Proto236b.images["player"]); |
---|
32 | this.parent = parent; |
---|
33 | bool IDS = false; //inertial dampening system, katsotaan pistetäänkö ostettavaksi peliin |
---|
34 | if (IDS == true) |
---|
35 | { |
---|
36 | this.LinearDamping = 0.97; |
---|
37 | } |
---|
38 | else |
---|
39 | { |
---|
40 | this.LinearDamping = 1; |
---|
41 | } |
---|
42 | this.AngularDamping = 0.7; |
---|
43 | |
---|
44 | this.thrusterEffect = new GameObject(40, 40); |
---|
45 | thrusterEffect.Image = Proto236b.images["player_thruster"]; |
---|
46 | thrusterEffect.IsVisible = false; |
---|
47 | thrusterEffect.Y -= 20; |
---|
48 | Add(thrusterEffect); |
---|
49 | } |
---|
50 | public override void Update(Time time) |
---|
51 | { |
---|
52 | Game parent = this.parent; |
---|
53 | if (this.X + parent.Level.Width / 2.0 > parent.Level.Right) |
---|
54 | { |
---|
55 | if (this.X > parent.Level.Right) |
---|
56 | { |
---|
57 | //parent.Camera |
---|
58 | this.X = parent.Level.Left; |
---|
59 | } |
---|
60 | } |
---|
61 | base.Update(time); |
---|
62 | } |
---|
63 | } |
---|