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.

Program Announcements / LineMap Plugin for DBP

Author
Message
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 21st Jun 2011 15:04 Edited at: 17th Jul 2011 14:48
The LineMap Collision Plugin is a plugin for DBP that allows you to quickly and easily check for 2D collisions using a line based collision system.

The plugin includes two things: the plugin itself (dll, ini, help files etc.) and a visual editor. The visual editor allows you to draw lines around your game sprites. The linemap file it outputs can then be loaded in your DBP games by the plugin. Linemaps may be manipulated in almost any way that sprites can and can be checked for collisions with one another. The linemap collision system may be used with any sprite position and you position your linemaps manually.

Although this plugin does not do anything that cannot be achieved in DBP (in fact the editor is written in DBP), there are a couple of advantages to using it. Firstly, using this plugin saves you the development time of making your own system. Secondly, in something that involves as many iterations as collision checking, it is worth using a plugin to get the performance benefits of C++ over DBP.

Screenshot of the Editor:


Download HERE.

Update Log


I hope you find it useful

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 27th Jun 2011 10:32
Right well version 1.1.0 is now here with some new updates. I've also taken this opportunity to re-write the first post to make it clearer and more structured. As always, any comments or feedback would be greatly appreciated.

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Jun 2011 12:59
Sounds good, but how does it compare to plugins that handle pixel-perfect collision? What are the benefits?

TheComet

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 28th Jun 2011 16:12
Hi Comet. Right well I should admit at this stage that the only plugin that I've encountered and used for pixel perfect sprite collisions is eXtends so my comments will mostly relate to my experiences with that. However there are a number of advantages of using line collision over pixel perfect collision in general.

Firstly, and this should apply to any pixel perfect plugin, line collision is much much faster whilst collisions are actually occurring. This is because it only has to check for a few line intersections rather than for every pixel in the overlapping areas of the two sprites. Thus, you should be able to achieve a higher fps.

Another advantage of the LineMap plugin is that it can be used with any sprite system and any type of sprite. Some pixel perfect algorithms prefer particular image types as they have to analyse them to check for collisions (eXtends prefers bmps for example). Further, at least in the case of eXtends again, the plugin requires the use of DBP's native sprites. Neither of these is the case with LineMaps as they are entirely separate from the sprites. This is important for a couple of reasons. Firstly, to keep size down, many people prefer to use pngs in their games. The LineMap plugin will support these as well as any other image types you can load into a sprite. Further, if you're using the LineMap collision system for performance reasons, you may well also want to use an alternative sprite system such as Advanced Sprites. As the LineMap plugin is tied to no individual sprite system, this is possible.

Moreover, the LineMap plugin supports almost all transformations supported by DBP's native sprite system (and animated sprites to boot). This is an advantage because pixel perfect algorithms don't always support all these transformations.

Finally, pixel perfect relies on alpha channels which can sometimes be a bit fiddly when you are defining them yourself (as with bmps). LineMaps avoid this.

Hope this clarifies why I think they're useful. If you have any other questions of queries, please do ask.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jun 2011 17:53
Looks like a nice plugin - good to see it!

One more advantage over pixel collision...

Bullets, often they move so fast that pixel collision just can't cope, with line based collision you can use the current and last location to form a line, and give perfect collision detection.

Another advantage...

