Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Help me fix this angle prob.

Author
Message
Link102
21
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 25th May 2007 19:01 Edited at: 25th May 2007 19:02
Alright, this is my code:

Basicly it's a circle that you can play with useing your mouse.
What I want to reach with this is to see if I can create an entire screen full of circles with you can interact with, useing a little code a posible.

now, as you've probably tried it, you've noticed the angles are totaly screwed. also the ball doesn't always move when you go over it with the mouse (you can't realy hit it hard).
Now I don't realy understand the atanfull cammand and there's probably a few thing to improve on with this code, that's why I've posted it. can you help me?

Don't look at my sig!
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th May 2007 10:50
Hello,

A quick bandage for this is to switch the x and y positions in atanfull. Since this is cartesian coordinates( screen x and y) you want to make sure the slope is being calculated as (y2-y1)/(x2-x1). If you use atanful(x,y) it will have the wrong slope - using (x2-x1)/(y2-y1).

The other thing, I just used trig. I couldn't get it to work with newxvalue and newyvalue so I used sin and cosine. Here is you version with those minor changes I just mentioned. It's still buggy, but it's closer to what I think you were going for:



I whipped up another version similar to yours. My original intent was to get rid of all of the floats because there are no fractions when it comes to screen positions - but I changed my mind because of rounding and things like that.

Anyway, in an attempt to get over the mouse position problem in regards to speed, I created my own mouse pointer and a function to control it's speed. mousemove(speed#) - where speed controls the pointer speed. Put a fraction in there to use only a percent of the actual mouse speed and slow it down. Put a whole number in there to multiply the speed by that amount. This isn't the same speed that get's transferred to the circle, that is still the mousemovex() and mousemovey() average.

I use curvevalue to interpolate the circle's movement over time. I was guessing that is why you had the timer variable. This version is quite buggy also, but I was trying for a few optimizations including getting rid of your distance calculation.

If you move the mouse to fast, it draws two circles. I don't know why.



Enjoy your day.

Login to post a reply

Server time is: 2026-07-12 18:00:05
Your offset time is: 2026-07-12 18:00:05