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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:26:31+00:00 2026-06-01T10:26:31+00:00

I am new to javascript.I want to move a car on path with arrows.I

  • 0

I am new to javascript.I want to move a car on path with arrows.I created the path with svg and made functions for the arrows.They are ok.But I dont know how will the car recognize the path?If I should check the path’s coordinates for each move, my path consists of different shapes how can I control it?I found some examples but they make the movement as motion not with each key press. Please give me an idea how to move the car only over the road..

  • 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-06-01T10:26:33+00:00Added an answer on June 1, 2026 at 10:26 am

    Ok, short answer: elements cannot recognize each other. What you can do, however, is simulate collisions by getting the computed styles of all elements you need, and then calculating the ‘surface’ the cover on the page. a couple of functions that will help you with that are getComputedStyle() and currentStyle, the latter is IE’s equivalent of the first.

    Basically, you’ll have to bind a custom event to your car – or whatever element you need, that gets dispatched (or in IE lingo: Fired) each time a key is pressed. That event will have to recalculate change the style of your car/element. Example: the up key is pressed, so the y position must change. Before actually moving the element, you should have an object containing all positions of solid elements in the area. Scan that element to see if the new position your car element is moving to will cause an overlap, if so dispatch/Fire the collision event, if not move car…

    Not this is a really simplified explanation but those are the steps you’ll most likely have to go through on each key press. That’s why I suggested reading up on custom events, handlers, event binding and dispatching.
    If you do write this in pure JavaScript, I can promise you now, hand on heart, there is 1 thing you won’t have to read up on: why JavaScript developers hate IE so much, especially if you want your script to run on IE versions prior to IE9…

    I’ll just end with this: a page to bookmark for stuff like this is javascriptkit. Also, you might prefer to use a framework like jQuery to get round the cross browser issues you will encounter.

    Good luck!

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

Sidebar

Related Questions

I'm brand spankin' new to Javascript. Here's what I want to do. I want
If I want to try out something new in Ruby or Javascript, I love
I want it to have a popup dialog javascript box. Instead of a new
I m new to using Web services using JavaScript. All I want is to
I'm using Nodejs and Socket.io. When the client connects, new JavaScript objects are created.
New to javascript, but I'm sure this is easy. Unfortunately, most of the google
I want to move the rectangle horizontally,however,it enters the updateStageObjects() function several times but
I am new to Javascript I want to create tabbed menu bar in that
i am new in JavaScript programming i want java script to find the names
I am new to javascript and I want to implement a pulley in which

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.