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

Revision 5308, 1.8 KB checked in by mijoilmo, 6 years ago (diff)

thruster animaatio

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