source: 2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Player.cs @ 5284

Revision 5284, 1.7 KB checked in by mijoilmo, 6 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 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.parent = parent;
32        bool IDS = true; //inertial dampening system, katsotaan pistetäänkö ostettavaksi peliin
33        if (IDS == true)
34        {
35            this.LinearDamping = 0.97;
36        }
37        else
38        {
39            this.LinearDamping = 1;
40        }
41        this.AngularDamping = 0.7;
42
43        this.thrusterEffect = new GameObject(40, 40);
44        thrusterEffect.Image = Proto236b.images["player_thruster"];
45        thrusterEffect.IsVisible = false;
46        thrusterEffect.Y -= 20;
47        Add(thrusterEffect);
48    }
49    public override void Update(Time time)
50    {
51        Game parent = this.parent;
52        if (this.X + parent.Level.Width / 2.0 > parent.Level.Right)
53        {
54            if (this.X > parent.Level.Right)
55            {
56                //parent.Camera
57                this.X = parent.Level.Left;
58            }
59        }
60        base.Update(time);
61    }
62}
Note: See TracBrowser for help on using the repository browser.