How do I move game objects with a finger in Javascript?

Hi.
I think my <script> learning curve would be most boosted right now, if I could see a .js /htm that allows a player to move a circle /square/dodecahedron / pterodactyl around the screen with a finger.

Also, I see some coders do their scripting inside html and <script> tags and others in .js
Is it inconsequential? or simply a preference.

Thanks
LVL 1
beavoidSelf EmployedAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
You asked, "How do I move game objects with a finger in Javascript?"

Easiest to use a library for this. https://blog.bitsrc.io/11-javascript-animation-libraries-for-2018-9d7ac93a2c59 provides one list + there are many additional Javascript Animation Libraries you can explore.

Experiment with various libraries till you find one which provides feature set you require for app you're developing.
Scott FellDeveloper & EE ModeratorCommented:
Touching and dragging on a screen is the same as using a mouse is the same as using an external graphic tablet is the same as a touchpad on your laptop.  https://www.kirupa.com/html5/drag.htm

It would really be best to take a few days and start a javascript course.  Don't try and fast forward, start with the basics and go from there https://www.codecademy.com/learn/learn-javascript

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott FellDeveloper & EE ModeratorCommented:
I see some coders do their scripting inside html and <script> tags and others in .js
Is it inconsequential? or simply a preference.
It is the same thing.  For long scripts  or scripts that will be used on multiple pages, you will typically see an external file such as
<script src="/path_to/scripts/helloworld.js"></script>

Open in new window

The hellowworld.js will look like
alert("hello world");

Open in new window

When the script is a one off for that page, you will see scripts inside the script tags like
<script>
alert("hello world");
</script>

Open in new window

The external js files do get cached in the browser and this is reason to load it externally along with writing code in just one place.
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

beavoidSelf EmployedAuthor Commented:
Thanks,
As a CS major, does that Academy course cover things that I'd definitely not know, and need to be aware of as a C++/Java pro
It is a big commitment. 12 hours,
but I'd need to know CSS and HTML associated with  JavaScript sites.

For the games I'm going to make, I'm sure I can't leave anything unlearnt. Will it cover touch-select-move?
Will that course cover it all? I am confident that the pages I've found from all my other EE questions on Javascript could get me going immediately. I've got enough examples working to see all the mechanics in place. My major intensions are bullet-proof networking and seamless cross-platform gameplay.
Do you think it's not worth taking the risk of misunderstanding core issues?
Is that course just a class about variable scope, OOP, for loops, if's?
Thanks
beavoidSelf EmployedAuthor Commented:
Thanks,
Scott FellDeveloper & EE ModeratorCommented:
The  codecademy gets you a good basic understanding of the language while getting you up and running quickly compared to reading

When taking your college level courses, did you first start out learning the basics of java and progress to more complex or did you start out programming a payroll system off the bat?   You have to (should) start at the beginning.  You already understand logic so you will be ahead of the game so to speak.  However, if you try to take shortcuts, in the end you will have spent more time going back and forth, fixing and getting it right compared to starting from the start.  I see this happening here all the time.  

Separate the back end and front end. Java being the back end and html/css and javascript being the front end unless of course you are using node, then JS can be the front and back end.  The progression I suggest is learning basic HTML, then CSS then Javascript.  If you have to take a 10 to 20 hour time out to just get the basics understood, it is very small compared to the amount of time you will be frustrated and asking basic questions and waiting for answers.  It will be time saved in the long run if that makes sense.  

Is that course just a class about variable scope, OOP, for loops, if's?
yes, as it pertains to javascript. OOP is not in the basic course. It also covers how JS can interact with the DOM which you will need. But this is why you should start with HTML/CSS first.  

There is also a lot of good info on mozilla https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS. That link also has info for html and css. What I like about the codecademy is you learn interactively vs reading.  The best way to learn is get the basics and then apply to your live project.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Game Programming

From novice to tech pro — start learning today.