Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4009180
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:50:46+00:00 2026-05-20T08:50:46+00:00

I writing a simple XNA demo in which a sprite is supposed to move

  • 0

I writing a simple XNA demo in which a sprite is supposed to move along a line (defined with two Vector2 points (Ax,Ay) and (Bx,By) ) at a given speed V (understood as a distance on the line traveled in a unit of time).
I understand that i’d need to calculate x and y position in a 2D space using equations similar to these:

dx = V*dt*cos(alpha)
dy = V*dt*sin(alpha)

but taking negative V into consideration (like when moving “backwards”)
But i wonder if i am not reinventing the wheel, maybe xna offers solution to that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:50:47+00:00Added an answer on May 20, 2026 at 8:50 am

    Create a 2D vector from point A to point B by subtracting A from B. Normalize it by dividing the X and Y conponents by the length of the vector. Multiply the X and Y components by the speed. Multiply this by the time slice (i.e. 20/1000 for 20 milliseconds). Add these X and Y values to your position.

    Example:

    A is (2, 5)  B is (1, 8)
    Speed is 2 (move 2 units in one second)
    Time slice is 20 milliseconds since last update
    
    C will be (-1, 3)
    Normalize C by dividing by distance (sqrt(-1 * -1 + 3 * 3) = 3.1622777)
    Normalized is (-0.316277, 0.9486833) (to move 1 unit that direction)
    Multiply by speed (2): (-0.632554, 1.8973666)
    For movement this time period, multiply by 20 and divide by 1000:
    (-0.01265108, 0.037947332), move sprite this far this frame
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I writing a simple method which should delete an entity from the database if
I am writing simple hex engine for action-rpg in XNA 3.1. I want to
I'm writing a simple game in XNA and I've faced a problem with delegates.
I am writing simple webapp in Java (for educational purpuses only) which allows admin
I am writing simple program for my Ubuntu 10.04. I want to see which
I'm writing simple command-line program in C++ (windows). One functionality of it is to
I'm writing simple standalone linux kernel module, which can turn off the LCD controler.
I've begun writing a game using XNA Framework and have hit some simple problem
I am writing simple housekeeping script. this script contains following line of codes.This is
I am writing simple parallel program in C++ using OpenMP. I am working on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.