How to use mouseX and mouse Y? https://codepen.io/pandassi/pen/zQGeyG

How to use mouseX and mouse Y? https://codepen.io/pandassi/pen/zQGeyG
0
#1

Hello everyone,

I am starting to learn JavaScript, this is my first project, and I am having trouble with libraries… I learned the basics of JS, only to find out that I need to also learn to work with tons of libraries locally so I’m kind of in desert of despair mode right now as it is confusing. When trying to apply any function that I’ve learnt, nothing comes out of it so I feel that it was for nothing…

Anyway, I am working on processing JS with this one, I am trying to make the duck move along with the cursor but when I use ellipse(mouseX, mouseY, etc, etc); float x = mouseX; and println(pmouseX - mouseX);as seen in some tutorials; but the duck disappears… how could I make all duck elements move with the cursor? Any tip would be greatly appreciated.

https://codepen.io/pandassi/pen/zQGeyG

[Mod Edit: added your link to make it easier for others ]

#2

Hi. So let me begin with this is definitely not a beginner project. Drawing on canvases is a special niche of javascript. What I mean by that is,. it’s likely one of those thing you’ll likely rarely use. I certainly would not judge the language’s ease of use on this project.

Also., javascript doesn’t require a single library. That’s one of the beauty’s of the language. If you don’t want to find yourself redoing something already made,. finding a library can make your job easier,. but it’s not necessary.

If this project means a lot to you,. then I suggest you become familiar with how to make an object follow a cursor first and then apply that idea to your project.

Another suggestion is to place your base64 string css last. Right now we are required to scroll through several lines just to see the other rules.

#3

Nobody likes to read a bunch of text without provided some sort of direction to accomplish their mission.

So I’ve put together a basic example of how you can make an object respond to mouse movement.

https://jsfiddle.net/n9hyaqcj/

#5

Thanks. I did fork someone’s project and worked from there, thinking it might be easier but now I’m stuck.
You’re right about base64 string I’ll fix that.

#6

Thanks I’ll check that out.