You can (although I'm not sure if this supports it) return the position that the 2 lines intersect. So if your firing bullets, they can deflect, leave a particle effect, that sort of thing.

Another advantage...

You can use points to signify certain areas on your sprite - like a little car might have some extra points on it's headlights, conveniently. Then you can add effects at these points, headlight effects, vapour trails, bullet exit locations on guns etc etc etc.


And, when you factor in rotation and scaling - with pixel based collision, often this is just a no-go, or it costs a lot of performance. With line based collision scaling and rotation is much cheaper. With similar systems, I've even stored the radius and angle of each point in relation to the centre, so that rotation and scaling is just a slight adjustment, practically free.

Health, Ammo, and bacon and eggs!
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 28th Jun 2011 23:14
Thanks Van B! I've got you and Green Gandalf to thank for helping me the rotation working in this!

Very true about bullets. V1.1 adds the functionality for checking linemaps against temporary lines for this kind of thing. At the moment, the plugin doesn't support finding the position where the two lines intersect. Adding this shouldn't be an issue as the algorithm I'm using finds this anyway I think but how would be a good way to return this, given that a point consists of two numbers?

I'm pleased with the performance of scaling and rotation although as I think we discussed in the thread I posted about my rotation problems, I'm using a system of four coords rather than an angle and a distance. I found sprite offsets were easier to handle this way although it did make some transformations more tricky.

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 7th Jul 2011 00:05
Right, version 1.2.0 is now here with a number of improvements.

First off, in response to Van B's comments, I've added two new commands. These are GET LINEMAP INTERSECTION X and GET LINEMAP INTERSECTION Y and they return the x and y coordinates of the last collision detected. Collisions are only detected when you run the GET LINEMAP COLLISION command.

Another major addition is support for C++. The new version comes with a .lib and .h file for you to include in your C++ projects. The system has only been tested with DarkGDK (and therefore MSVC++) so far but my hope is that as this version of the plugin is now DBP independent, it should be easy to recompile it for use with various other C++ compilers when AppGameKit Tier 2 comes out.

Following on from this, I've also thrown in a second version of the demo. This should do exactly the same things as the DBP demo but is, of course, written in DarkGDK. The documentation has also been updated to include the C++ versions of commands as well as the DBP ones. Mostly, these commands are just the same with the spaces taken out, with brackets and with lm as a prefix. However in some cases, there are changes. For example lmDrawLineMap requires you pass it the functions it will use to draw the linemap. This is so that it can be independent of DarkGDK so it can immediately be used with AppGameKit when it comes out.

Finally, I've done some corrections to the documentation and fixed a couple of glitches in the demo I provided for DBP.

Please feel free to comment and make suggestions and corrections.

I hope you like the updates

The Slayer
Forum Vice President
14
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 7th Jul 2011 14:25
I think it's a great idea for a plugin, Lucas! Nice work.
This could really speed up platformer games or horizontal/vertical shooters, etc...
How much faster is the plugin than the original DBPro collision commands?
Is there a demo that shows this?
Would like to see some examples of this plugin. Thanks.

Keep it up!

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 7th Jul 2011 15:42
Thanks Slayer!

I can't claim that this plugin is faster than DBP's native collision system BUT DBP only supports box collision which is too inaccurate for many games. However whilst no collisions are occurring, there is certainly no penalty with this plugin compared to DBP's commands because of the use of circle collision checks which mean that unnecessary line collision checks are not carried out. However compared to the pixel perfect algorithms used in plugins such as eXtends, I find that during collisions, the frame rate tends to drop to well under half, sometimes as low as a quarter, of the frame rate that existed before a collision occurred. With line based collisions, you will notice little difference during collisions; maybe a 10-20 frames or so drop from a couple of hundred fps.

The download includes two demos, one for DBP the other for DGDK. Both include the source code and the ready-compiled executables which you can just run. Further, if you want to test the linemap editor, you can load the linemap project files used to make the linemaps in the demo.

Thanks for the support

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 17th Jul 2011 14:47
Version 1.2.2 is here. Mostly glitch fixes to the C++ version of the plugin and to the demos. I've also added the new GET LINEMAP INSERSECTION X and GET LINEMAP INTERSECTION Y commands to the demo so you can see how they can be used.

Further to what you were saying about seeing examples The Slayer, it occurred to me that the demos I've included are really tech demos to show how the commands work. If you want to see the plugin in use in an actual game, you can look at the game I published to Intel Appup: RADAR. There is a free demo version which also uses the plugin that you can download. I should qualify this by saying that although this plugin was in fact built for RADAR, it was about the fifth collision technique I used and so to avoid a major rewrite, I didn't use as much of the plugin's functionality as I would have liked. However I do think that it demonstrates that the plugin is stable enough for use in fairly major projects.

Login to post a reply

Server time is: 2024-03-29 02:12:25
Your offset time is: 2024-03-29 02:12:25