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.

Newcomers DBPro Corner / Radar slowdown

Author
Message
GMX
19
Years of Service
User Offline
Joined: 19th Sep 2005
Location: In front of my monitor
Posted: 31st Jul 2007 01:55 Edited at: 31st Jul 2007 01:57
Hello.

I have this code (below) and I'm trying to make a radar appear on the bottom-right corner of the screen. Aside from the fact that this code doesn't even work correctly, it also causes massive slowdown for my machine. I'm not too experienced with DarkBASIC and therefore I don't know any techniques to reduce slowdown. Anybody's insight would be helpful. (this is a flying game by the way)

ships(0) is an array that holds the enemy ships, it's declared dim ships(10). It is created of the type Ship, and the "num" member simply holds the object number of that ship.

p_num is a global variable that holds the player's object number.

xzobjdistance() and FindYDir() are self-declared functions and are posted below...

If I comment out that whole bit of code listed below, it runs at a normal speed, but if I comment out the first half or second half ("half" meaning above or below the for loop) separately, neither time does the program speed up.



xzobjdistance()


FindYDir()


Thank you for any help!

ZOMG
Mr Tank
22
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 31st Jul 2007 03:20
It may be because of using the 2d drawing commands. Just comment out the "circle" commands and see how fast it runs then.

SUPER BADASS SPACESHIP X: WEBSITE
FORUM TOPIC
GMX
19
Years of Service
User Offline
Joined: 19th Sep 2005
Location: In front of my monitor
Posted: 31st Jul 2007 23:56
Hmm, you're right, it is because of those. I commented them out and the program ran fine. If I use a sprite instead of circles, do you think it would work better?

ZOMG
Mr Tank
22
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 1st Aug 2007 02:14
I've never used sprites, but i'm pretty sure they are faster. Also there's a "lock pixels" command you could try with still drawing the circles, but i can't remember whether it speeds up reading or writing stuff to the screen or both. Try searching the forum for it. Maybe even "paste image" will do. Not sure whether this works with transparency though.

I personally try to avoid 2d altogether. My radar consists of 3d objects locked to the screen. Instead of drawing a circle, i use a plain object textured with an image of a circle.

I've promised someone else i'd make a code snippet for this method, so if all else fails you can just use that. Might have to wait a bit though.

SUPER BADASS SPACESHIP X: WEBSITE
FORUM TOPIC
GMX
19
Years of Service
User Offline
Joined: 19th Sep 2005
Location: In front of my monitor
Posted: 1st Aug 2007 03:03
Alright it's cool, I'll try sprites and then 3d objects and see what I come up with. I wouldn't mind having the snippet as well though,

ZOMG
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 1st Aug 2007 04:00
Sprites should work fine. If you prefer to use the circle command you could use d3d_func. It's a dll most useful for when you need to use text, but its circle command is also quick.

Login to post a reply

Server time is: 2024-11-25 13:27:56
Your offset time is: 2024-11-25 13:27:56