Montana-Media-Arts / 120_CreativeCoding

Main Code Repo for MART 120. This contains lecture code examples, the HW Wiki, and HW Code Examples.
https://montana-media-arts.github.io/creative-coding-1/
MIT License
131 stars 13 forks source link

looking for ideas on where to start.. #145

Closed HagenNathaniel closed 6 years ago

HagenNathaniel commented 6 years ago

hey guys!!

I had a crazy idea, that may turn out to be a bit too much...

I was thinking of doing a clock, where the hands turn like they would on a real one.....

but here's the kicker,...they follow the direction of the mouse..

So...go around to the right, and the hands follow that direction, go left, and they go that way..

Sound crazy?

anyway, any ideas where to start?

DVSnell commented 6 years ago

So I haven't looked at this week's material yet (I know, I know. Bad Don.) but if p5 works like similar packages it should be pretty straight-forward: Single line with a fixed pivot point and immovable length set to track/point to Mouse Position X and Mouse Position Y.

This is how a lot of side-view shooters like Metal Slug, TowerFall, and Duck Game work, except they throw in lateral/vertical character movement with a keyboard or gamepad.

spkvfx commented 6 years ago

So, you'll need to think about how you'll convert linear motion into rotational motion. To start, you need to think about what you already know.

You know the position of the mouse in the X or Y axis. You know the width and height of your canvas You know that for every rotation of the minute hand there is 1/12 of a rotation of the hour hand You know that there are 360 Degrees in a circle

You also need to know what you need to define: How quickly should the hands turn in relation to the position of the mouse

It's pretty easy to map the mouse's position degrees of rotation:

rot_minutes = (mouseX/width)*360*rate

where, mouseX/width is the percentage of the mouse's position relative to the width, so multiplying this by the total number of rotations will get you what you're looking for.

But how many degrees should the hour hand travel in that same distance? As I stated, we know that for every rotation the hour hand makes 1/12 of a full rotation. So, if I haven't over-simplified this:

rot_hours = rot_minutes / 12

That seems right to me, but I have the feeling I'm missing something.

I don't think you need to worry about relative position and velocity of the mouse (which I haven't figured out yet). I think you can just just use the absolute position in this particular case.

HagenNathaniel commented 6 years ago

seems like it would be easier to get one hand to rotate, instead of trying both...

another idea, would be to use a similar code to the "man with a spinning head" example, but it wouldn't have to move left and right.

HagenNathaniel commented 6 years ago

seems like it would be easier to get one hand to rotate, instead of trying both...

another idea, would be to use a similar code to the "man with a spinning head" example, but it wouldn't have to move left and right.