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 / Mousemove([X and Y])

Author
Message
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 1st Dec 2005 22:52
Help page says:
Quote: "This command will get the current integer X movement value of the mouse pointer. Instead of the actual mouse position, this command returns the difference between the current mouse X position and the last mouse X position."


is this speed it's mentioning:
a number of frames
a number of milliseconds
something else I've not thought of?

No matter what value I try for speed it doesn't seem to work as I want it to (moves to its new position too quickly).

Hope someone can help me as this is frustrating me...

...maybe one day I'll finish a project
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Dec 2005 04:13 Edited at: 2nd Dec 2005 04:16
Take a look at the camera rotate example in the Code Hints section of my web site (DBC code - it doesn't work the same in DBP).

Depends what you are doing, but it might be better to use MouseX() or MouseY() and calculate the amount moved instead of MouseMove.

TDK_Man

Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 2nd Dec 2005 19:29 Edited at: 2nd Dec 2005 19:29
It depends on where SimSmall is useing it for.

the mousemoveXY() comands return how many pixels the cursor has moves between every update of the screen (or maby between every time the command is called).

hope this awnsers your question

Don't look at my sig!
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 2nd Dec 2005 20:20
Actually none of you could have helped... (sorry )

Quote: "speed it's mentioning"


I was thinking perhaps the answer to my problem was to do with curveangle() - there's no speed in mousemove... So I'll try again...

Here goes:

Quote: "CURVEVALUE()
This command will return an auto-interpolated value based on a given speed. This command will gradually move a number from its current value to a destination value at a certain speed. This command can be used to create the technique of controlling a cars velocity as it breaks to a halt. The parameters should be specified using real numbers.

SYNTAX
Return Value=CURVEVALUE(Destination Value, Current Value, Speed Value)"


Now is THIS speed any of what I thought of in post 1?

OR

mousemove(x or y) is this value updated once per loop or each time the command is used... unfortunately in the post above Link102 has already said he didn't know (I presume 'he' anyway)

My minor annoyance is that is that mousemoving moves far too quickly then doesn't move at all for a few frames (only if sync rate is above 40, but I have it set at 0)...

Now I've hopefully made things slightly more logical, Could anyone help now?

...maybe one day I'll finish a project
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 2nd Dec 2005 21:40
it updates once per loop, so stick the returned results into a variable before you use em, if the movement is too large then just divide the returned result by the required amount, or add your movement value something like

by_one=mousevalue/abs(mousevalue)

so it returns either -1 or 1

eg

-234/234=-1

234/234=1

is that what you wanted?



Is a Troll actualy a Chav who`s on the net?, are Chavs capable of using the net? if they are, what idiot trained em?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Dec 2005 21:49
What are you trying to do?

I assume from what you've said so far is that you are trying to move a 3D object on screen using the mouse, but it's difficult to figure out exactly what isn't working from your posts so far.

Maybe a bit of non-working code would help, along with a bit of info on what it should be doing.

TDK_Man

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 2nd Dec 2005 22:23
It's a performance problem

Running the code in its own dba file - no problem, completely smooth, exactly as I want it to... run with the rest of the game - not so smooth... But it was mouselooking that had problems, I've just got to try and de-clutter the screen...

still need code posting?

...maybe one day I'll finish a project
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th Dec 2005 06:46
Ah OK - with you now.

I assume you are already using If Object In Screen()?

Also, I don't know if you are using Sync Rate 0 or not, but if you are, what happens if you set it to Sync Rate 60?

TDK_Man

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 8th Dec 2005 13:46 Edited at: 8th Dec 2005 13:48
Sync rate can be a bit iffy...

When set as:/It runs (insert number here) frames a second:
40/34
41/34
42/34
43/34
44/40
45/40
46/40
47/40
48/51
49/51
50/51
51+/51 - 99 (never quite reaches the 100!)

I'm not actually familiar with object in screen, and just now checked to see if the command even existed... Never seen the command before but don't know how it will help me? perhaps something like this?:



but I've hidden an object, surely it will always return zero for this...

The REAL solution is to get some new parts for my machine 1.66 Ghz isn't really accptable anymore that was top notch 5 years ago

...maybe one day I'll finish a project
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Dec 2005 20:26 Edited at: 8th Dec 2005 20:30
Quote: "that was top notch 5 years ago"




Five years is an eternity in the world of computers! When I deliver a new computer to a customer, I tell them it will be obsolete in around three to six months!

A five year old computer is a practically a museum piece.

To keep my machine relatively up to date, I upgrade odds and ends fairly frequently and upgrade the CPU (and motherboard if necessary) every 12-18 months.

That way, the cost is spread gradually and you never end up with a complete box of ancient parts.

1.6 Gig isn't too bad CPU-wise, so if the budget is tight I would suggest that upgrading the GFX card (if your current one has less than 128MB DDR memory) would be the best option to give the best improvement for the outlay.

Anyway, back to the fps problem...

Your snippet is on the right lines.

I use a counter variable - like ObjCount - which is incremented when the program creates an object and decremented when it deletes an object.

You then always know how many objects there are. So, your For..Next loop can count from 1 to ObjCount instead of 65535 - saving time.

When you hide an object, it's not the same as deleting - it still exists.



TDK_Man

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 8th Dec 2005 22:31
Quote: "I use a counter variable - like ObjCount - which is incremented when the program creates an object and decremented when it deletes an object"


Would this work? If I had, say 32 objects and deleted number 17 - the counter would now say I had 31, and so poor object number 32 would be forgotten, and when it gets to 17, it gets a tiny little rest.

by tomorrow morning I'll probably be able to adapt it to work, but right now I'm a little puzzled by it...

...maybe one day I'll finish a project
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Dec 2005 16:14
Yes sorry - a typo on my part.

I wrote that in the early hours and went to bed. It dawned on me just before I nodded off to sleep that I'd make a mistake.

Quote: "I use a counter variable - like ObjCount - which is incremented when the program creates an object and decremented when it deletes an object."


should have said:

Quote: "I use a counter variable - like ObjCount - which is incremented when the program creates an object but NOT decremented when it deletes an object."


Even if you do delete some objects, the For...Next loop will not have to test for the existence of anywhere near 65535 objects which will be much faster.

TDK_Man

Login to post a reply

Server time is: 2025-05-22 20:15:41
Your offset time is: 2025-05-22 20:15:41