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

Revision 5320, 2.1 KB checked in by mijoilmo, 6 years ago (diff)

kenttä toimii loistavasti! (y)

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