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

Revision 5299, 1.7 KB checked in by mijoilmo, 6 years ago (diff)

kaiken muutin

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