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 / Help with optimising radar code.

Author
Message
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 20th Aug 2010 19:37
Hello,
As the title says, I need some help with some code for making a radar for my FPS game.

The code I have already (see below) works fine, except it causes the frame rate to drop by around 40 frames. I've narrowed the problem down to the 'get image' command, the larger the image captured, the larger the slow down.
Here's my code:



Is there something I've missed?
Is there a better way of doing this?
I've looked in the codebank and there's a very good radar code by Dmitry K called 3D radar but I don't understand it could anyone help with that?

Thanks for the help,
Broken_Code
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 21st Aug 2010 00:25 Edited at: 21st Aug 2010 00:26
There are a few ways you can go about making this better.

The simplest is to make an extra camera, and set this to an image. Then you can use set current bitmap with a negative number to draw to that camera, using the same commands as you are currently. However, it will may be slow if you're using cls. You could draw over your circles with the background colour before moving them and drawing new circles.

I'm sure there are examples of this on the forum, but I can't find it.

Something like




Alternatively, there's a plugin where you can draw to images without using the camera.

Lastly, you can do it in 3D. This is what I've used for radar and it works OK, unless you have a really large number of things on your radar. Here's a snippet I made way back when:

http://forum.thegamecreators.com/?m=forum_view&t=115028&b=6
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 21st Aug 2010 02:13
Thanks for the quick reply,

That 3D radar code is very good, nice and fast (I got 250FPS on that example) and gives a very clear radar, I would never have thought of using limbs for that!

However, I think I will try your other suggestion first as I have attempted that before but couldn't get it working. I'll try again and see what I can get and report back on how it compares to the 3D object limb version and my original code.

Thanks again for the help,
Broken_Code
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 22nd Aug 2010 14:55
I tried the setting a camera to an image way but I think my version of DBP is too old as it doesn't recognise 'set bitmap -1'. In the latest version, however, this method works fine with only around a 4FPS hit on my system.

The limb method is very good, in-game I got a negligible FPS drop and I can texture the backdrop as whatever I want! I added a couple of lines to the start up code:



So nothing that really changes the code but makes it look a bit better without any hassle.

Thanks for the help,
Broken_Code

Login to post a reply

Server time is: 2026-07-23 12:10:36
Your offset time is: 2026-07-23 12:10:36