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

Revision 5270, 1.6 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    Level level;
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(Level level)
28        : base(40, 40)
29    {
30        this.Image = Proto236b.images["player"];
31        this.level = level;
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        if (this.Position.X > this.level.Right)
52        {
53            this.X = this.level.Left;
54        }
55        else if (this.Position.X < this.level.Left)
56        {
57            this.X = this.level.Right;
58        }
59        base.Update(time);
60    }
61}
Note: See TracBrowser for help on using the repository browser.