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 Professional Discussion / Effects of Clicks not doing what it meant to

Author
Message
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 12th Apr 2013 17:08 Edited at: 12th Apr 2013 18:16
Here's the code



Everything works fine except the bottom left corner. I have got the coordinates correct as far as I can tell but it isn\'t working. Anyone know why?? I have used three different camera if that makes any difference
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Apr 2013 18:12
Is it possible you could trim your code down to demonstrate the problem.

There is a lot of code there we can't run due to missing images.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 12th Apr 2013 18:16
I think I have trimmed it down to the bare minimal
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Apr 2013 18:41
I'd change your code to check for the mouse button being released, rather than checking for a mouse down. Whats probably happenning is your clicking on a button, and the framerate's so fast that it's changing again whilst your finger's still on the button.

I'd probably do this..


I've added code to report only when the mouse button has been released.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 12th Apr 2013 19:10
Thanks for the reply but it still doesn't work. It mainly to do with the bottom of the screen half way between the "Previous Sketches" text.
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Apr 2013 19:13
Can you explain what you mean by "it doesn't work"
What is actually happening?

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 12th Apr 2013 19:44
Well when I put it in the code it had the same result as it had before.

[img][/img]

The purple bit which goes down isn't meant to go down according to the coordinates or the actual function of the program. I got the coordinates from the mouse cords which you can see are coded to show up in the top right of the program.
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Apr 2013 21:16
But you didn't explain what actually happens? Or what should happen?

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 12th Apr 2013 21:27 Edited at: 12th Apr 2013 21:38
Oh sorry. The thing which is meant to happen is a menu will open to allow the user to select a different design. The thing which happens at the moment is it opens a different menu than the one required which is to spawn in items.

E.g this variable is meant to be PreviousSketchSearch=1 but instead InventoryShipConstruction=1 is done.

I'm not the best at describing it.
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Apr 2013 22:37
I don't know if it'll help, but change all the => and =< to be >= and <=. (Switch the characters around.)

I always do it >= rather than => so it may be a cause.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 13th Apr 2013 02:32
Hi,

Where you're checking to see if the mouse is in the right area, the way you're doing the y boundaries seems wrong to me. For instance:

If mousex()=>326 and mousex()=<357 and mousey()=>200 and mousey()=>210 and mouseclick()=1 then InventoryShipConstruction=1

I.e. mousey() has to be greater than or equal to 200 and mousey() has to be greater than or equal to 210. To my mind this should be: mousey() has to be greater than or equal to 200 and mousey() has to be LESS than or equal to 210.

This does seem to fit the area you highlighted as a problem. Your current code has the bounding box stretching all the way down to the bottom of the screen and overlapping any buttons below it. Because the "InventoryShipConstruction=1" check appears first in the code this would execute first thus giving the issue you described.

Anyway, I hope this helps.

one of these days I'll come up with a better signature
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 13th Apr 2013 02:45
Quote: "mousey()=>200 and mousey()=>210"

I never spotted that. Good call.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 13th Apr 2013 14:24
Hi,
thanks for the reply but It still dosn't work (both suggestions)
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 13th Apr 2013 22:13
Does it not work in the same way as before or is it not working in some new way?

I've had another look and, using Mobiius' suggestion of detecting when the mouse button has been released, come up with a short piece of test code and it works how I imagine it should but I've had to make a few assumptions as to what you're code is doing and what effect you are looking for (for instance, I don't know what RotationLockTimer is supposed to do).



In the demo I've drawn boxes to show where then selection areas are and the coordinates you're using for the Previous Sketches "button" is look too small (it doesn't seem to be the same size as the text judging by the picture you posted).

one of these days I'll come up with a better signature
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 13th Apr 2013 23:56 Edited at: 13th Apr 2013 23:56
I copied your code for the box and is this what you get?

Sorry it isn't very clear.

Also I am still having the same error

[/img]
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Apr 2013 13:41 Edited at: 14th Apr 2013 13:43
The approach you've taken here is not very flexible because you've used literals coordinates; what happens when the screen resolution on a player's machine is different? The coordinates will be off, unless you want to use the same resolution no matter the monitor size, be it laptop or 40 inch.

You should simplify the process; always best to keep it simple. Use sprites and put a pixel sprite under the mouse and test for collision. Each of those screen elements could be sprites. Additionally, screen GUI could also be 3D, using a UI camera and object masking, a hit test object could be placed at the mouse location or you could use Pick Object.

If you fancy sticking to images; use variables instead of literals for user interface elements. Treat each UI element as a UDT; search the forum and Code Corner for UI snippets, there are loads freely available. Perform your hit test from the origin of each UI element.

Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 14th Apr 2013 13:53 Edited at: 14th Apr 2013 13:53
Hi Chris Tate,

I thought you had to write new bits of code for each resolution

I'll try with the objects now then

edit: Forgot to say thanks
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 14th Apr 2013 17:15 Edited at: 14th Apr 2013 17:22
Thanks Chris Tate it worked just can't turn them invisible; any ideas?

Edit:

here's the code and the previous sketches dosn't work still



Please help
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Apr 2013 20:07
If you can't pick an invisible object, set the object alpha mapping to 0; or try masking the object using Set Object Mask.

As a note; an easy way to use screen coordinates is to use the Pick screen command, and place the objects in screen space.

Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 15th Apr 2013 09:38


This is where I got my boxes for the collision (there is one where the inventory is) but the "PreviousSketchSearch" one still dosn't work. It just doesn't do anything; got any ideas?

Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 15th Apr 2013 11:03
The code would work if the object is in the right place. I doubt the object is in the right place. Make sure camera 4 has the same FOV (field of view) as the screen camera otherwise the object will appear in a completely different position in that camera.

Why not try replacing the position object with something like this:



Functions like this lighten the work. All you do is specify the screen position, object , distance and camera; and it does the rest.

Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 16th Apr 2013 19:15
Sorry I don't understand; do I move the object or check for collision of the object with the mouse?

The object collision thing seems to work except the bottom right box. As it work fine with the rest.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 16th Apr 2013 22:06 Edited at: 16th Apr 2013 22:07
Basically replace things like this:

Quote: " If object exist(1000001)=0 then make object box 1000001,40,1,5 : position object 1000001,140,50,242 : hide object 1000001"


with

Quote: "ProjectObject(1000001, Camera, ScreenXPosition, ScreenYPosition, DistanceFromScreen)"


So that you are 100% sure the object is at the correct location from the correct camera, which is 4 in your case. And be sure that Camera 4 has the same FOV as camera 0. Use the function I gave you. Make all objects visible while debugging. And make use of the Set Object Mask command to set what camera objects should render to.

Login to post a reply

Server time is: 2025-05-17 21:42:07
Your offset time is: 2025-05-17 21:42:07