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 / Position 2D circle to follow the mouse

Author
Message
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th May 2007 03:06
Yes, I have used the search, which gave huge lines of code that only generated Syntax Errors, and people that said they already knew how to make the object follow the mouse, and asked for something else. I looked through TDK's tutorials AND other tutorials and I couldn't find anything.
Can someone give me a code that creates a 2D circle and makes it follow the mouse?

Aren't I full of questions?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th May 2007 04:04 Edited at: 19th May 2007 04:05
It depends on exactly what you mean. Programming is precise. Your request isn't.

What background is the circle moving over? Do you need to replace the background?

How should the circle follow the mouse?



That follows the mouse, but you are probably not wanting that.

So, please tell us exactly what you want in a bit more detail - we can't read your mind!

TDK_Man

Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th May 2007 06:43
That is what I want, when I try that, the circle still doesn't follow the mouse.

Aren't I full of questions?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th May 2007 07:25
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th May 2007 22:16
It puts the circle at the position of the mouse... then stays there even if I move the mouse.

Aren't I full of questions?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 19th May 2007 23:13
i think he wants the circle to lag behind the cursor

sinani, store the circle's current X position and Y position in variables. each loop, check whether the X position is less than or lower than mouseX(). increase it by a little bit if it's lower, decrease it if it's higher. do the same for the Y position and mouseY()
RUCCUS
21
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 19th May 2007 23:33


Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 20th May 2007 01:19
Quote: "i think he wants the circle to lag behind the cursor"

Lag? Cursor? First of all, the circle should be moving at the same speed of the mouse. Second of all, I should clarify that I am using the HIDE MOUSE command.
Ruccus, your code made a circle, made it stay at the corner of the screen, and then made it disappear.

Aren't I full of questions?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
RUCCUS
21
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 20th May 2007 01:32 Edited at: 20th May 2007 01:33
Works fine for me. Are you talking about the actual code, or an attempt to implement my code into your own? Those are 2 very different things, and my code should work perfectly, unless your sync rate is at like 1.

If you want the circle to just be positioned at the mouse's position at all times... why dont you just draw a circle at the mouse's coordinates :S.

If you want it to follow the mouse with a delay, do what I did above.

Thats all there is to it...

TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th May 2007 18:47
Quote: "It puts the circle at the position of the mouse... then stays there even if I move the mouse."


Hmmm - that sounds very strange.

Might possibly be a Sync problem, but as Ruccus says, any snippet we give you that works on it's own can be rendered useless when you paste it into your own programs - for a multitude of reasons.

So first of all, let's find out if it's a problem with DB or your computer.

Copy the code snippet I posted into an empty DB project and just run it. Does it do what you want it to then?

If it does, then there's something in your code which isn't quite right. In which case, you would be better posting the section of code from your program where the snippet does not work.

You don't need to post the whole program - just create a small example from your program which doesn't work. There's a very good chance that doing that, you will probably discover why it's not working yourself.

TDK_Man

zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 21st May 2007 01:20
TDK, your code works perfect for me. No lag with it just alone, and I even adjusted my mouse settings, just to see if I could break it.

Like you suggested, there must be some tie-ups (inner-loops) in his code slowing down the main loop.

Attila
FPSC Reloaded TGC Backer
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 26th May 2007 14:30
Here is a working sample (DBClassic) . Showing the center of the circle (mouse position on left top) and the mouse is hidden.

TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th May 2007 03:56
He can't be that bothered about it - he hasn't come back in nearly a week!

TDK_Man

SimSmall
21
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 27th May 2007 19:04
I suspect the thread about net games will go much the same way...
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 28th May 2007 02:59
Oh, hi guys.
I found my own way with the circle following the mouse. same goes with the thread about net games.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
SimSmall
21
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 28th May 2007 12:44
Ah, that's good to hear.

Well, good luck with your project

Login to post a reply

Server time is: 2026-07-05 18:37:38
Your offset time is: 2026-07-05 18:37:38