source: 2016/27/ohjaajat/VenienteFragore/VenienteFragore/VenienteFragore/MovingPlatform.cs @ 7733

Revision 7733, 895 bytes checked in by sieerinn, 3 years ago (diff)

Objektien luontia aloitettu

Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Jypeli;
6using Physics2DDotNet;
7
8class MovingPlatform : SimplePhysics.Object
9{
10    private readonly Vector startPosition;
11
12    private readonly double distance;
13
14    private Vector direction;
15
16
17    public MovingPlatform(Vector position, Vector direction, double distance, double width, double height) : base(width, height)
18    {
19        this.direction = direction;
20        this.distance = distance;
21        Position = startPosition = position;
22        IgnoresGravity = true;
23    }
24
25    public override void Update(Time time)
26    {
27        if (Vector.Distance(startPosition, Position) > distance)
28        {
29            direction = -direction;
30        }
31        Velocity = direction;
32        Game.UpdateMovingPlatform(this, time);
33        //base.Update(time);
34    }
35}
Note: See TracBrowser for help on using the repository browser.