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 6698581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:35:41+00:00 2026-05-26T06:35:41+00:00

Currently i’m making a breakout game, and to define objects’ location or movement i’m

  • 0

Currently i’m making a breakout game, and to define objects’ location or movement i’m using :

float mX, mY;
float speedX, speedY;   

And to move an object I add the speed in a certain direction to the current position (mX += speedX).

But I’ve read alot on that I ‘should’ be using vectors instead of the above, wich I now plan on doing. I’ve read up on some of this vector math, but I don’t know how I could implement this in my game. There’s alot of information on the math itself, but I couldn’t find anything on the code-side of it. I could come up with:

float mX, mY;
float direction;
float velocity;  

But here i’m kinda stuck. I know I should move the object to direction with velocity, probably with a factor of time, but how ?

(btw, i”m making it with openGL-ES on Android)

  • 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-26T06:35:42+00:00Added an answer on May 26, 2026 at 6:35 am

    A vector in 2D has two dimensions: (vx, vy). That’s all you need.

    You find the direction by calculating what’s called ‘unit vector’: a vector of magnitude 1 that points in the direction you’re going.

    You calculate magnitude using this formula: magnitude = sqrt(vx*vx + vy*vy)

    You get the unit vector by dividing both components by the magnitude:

    (ux, uy) = (vx/magnitude, vy/magnitude)
    

    If you are moving with a constant velocity over a time step dt, then the distance you move in each direction is:

    (dx, dy) = (vx*dt, vy*dt)
    

    This assumes no acceleration over that time period.

    This is all basic vector stuff. A little reading could go a long way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am using Amazon Cloudfront to service static objects on my ASP.Net MVC3
Currently, I am developing a product that does fairly intensive calculations using MS SQL
Currently I am adding object by creating it like: type TRecord = class private
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently we use log4net of version 1.2.10.0 and we should start using some 3rd
Currently we are using Trac . Tickets are good for tracking tasks and related
currently we have quite a chunky auditing system for objects within our application, the
Currently, db4o does not allow indexing on the contents of collections. What object databases
Currently in my webpage i load images to the ListView object as follows... <ContentTemplate>
Currently I am using a pretty basic function to pre-load images: function preload(arrayOfImages) {

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.