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.

DLL Talk / The Matrix1Utils plugins collection

Author
Message
Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 16th Jul 2007 10:55 Edited at: 16th Jul 2007 10:56
This may seem a bit silly but I would also like to ask for a GetBackdropColor(Camera) function, ideally with a GetCurrentCamera() function.

Set Display Mode will reset the backdrop and there is no way to identify what the last color was.

Thanks.

http://3dfolio.com
vibe runner
17
Years of Service
User Offline
Joined: 7th Aug 2006
Location: The Future
Posted: 17th Jul 2007 15:41 Edited at: 18th Jul 2007 19:58
I think it's daft you have the amazing Array DLL as a seperate package. I think for many people it's "hidden" from view.

Your Array DLL is great. Make it part of the Matrix1 suite, please?
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Jul 2007 17:10
Yes - I have a rewrite of that particular plug-in on my to-do list, and it will be rolled into this pack eventually, as will the ini-file plug-in.

Foe7
17
Years of Service
User Offline
Joined: 26th Mar 2007
Location:
Posted: 22nd Jul 2007 23:54
I was referred to this set of highly usefull functions from this thread:

[href=http://forum.thegamecreators.com/?m=forum_view&t=108603&b=15[/href]

so basically my issue involved the reading of strings from a file, and I expect the strings to be big.

Looking through the commands, I see the memory bank commands, but I am not quite sure how they are used. Is there some way to get them to act like the regular read/write string commands?

Thanks
Xolatron
18
Years of Service
User Offline
Joined: 12th Mar 2006
Location: The Star Forge Language: DBpro
Posted: 23rd Jul 2007 00:40 Edited at: 23rd Jul 2007 00:48
Yes. Here's an example of making a file from a string (like write string, but the whole file must be one string):


(You can combine the strings you want to write by adding each line after a 'chr$(13)+chr$(10)')

I haven't done string reading with it as of yet, so I don't have code for that, sorry. It would work similarly, but in reverse. Note that string indeces start at position 1, while bank indeces start at position 0.

Edit: Here's some [untested] code for reading an entire file into a string:

(you can use 'split string' with a delimeter of 'chr$(13)+chr$(10)' to read individual lines.)

-Xol

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jul 2007 00:51
Yes-ish.

There are two ways that I can think of immediately that will be reasonably fast.

1. Map the file into a bank, read the whole bank as a single string, then use the SPLIT STRING command to break the string into individual lines. This is the method I use for the help-file generator I wrote to build the help files for these plug-ins - the code can be found somewhere on the first page of this thread.

If your files are too large to be working on complete copies in memory, then try method 2 ...

2. Map the file into a bank, then use the SEARCH BANK function to search for each newline in turn, and use the BANK STRING$ function to read each string.



My help files are small enough that memory isn't an issue, so method 1 worked well for me.

The next release of these plug-ins will finally include the obligatory file I/O functions/commands that will easily handle this kind of thing, with lines of any size.

Foe7
17
Years of Service
User Offline
Joined: 26th Mar 2007
Location:
Posted: 23rd Jul 2007 01:02 Edited at: 23rd Jul 2007 01:26
Ah, I see how that works, cool!

And I'm assuming to write the strings, I would do what Xolatron mentioned?

Thanks a ton,

-F7

[EDIT]

Okay...attempting to run it, i get an "unknown exception" at the line where I load a large file, using the "map file to bank" command. Looking back at the source, I see that it is because I used the wrong variable for the file name.

Just an idea...if your plugin is what launched the error message, maybe making it more descriptive? as the filename I passed it was an uninitialized string variable, thus a non-existant file.

Thanks again for the help.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jul 2007 01:25
It might be easier to write the strings as I did in the help-generator - build one very large string containing all of your individual strings separated by newlines, then get its size, map a bank to a file of that size, and poke the whole string into it at one go.

If that's too memory intensive, you can build your strings up to a certain size, then drop them into the mapped bank, then build the next set, drop them in etc.

Better would be to wait a few days for the file plug-in, or use one of the alternatives that are available around the forums ... at least until mine is available

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2007 17:02 Edited at: 29th Jul 2007 17:24
Well, the plug-in pack is up to it's first birthday, and here's a new release to celebrate that fact.

There are 3 new plug-ins in this release:
Matrix1Util_22 - File I/O
Everyone else and his dog has released a File I/O plug-in in the past - here's my version. You won't find anything too different from most peoples plug-ins here, just the little extras that make my plug-ins such a joy to use You can:
- Open files for input, output, update or append
- Read/Write booleans, bytes, words, dwords, integers, floats, double integers, double floats, and strings of any size.
- Strings can be terminated by a Newline (Unix standard), CRLF (DOS Standard), CR (Mac standard), NUL, or can be preceded by the length of the string in either a byte (255 chars), word (65535 chars) or dword (4 billion chars)
- Seek to any position in a file using 64 bit I/O (it means you can have files over 4GB in size)

Matrix1Util_23 - Colour conversion
This plug-in provides enhancements to the RGB colour functions already provided by DBPro, and also includes the following:
- 16 bit RGB with alpha bit
- HSL with alpha
- HSV with alpha
- CMY with alpha
- CMYK (no alpha, there's not enough room in a dword)
- ANSI terminal emulation colours
Functions have been provided for all of the above to convert to and from RGB (except for the ANSI colours).

Matrix1Util_23 - System folders
This plug-in provides pathnames to several useful locations within the system in a system independent manner.

In addition, the following fixes and minor additions have been applied:
Matrix1Util_01 1.0.0.5
- Clearer error message when using a null or empty string for a filename.

Matrix1Util_09 1.0.0.2
- Added VECTOR EXIST function
- Added CURRENT CAMERA function (turned into a right pain because of a DBPro bug - hope you're happy Mistrel!)

Matrix1Util_13 1.0.0.5
- Added IS FULLSCREEN, IS EXCLUSIVE and SCREEN MODE functions
- Added GET DBPRO WINDOW and SET ACTIVE WINDOW functions
- Added window iterators (including search by title or class)
-- (FIRST WINDOW, FIRST WINDOW CLASS, NEXT WINDOW functions)
- Added WINDOW TITLE and WINDOW CLASS functions
- Added functions where the window handle is specified:
-- IS VISIBLE, IS MINIMISED, IS MAXIMISED, IS A WINDOW
- Added MAXIMISE WINDOW, MINIMISE WINDOW, RESTORE WINDOW commands.

Matrix1Util_16 1.0.0.7 (Previously released as a hot-fix)
- Fixed the FAST UPPER$ and FAST LOWER$ functions that were broken in the last release.

Lastly, the help-file generator has been enhanced slightly - you'll see the results in the index pages of the 3 new plug-ins. The next release will hopefully contain the equivalent enhancements spread to the other plug-ins.

Attachments

Login to view attachments
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2007 17:08
Here's code for the easiest new plug-in first - directories



IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2007 17:29
Here are the colours in action:

The reason for the apparent duplication of colour display was to test the conversion of each type to rgb, back again, and finally back to rgb without apparent loss of quality

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2007 17:32
*Sigh* Well, wouldn't you know it. I've just seen that the improvements to the help file indexes haven't taken too well They looked good in IE & FF, but not in the DBPro help.

Ah well, at least they are usable.

Xolatron
18
Years of Service
User Offline
Joined: 12th Mar 2006
Location: The Star Forge Language: DBpro
Posted: 29th Jul 2007 18:40
Awesome - thanks!

Can't believe I just wrote a bunch of functions that do exactly what your directory ones do (including the DIR DBPRO TEMP() too). But I'm certain that these will help the speed (especially the DBPRO TEMP() - no more trial and error)

IS MAXIMIZED() could be quite useful. I've been using a check to see if the window width was equal to that of a maximized window up to now.

I also have two requests for the directories plugin (I know, more work, but it would be even more awesome than it already is ):
First, I'd like to see folders such as 'My Music' and 'My Pictures' located. Below is a list of all the usefull CSIDL values I've found (you've got most of them, but there are some useful extras as well):


Also, I'd like to be able to do something like SET DIR MYMUSIC(path$) to set the Known-folder directory. This invloves a call to
SHSetFolderPath, except that it must be called through "GetProcAddress with ordinal 231 for SHSetFolderPathA (for ANSI strings) or ordinal 232 for SHSetFolderPathW (for Unicode strings) to obtain a function pointer.", which is over my head in DBpro.

And again, thanks!

-Xol

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2007 22:33
Quote: "IS MAXIMIZED() could be quite useful"

GET SCREEN MODE may be even more useful. It combines all of the fullscreen/windowed/exclusive checks into a single function.

Quote: "I also have two requests for the directories plugin"

Ok, there are some folders there that I haven't provided access to that may be useful as well - MYMUSIC, MYPICTURES & MYVIDEOS in particular, but maybe also SENDTO. I'm not sure about STARTUP and STARTMENU though.
You'd need to be able to create shortcuts to use SENDTO, STARTUP & STARTMENU properly though.

I'm not sure about providing access to set paths though - a guy could cause all sorts of problems with the standard running of the system by doing that, and I'm not sure there's any need for it anyway.

Convince me.

Xolatron
18
Years of Service
User Offline
Joined: 12th Mar 2006
Location: The Star Forge Language: DBpro
Posted: 30th Jul 2007 00:41 Edited at: 30th Jul 2007 00:42
Arrghh... I lost my post. This is the abridged re-write. A apologise beforehand for the breif and hastily-written nature of what really ought to be a longer post...

Yay for GET SCREEN MODE()!

I forgot about the need for shortcuts for those folders, since I already found a way to make them (by way of a free dll)

The set dir request was in response to something that happened to me recently (that is, yesterday ) - Windows decided to set the string for my 'My Music' folder to "". Every check to SHGetFolderPathA would return this, and it was very annoying.

To remedy this problem, I looked up SHSetFolderPath, but you can only use that with pointers, as I mentioned, and that sounded very hard to accomplish in DBpro.

The request was due to the fact that programs calling DIR DOCUMENTS() expect a valid (if not existing) pathname as a return value. A blank string returned could wreak havoc on a lot of programs if they ran on a computer with the same problem as I have (only for 'My Documents' or 'Program Files'). The program would try to write to 'MySoftwareName' rather than 'Crogram FilesMySoftwareName', and the whole program could crash, or at least decide not to run.

You are correct about the problems that could arise, however, so I propose a safe solution: if the string returned by SHGetFolderPath is not a valid path ("" or a string not beginning with a drive, whatever), then your plugin could call SHSetFolderPath internally to reset that folder's location to it's default path before returning the string to the DBpro program, thus ensuring that DIR DOCUMENTS() etc. always return valid directory paths.

But that would probalby take a lot of work (and I'm happy enough with plenty of new functions to try ), so don't worry about it if it would take to much effort. It's sort-of minor, really.

-Xol

Edit: Okay, maybe that wasn't so breif after all.

Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 31st Jul 2007 07:11
The temp dir returned by Dir Dbpro Temp() has an extra backslash.

Quote: "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\\dbpdata30"


Was there a reason for not using long file names?

http://3dfolio.com
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 31st Jul 2007 13:47
Yes - it's generated by Lees code, not mine. I just found it an exposed it.

I didn't consider the effort of cleaning the path worthwhile - but since then I may have come up with a simple way of cleaning it and providing long filenames.

Maybe in the next release.

Xolatron
18
Years of Service
User Offline
Joined: 12th Mar 2006
Location: The Star Forge Language: DBpro
Posted: 31st Jul 2007 17:01
It's because GetTempPathA returns the Windows temporary path with a backslash on the end and uses short directory names. Neither the shortened name nor the extra backslash should cause any problems, though.

-Xol

CJD
18
Years of Service
User Offline
Joined: 15th Mar 2006
Location:
Posted: 31st Jul 2007 19:35 Edited at: 31st Jul 2007 19:35
On the console plugin help page it says:

Quote: "The second form of this command will force the cursor to move to the start of the next line, scrolling the contents of the window if necessary.
"


Yet the commands below are both the same "print console". How can i get the console to automatically go onto a new line after each print?

Thanks.

EDIT: and i should have said, brilliant plugin pack!!

Your signature has been erased by a mod because it's larger than 600x120
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 31st Jul 2007 19:59
Quote: "Yet the commands below are both the same "print console""

That's a bug - I used angled brackets, which of course, won't show up in HTML.

The actual usage is:


Basically, if you provide variables or constants after the PRINT CONSOLE command, then they will be printed one after the other, and won't cause a newline. If you provide nothing after the command, it will print a newline.

They use the same command because I didn't want to include another command simply to write a newline - there's nothing to stop you printing CHR$(13)+CHR$(10) if you don't want to use the second form though.

It's the closest I could get to the behaviour of the DBPro print command - Lee cheats by including compiler support

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Aug 2007 20:06
Quote: "You are correct about the problems that could arise, however, so I propose a safe solution: if the string returned by SHGetFolderPath is not a valid path ("" or a string not beginning with a drive, whatever), then your plugin could call SHSetFolderPath internally to reset that folder's location to it's default path before returning the string to the DBpro program, thus ensuring that DIR DOCUMENTS() etc. always return valid directory paths."


I've decided to NOT do this - The vast majority of systems will have the correct paths anyway, and any that do not may have other problems too (corrupt registry for example). In addition, I could only make a guess for the correct folder for English-language installations - not at all for non English ones.

I've just written those 4 extra DIR commands and added the fixes for the double backslash & short filenames, plus I've added a plug-in for maintaining links (particularly for desktop and sendto shortcuts) - they'll all be in the next release.

Xolatron
18
Years of Service
User Offline
Joined: 12th Mar 2006
Location: The Star Forge Language: DBpro
Posted: 4th Aug 2007 20:42
That's fine. For reasons unknown to me, Windows decided to reset the path anyways ... looks like this would probably happen on most systems anyways.

Quote: "I've just written those 4 extra DIR commands"

Awesome; Thanks.

Quote: "I've added a plug-in for maintaining links (particularly for desktop and sendto shortcuts)"

Even more awesome! Anyone wanting to publish their program will surely want shortcut-capability.

-Xol

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Aug 2007 00:26
Seeing as I've moved so far from the top of the first page, I've decided to release the next update

There are lots of changes here, plus two new plug-ins.
New plug-ins first:
Matrix1Util_25 1.0.0.1
- New plug-in for reading and updating windows link files

Matrix1Util_26 1.0.0.1
- New plug-in for callbacks during different stages of the sync process
- Also included the CURRENT CAMERA function from Matrix1Util_09

More on plug-in number 26 in a later post ... some of you will really like that one.


Here are the changes I've made to the existing plug-ins:
Matrix1Util_07 1.1.0.0
- Corrected function names for * TO DECIMAL functions

Matrix1Util_09 1.1.0.0
- Removed function CURRENT CAMERA (moved to Matrix1Util_26)

Matrix1Util_11 1.1.0.0
- Fixed problem in the help file for PRINT CONSOLE command

Matrix1Util_12 1.1.0.0
- Added a new version of the ADD LIMB command
- Added 3 new APPEND LIMB functions/commands

Matrix1Util_15 1.1.0.0
- Somewhere along the line, exporting of some functions was broken.
-- Fixed ENABLE SPECIAL KEYS / DISABLE SPECIAL KEYS
- Updated disable to handle Windows/Escape (same as Alt-F4)

Matrix1Util_16 1.1.0.0
- Changed COUNT to STRING COUNT in the help file
- Added EXPAND ENVIRONMENT$ function to expand strings containing %environmentsymbols%
- Modified SPLIT STRING to reuse working storage on repeated runs where applicable
- Modified all string search routines to operate a little faster

Matrix1Util_18 1.1.0.0
- Added 2 new MAKE OBJECT commands to create blank objects

Matrix1Util_19 1.1.0.0
- Internal change on error checking/reporting

Matrix1Util_20 1.1.0.0
- Added 8 new commands and functions for coroutines (co-operative multi-threading).

Matrix1Util_24 1.1.0.0
- Ensure that all paths returned are 'clean'.
- Added DIR SENDTO, DIR MYMUSIC, DIR MYPICTURES and DIR MYVIDEO functions.

Lots of new functionality there, most notably coroutines (a kind of cooperative multitasking), raw object creation, and disabling all those special keys on Win2K & XP.

You might also notice that I've incremented the version number on all of the plug-ins except for the 2 new ones to 1.1.0.0. It seemed like a good idea at the time.

A few examples of the new stuff will follow soon.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code

Attachments

Login to view attachments
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Aug 2007 00:50
I'll cover coroutines first, a part of the function pointer plug-in.

One of the harder things we have to do as programmers is to write code that can stop part way through, then pick up where it left off a little later (pathfinding comes immediately to mind).

The solution that most immediately springs to mind is to add multi-threading to DBPro - unfortunately, DBPro wasn't designed or written with that in mind, so most attempts at multi-threading will work ... until suddenly they don't. This is because DBPro may be reading from a memory location in one thread that you are writing to in another.

There is another solution - it's a half-way house between single-threading and multi-threading that a few people may remember from early versions of Windows (3.11 and earlier) - co-operative multi-tasking.

Basically, each thread has total control, until it releases control to another thread. Also known as coroutines.

You can start a long-running function off, and at a certain trigger event (such as elapsed time), switch to another coroutine. That can run for a while, and then switch back. This can repeat as many times as you wish, and you don't need to completely recode your routines to get it to work for you.

Here's a rather simplistic example:


The main process is always coroutine 0. Here we create coroutine 1 simply by getting a function pointer to the function we want to run.
The function in this case will count from 1 to 3, displaying the count each time, and immediately returning control back to the main process.
The main process will run a loop, switching to the coroutine each time until it detects that the coroutine has completed.
It then restarts the coroutine from the top and runs in a loop again, before finally deleting the coroutine and ending.

Ok, this was a simple example, but if you imagine that the coroutine being run was a pathfinding routine that may run as long as 10 seconds. Rather than recode, you can add a check within the function so that if the elapsed time is greater than 5 ms that control is returned to the main process. The main process can pass control back to the pathfinding each loop until it completes. Both routines get their share of the processor, your game continues running, and you didn't have to rewrite your pathfinding to include start/restart logic.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Aug 2007 00:54
A slightly expanded example in the same vein. This one runs two coroutines in parallel, with one of them set to never end.



Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Aug 2007 01:10 Edited at: 30th Aug 2007 01:12
Next, here's the Sync callbacks.

This plug-in was primarily written to allow you to add calls to DBPro functions during different stages of the SYNC process (whether under manual control or not). In actuality it became a little more of that - giving access to various camera information, and allowing you to also set the sprite draw area on screen.

Here's a simple example for the callbacks first, with a little camera information thrown in.


There are two cameras being rendered - the default camera (0), and a new camera (3) - each shows the single cube that has been created. There are three callbacks registered - one at start of sync, one at end of sync, and one at the point where each individual camera is about to be rendered.

The display will show camera details for each camera being rendered. If you press SPACE, camera 3 will be disabled. Pressing RETURN will bring it back. Notice how the camera information for camera 3 disappears, because it is collected as each camera is rendered.

In addition, holding any key except space will hide the cube but only within camera 3. It will still be visible in the main camera.

So now you have a little more control over what you see when DBPro renders your objects in different cameras - maybe someone can do a multi-camera version of LiT's frustrum culling code

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Aug 2007 01:16
Finally for tonight, here's an example of the sprite callbacks:



The sprite is rotated in the callback for sprites. In addition, the sprite is initially limited to being drawn within the area 0,0 to 100,100. Pressing space will set the area to 90,90 to 640,480.

The whole screen can be drawn to by setting the view area to the full window size, at which point, the limiting area will be completely disabled, even if you resize the window to make it larger.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Sep 2007 00:48 Edited at: 4th Sep 2007 00:49
One more, using the new command I've introduced to create 'blank' objects ready for filling in. This is a reworking of my (rather crap) wavy flag code, using the new command, and direct vertex manipulation.



The command to look for is MAKE OBJECT NEW, which allows you to specify the number of vertices, the number of indices and the FVF format of the object.

[EDIT] Added the Union Jack image

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code

Attachments

Login to view attachments
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 10th Sep 2007 12:38
You just don't stop do you?

There isn't much that I can say to praise your DLL's that I haven't already said. They are in my opinion one of only two essential plug-ins for DBP (the other being BlueGUI).

Add to that, the fact the you offer them completely free of charge and you become my hero!

Thank you



IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Sep 2007 01:36
Thanks for the vote ... and despite concentric only using 3 of my plug-ins, it's a great game

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Pixel Paint
16
Years of Service
User Offline
Joined: 15th Sep 2007
Location:
Posted: 16th Sep 2007 00:02
Does anyone know what happened to Utility_14?

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Sep 2007 14:23 Edited at: 20th Sep 2007 14:32
Ian, I'm struggling with HITIMER().

I tried to do a straight replacement of TIMER() with HITIMER() in my code. This doesn't work. I'm using it to work out the number of milliseconds a cycle takes, and basing the movement on this value.

I also tried to use HITIMER(1000), just incase it needed to know I was working in milliseconds. This didn't work either.

Any Advice?

***[EDIT]*** Scrap that, I found references to the original TIMER(). However, it does beg the question - why is the value of Timer() and Timer() different?



Olby
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 21st Sep 2007 16:51 Edited at: 21st Sep 2007 16:52
(sorry for the double post - my internet lost connection)

http://www.olby.times.lv
http://www.myspace.com/producerolby
PentiumIV 1.60GHz, 256MB, NVIDIA GeForce FX 5200 128MB, AC'97, WinXP Pro SP2, DirectX 9.0c (Feb2007), DBPro 6.6b
Olby
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 21st Sep 2007 16:51
Because HITIMER() is more precise as IanM told us in help files. That difference is TIMER()'s incorrect time. I guess so.

http://www.olby.times.lv
http://www.myspace.com/producerolby
PentiumIV 1.60GHz, 256MB, NVIDIA GeForce FX 5200 128MB, AC'97, WinXP Pro SP2, DirectX 9.0c (Feb2007), DBPro 6.6b
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Sep 2007 22:20
Hmmm, no mailback ... it is broken?

@BatVink,
HITIMER() (without a value) is simply a more accurate timing system. It is not compatible with the built-in TIMER() function as it uses a different starting point (HITIMER starts counting when the processor is started - it counts processor ticks, TIMER starts counting sometime during the windows startup - it counts interrupts from the 8253 timer chip or compatible in your PC).

@pixel paint,
It's missing because it's a plug-in that I've started again and again in the past because I couldn't get it just right. At this point though, almost everything I planned on getting it to do is being done by plug-ins 20 and 26, as they turned into a much better place to put the code. I'll probably continue in the same vein with the rest of the functionality and salvage 14 for something else eventually.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Pixel Paint
16
Years of Service
User Offline
Joined: 15th Sep 2007
Location:
Posted: 25th Sep 2007 01:00
Could you try to make something for ZONES that finds out what side of a zone you are detecting? (split it up into 4 parts and return 1,2,3, or 4)

Thanks. Kind of hard, but it will make some things easier.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Sep 2007 19:33
I can do anything

... as long as I understand what you want. I'm not sure what you are asking for - at the moment, your point can be either inside a zone, or outside a zone. What is it that you mean by 'side'.

Also, please bear in mind that your definition should ideally work for 2D and 3D zones.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Pixel Paint
16
Years of Service
User Offline
Joined: 15th Sep 2007
Location:
Posted: 29th Sep 2007 22:40
I was thinking 2D, but it's probally possible with both. I need it to tell me what section like this:

_______
|\ 2 /|
| \ / |
|1 / 3|
| / \ |
|/ 4 \|

Just return the number of the section(I didn't mean side). I don't need it for 3D that much either.

Pixel Paint
16
Years of Service
User Offline
Joined: 15th Sep 2007
Location:
Posted: 30th Sep 2007 19:34
Oops, it didn't work
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Oct 2007 16:19
So what you want to know is which border is the closest to your point? That's doable - in 3D it'd be which side of the cube that makes the zone is the nearest.

Can you tell me what you are using it for? I try not to just add commands to the plug-ins that a single person uses (unless it's me ), and I can't think of general use reason for this function.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Pixel Paint
16
Years of Service
User Offline
Joined: 15th Sep 2007
Location:
Posted: 2nd Oct 2007 00:59
I'm trying to make a game where a ball bounces all over the screen and destroys the blocks. I need it to detect which side of the block the ball is hitting so the game knows which angle to make the ball go next.

deadlyduck
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: United Kingdom
Posted: 2nd Oct 2007 12:36
Not sure if theres an easier way, but the same thing in 3D would be usefull for finding what side of an object is hit by fire.

Front/back/left/right/top/bottom

so if it was a tank for instance you could easily work out the armour, damage etc. of the hit side.

I haven't started working on stuff like that yet, trying to get Dark Physics to move my vehicles, If not quite realisticly then real enough to be fun and look right. So many variables to tweek hehe.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Oct 2007 15:15
@Pixel Paint,
Ok, I can kinda see where you're going with that, but I'm not sure it will solve your problem, and I'm not sure that zones are the right tool to use.

First, having a zone check is not the same as a collision check as that's not what zones were really designed for - think more walking into a trapped area rather than seeing if you hit a wall.

Second, knowing which side your point is currently nearest to doesn't tell you which side you've actually gone through and which to bounce from.

That said though, it might be useful for me to add commands to check for intersections/collisions between points, lines, spheres and boxes, and to maybe more zones in that direction (think spherical zone). *Sigh* means a complete rewrite of zones though.

In the meantime, assuming that you are writing a pong or breakout clone, I can write you a function that you can use to check for moving-sphere to box collisions, and work out the correct end point after rebound. For non-rotated boxes, the maths is easy.

@deadlyduck,
Yes, I've already worked out how it could be done for 3D as well as 2D. I just hadn't decided whether to do it or not

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Pixel Paint
16
Years of Service
User Offline
Joined: 15th Sep 2007
Location:
Posted: 3rd Oct 2007 00:00
Sure! I'd love a function for it! Everything that i tried didn't work though...

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Oct 2007 22:18
Here's the code:


It's still on-topic for this thread - I used the min and max functions from one of the plug-ins

There are two collision functions in there - a simple fast check to see if a circle intersects a rectangle, and a second more detailed check that tells you which side of the rectangle is nearest to the centre of the circle which you can use to tell which side to bounce off - It's close enough to reality that you won't notice the difference too much.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Oct 2007 22:30
@IanM
I have a serious problem with the memory commands! I am using them to simulate inheritance and polymorphism (I need to store shapes, which could be circles/boxes/polygons and all have position and rotation data). However, sometimes when allocating new memory, or writing to some memory the program crashes with a 'blah blah blah has encountered a problem and needs to close'. I am quite sure it is a problem with your plugin, but I can send you the whole code if you need it.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Oct 2007 22:48
Sure, I'll take a look - I'd prefer smaller bits of code that reproduce the problem instead, but if it's too hard to reproduce, then just send your code.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Oct 2007 23:39 Edited at: 4th Oct 2007 23:40
I sent you the code by email, thanks for the help

You need to create a folder called shapes in the folder in which the program is run. The folder can be empty, it just needs to be there.

Pixel Paint
16
Years of Service
User Offline
Joined: 15th Sep 2007
Location:
Posted: 9th Oct 2007 03:28
Ok, thanks, but I can't get it intergraded into my code for the game(using sprites.)

I'll keep trying.

Also, another suggestion, could you maybe try to make a command that changes a specific color in a bitmap to another? I have code for it, but it's annoying to use(with the resizing problem with images).
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Oct 2007 23:43
Sure you can. You can use the sprite x & y positions to get the start point of your box, then add the sprite width & height to get the end point. The circle is simply the centre of your ball sprite and the radius of it.

The code's there. Use it, or not - it made me remember how to do it properly, so I got what I needed out of it.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code

Login to post a reply

Server time is: 2024-04-16 17:17:15
Your offset time is: 2024-04-16 17:17:15