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

Revision 5342, 2.1 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    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        this.Restitution = 0.2;
45
46        this.thrusterEffect = new GameObject(40, 40);
47        thrusterEffect.Animation = new Animation(parent.ImageLists["player_thruster"]);
48        thrusterEffect.Animation.FPS = 18;
49        thrusterEffect.Animation.Start();
50        thrusterEffect.IsVisible = false;
51        thrusterEffect.Y -= 19;
52        Add(thrusterEffect);
53    }
54    public override void Update(Time time)
55    {
56        base.Update(time);
57        this.parent.MessageDisplay.Clear();
58        this.parent.MessageDisplay.Add(this.AbsolutePosition.ToString());
59        if (this.X > parent.Level.Right) {
60            this.X = parent.Level.Left;
61        }else if (this.X < parent.Level.Left){
62            this.X = parent.Level.Right;
63        }
64        if (parent.CurrentLevel.IsPlanet&&this.Y>parent.Level.Top) {
65            //player pystyy lähteä pois planeetalta kun menee tarpeeksi ylös
66            //TODO: vaihda leveli spaceksi
67            if(false){}
68        }
69    }
70}
Note: See TracBrowser for help on using the repository browser.