| View previous topic :: View next topic |
| Author |
Message |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Feb 18, 2003 12:35 am Post subject: Overlapping dialog elements? |
|
|
Is there a way that I can tell if dialog elements are overlapping each
other? I've tried several times to attempt to solve this problem and I
have come up with no solution.
I've tried something like:
| Code: | | if @both(@greater(@fsub(%%top,16),@dlgpos(element,T)),@greater(@fsub(%%left,16),@dlgpos(element,L))) |
But I don't really know how to find if they're overlapping each other.
Any tips would be appreciated very much.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Feb 18, 2003 12:50 am Post subject: |
|
|
If the elements can use a STYLE, ya can test it using a
background color to show where it's actually located...
| Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Test Program",-1,0,200,60
DIALOG ADD,STYLE,S1,,,,CYAN
DIALOG ADD,STYLE,S2,,,,LTGREEN
DIALOG ADD,TEXT,T1,5,5,,,"Test Text",,S1
DIALOG ADD,CHECK,CK1,30,5,,,"Test Checkbox",,,S2
DIALOG SHOW
:EVLOOP
WAIT EVENT
goto @event()
:CLOSE
EXIT
|
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Feb 18, 2003 12:58 am Post subject: |
|
|
Thanks for the idea, but I should make myself clear: I will need to be
checking through code, not the human eye.
But thanks anyway!  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Feb 18, 2003 4:15 am Post subject: |
|
|
Ok... why do ya need to check element overlap with code?
It'd help if we know what you're tryin' to accomplish...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Feb 18, 2003 2:47 pm Post subject: |
|
|
Sorry...
It's for a type of "game" in which you have to avoid obstacles. If one bitmap
overlaps the other then basically you've hit an obstacle.
I'm pretty sure that it would work with some type of code using @dlgpos(),
but I'm not sure about the math that's needed.
I hope this helps you understand better.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Feb 18, 2003 9:16 pm Post subject: |
|
|
OK - I'd keep the element names and positions in a list something
like this:
Element1|30|100
You can then find it with @match(), PARSE to check it's position,
and update it as needed. If the elements are different sizes, ya
can add the width and height also.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Feb 18, 2003 9:18 pm Post subject: |
|
|
Another thing ya might do is cut your layout into an invisible
grid, and when a piece is in that grid space, mark it as occupied.
It's been a while (so I don't really remember), but I prolly used
this method on the checkers game...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Feb 18, 2003 9:29 pm Post subject: |
|
|
They're all good ideas, but in my case I don't think they will help.
The reason for that is that I generate a random number of bitmaps
and you need to move left or right to avoid the oncoming objects.
I'm thinking I'm closer with @dlgpos() to get the object position and the
other object's position and do some math calculations and come up with
an answer to whether they're overlapping each other or not.
Thanks again for all of your ideas and help, they are greatly apprecieated!  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Feb 18, 2003 9:42 pm Post subject: |
|
|
Well, it's your baby....
The thing is - if ya gotta check all positions of every piece,
I think it'd be faster/easier to run thru a list in a loop. Ya
would put the location data in the list when the elements
were created.
I'd like to see it when ya get done.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Feb 18, 2003 9:49 pm Post subject: |
|
|
Question - are all the pieces we're dodging the same size? _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Feb 18, 2003 10:29 pm Post subject: |
|
|
Never mind... here's a basic collision detection routine if that's all
ya wanted. It's not tested, but ya should get the idea...
_______________________________________________________________________________________________________________________________________________________________________________________
| Code: |
if @both(@greater(@sum(%%player_x, %%player_width), %%object_x), @greater(@sum(%%object_x, %%object_width), %%player_x))
if @both(@greater(@sum(%%player_y, %%player_height), %%object_y), @greater(@sum(%%object_y, %%object_height), %%player_y))
INFO Collision!
end
end
|
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Feb 19, 2003 2:05 pm Post subject: |
|
|
| FreezingFire, the loop Mac is telling about is in a way the same as all the MouseOver codes that are posted over here... Maybe you should take a look at one of those? |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Wed Feb 19, 2003 2:09 pm Post subject: |
|
|
Slight difference - ya gotta allow for both the width/height of the
player and width/height of the object...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Feb 19, 2003 2:21 pm Post subject: |
|
|
| Well, if FreezingFire uses your code, and the loop of one of the Mouseover codes, it might work... |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Feb 19, 2003 9:57 pm Post subject: |
|
|
| Mac wrote: | | Question - are all the pieces we're dodging the same size? |
Yes.
Also thank you for the code... I think I've got an idea now! I just needed
the help to get started. Again, thanks.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|