Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Xivister

Pages: [1]
1
DotNet / Re: SFML C# Views and Sprites
« on: February 16, 2014, 07:23:18 pm »
Thank you - I will definitely check out NetEXT.

2
DotNet / SFML C# Views and Sprites
« on: February 16, 2014, 07:21:25 am »
I am newer to using C# with SFML. I am having a problem with sprite transformations with views. In the game, when a mouse pressed event is triggered, the sprite is supposed to move to the position of the mouse click at a constant velocity over time. However, it does not always move to the correct position, which I believe is due to local versus global positions. Any idea on how to fix this issue?

My creation of the RenderWindow:
myProgram.app = new RenderWindow(new VideoMode(5000, 5000), "Game", Styles.Fullscreen);

My creation of the View:
VideoMode mode = VideoMode.DesktopMode;
View view = new View(new Vector2f(mode.Width/2, mode.Height/2), new Vector2f(mode.Width, mode.Height));

Event method:
static void MouseButtonPressed(object sender, MouseButtonEventArgs e)
{
        if (e.Button == Mouse.Button.Right)
            fighter.MoveToPoint(new Vector2f(Mouse.GetPosition().X, Mouse.GetPosition().Y));
}

Transformation Methods:
 
 public void MovetoPoint(Vector2f inputCoord)
  {
        aTimer.Enabled = true;
        inputPosition = inputCoord;
  }
  private void OnTimedEvent(object source, ElapsedEventArgs e)
  {
    if (this.Length(inputPosition - this.Position) > 0)
        this.Position = this.Position + (this.Normalize(inputPosition - this.Position) * (Math.Min(v, this.Length(inputPosition - this.Position))));
    else
            aTimer.Enabled = false;
  }



Pages: [1]