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 Discussion / Sprites are so slow

Author
Message
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Sep 2008 00:44 Edited at: 25th Sep 2008 00:47
My editor can't continue to be made unless I find an alternative, because dbc's sprites are so ridiculously slow, I have 22 sprites, and it drags my fps down from 80 to about 50. Are there any dll's or alternative commands to construct a gui with?



Attachments

Login to view attachments
Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 25th Sep 2008 02:12 Edited at: 25th Sep 2008 02:13
I dont know if you checked out TDK's "Tutorial - The Definitive Guide To Making In-Game Menus" it's still on the forum just scroll down and take a look if you haven't. In the methods he explained about, the first one is the fastest in terms of speed it's just not the cleanest looking. The second is effective for specific kind of buttons but the Point(x,y) is SLOW! Then there's method 3, that's what you're doing, it's also slow because of sprites.

Personaly I only use a combination of the first 2 method. Mostly the first one, for performance. By the way that's an awsome looking game.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Sep 2008 02:44 Edited at: 25th Sep 2008 02:55
Actually, my speed problems doesn't come from using the sprites in any way, just creating them. For example, disabling everything in my main loop, I get 100 fps. But if I disable everything in my main loop and comment out the lines where I create sprites, I get 240-250 fps.

Quote: "By the way that's an awsome looking game."


Thanks.

Edit: Would Advanced Sprites work with Dark Basic Classic?
Also, how would I go about measuring the time it takes to do certain tasks and then get a mean out of them in DBC? I would like to see what runs slowest in my program and try to speed them up.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Sep 2008 03:40 Edited at: 25th Sep 2008 03:43
If you don't need transparency or if you can manage the redraw of the sprite yourself, turning these off for the sprite will increase performance dramatically. Use the command
SET SPRITE <num>,redraw,transparency

In this first example, I draw 100 sprites with redraw and transparency on. I get FPS of about 148:



In this next example, I turn off transparency and redraw for all of the sprites. I get FPS of about 450. A dramatic increase.



Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Sep 2008 03:48
I understand what you mean by transparency, but what do you mean if you "redraw" the sprite?

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Sep 2008 04:44 Edited at: 25th Sep 2008 04:46
The reason a sprite stays on the screen and keeps it's shape without smearing when it's moved is because it automatically places itself on the screen, then cleans up after itself when moved, and redraws itself in a new location. It essencially always redraws itself and clears out any image it leaves behind. You can turn this redraw off which takes the processing away from the sprite itself. When the redraw is turned off, if you move the sprite, it will leave behind a trail of itself. You can cleanup the trail by clearing the screen. It's much faster than letting the sprite cleanup after itself. And if the sprite does it's own redraw, it will constantly be doing that whether you clear the screen or not. That is how sprites appear above everything else - they have their own processes going on.

If you want to boost performance even more, hide the sprite (Hide Sprite num) and only PASTE it to where you need it to appear. You don't have to unhide it to paste it. Also, a hidden sprite will still detect collision. You can Sprite <num>,x,y,<img> then Paste Sprite <num>,x,y and the sprite will be hidden and in the proper position if collision is needed.

Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Sep 2008 05:07
Quote: "If you want to boost performance even more, hide the sprite (Hide Sprite num) and only PASTE it to where you need it to appear. You don't have to unhide it to paste it. Also, a hidden sprite will still detect collision. You can Sprite <num>,x,y,<img> then Paste Sprite <num>,x,y and the sprite will be hidden and in the proper position if collision is needed.
"

Yes I was doing that already. And thanks for the explanation about the "clean up"

Also, how would I go about measuring the time it takes to do certain tasks and then get a mean out of them in DBC? I would like to see what runs slowest in my program and try to speed them up.

Irojo
17
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 25th Sep 2008 06:48
I know this isn't help for you, but is that that awesome zombie game that you've been working on? The one that you were having problems with zombies offscreen? It's looking great.


I download memory.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Sep 2008 15:19
Quote: "I know this isn't help for you, but is that that awesome zombie game that you've been working on? The one that you were having problems with zombies offscreen? It's looking great.
"


Yes it is, thanks! I'm actually surprised with myself that I could get this far, I usually like to drop a project not to long after I start it, lol.

Irojo
17
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 25th Sep 2008 15:22
As do I.

Are the zombies code generated? O_o


I download memory.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Sep 2008 22:56
No, but they are most likely placeholder.

Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 25th Sep 2008 23:18
Satchmo what happens when you have more files than your gui can handle, I can give you some tips on sliders if you want.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 26th Sep 2008 01:27 Edited at: 26th Sep 2008 02:07
Actually , I was thinking about sliders, but thought they would be too hard, so I was thinking of putting in pages, but I have not yet done so, so currently they will just overlap. Some tips on sliders would be nice though, thanks.

Edit: Man this sucks, I've always had this problem but kind of pushed it off until now, it seems that I build an exe of the editor, and test it, even with no level loaded it maxes at about 28, and dips to 20 with a medium sized level, half of the forty I get when using it in the dbc editor.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Sep 2008 09:14
Quote: "Also, how would I go about measuring the time it takes to do certain tasks and then get a mean out of them in DBC?"


Well, if you can isolate your specific tasks, you can run them in a loop of set iterations, get a time for the run, and get a basic benchmark for that particular task. For example, I'll create a function that adds 2 randum numbers together and run it through a loop 100000 times. I'll time it to get a gist of how long it takes to perform that task:



You can do this for subroutines or functions or anything in your program to get an idea of what parts take longer than others. Just make sure to run the same number of iterations for each task you want to test.

The things to check for in your program that can slow things down are functions within functions, loops within loops, not using sync on or forgetting to put a SYNC in the correct place, too many objects on screen at once, objects off screen not being hidden or deleted, using color object instead of a small texture of one color, using lot's of off-screen bitmaps (not pictures but screen bitmaps that you create using CREATE BITMAP or LOAD BITMAP), using lots of drawing commands instead of pasting images... there are lot's of other things but these are pretty common.

Quote: "I've always had this problem but kind of pushed it off until now, it seems that I build an exe of the editor, and test it, even with no level loaded it maxes at about 28, and dips to 20 "


Yeah, fullscreen mode exes in DBC tend to run a lot slower than when in the editor. Try using windowed mode for your exes. It usually runs at about the same speed as the editor. Or drop your resolution down to the default 640x480x16 in fullscreen mode - though that may not look the way you want.

Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 26th Sep 2008 18:14
Quote: "Yeah, fullscreen mode exes in DBC tend to run a lot slower than when in the editor. Try using windowed mode for your exes. It usually runs at about the same speed as the editor. Or drop your resolution down to the default 640x480x16 in fullscreen mode - though that may not look the way you want."


Is there any way I can increase the window size(stretch it) without increasing the resolution?

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Sep 2008 01:07
In window mode, the bit depth is always whatever the window's desktop is. If you use set display mode x,y,depth that will resize the resolution but the depth will be the windows desktop depth - so you can't stretch the view without increasing the resolution. You can change the window size, but depending on the resolution you might have a small box centered in the window. SET WINDOW SIZE ...

Enjoy your day.
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 27th Sep 2008 10:15
Hi,

You can try something that should improve your fps.
Make all renders inside a bitmap 1 (same size than bitmap 0) and juste before the sync copy bitmap 1 on 0.
On DB v1 it gives a really faster result than directly drawing all in the bitmap 0
Especially when you use Paste Images ... Then, try to replace your sprites with paste image ...

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Sep 2008 11:10
WOW Freddix! I just tested that out with 100 drawings that take 22 seconds when drawn directly to bitmap 0. It takes 5 seconds when I draw them to bitmap 1 then copy bitmap 1 to 0 . I never knew that - and would have suspected that drawing and then using the copy bitmap command would have been a little slower than just drawing to sceen 0! Thanks!

Enjoy your day.
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 28th Sep 2008 02:12
In fact, I think it's because images are stores in system memory, bitmap 0 in graphic memory and others bitmaps in system memory too.
If you make many memory transfert from system memory (images/sprites) inside graphic card (bitmap 0), it's slow .. If you make all your drawing in system memory that is fast ( Images/Sprites -> Bitmap 1) and then simply made 1 system memory to graphic memory transfer ... it's faster

Gandalf said: "All we have to decide is what to do with the time that is given to us"
Odyssey-Creators - X-Quad Editor - 3DMapEditor
Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 28th Sep 2008 05:51 Edited at: 28th Sep 2008 06:00
Well this is intresting, I'll have to use this.

[edit]

WOW tried it also and it's wonderful!!! Anyone using a tile based game HAVE to use this imo.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 28th Sep 2008 22:36
Hey, if I posted my code here, would anybody be able to compile a medialess exe for me? Because whenever I play a game like soulhunter or blockverse, it runs perfectly and compared to my exe's they run ALOT faster.

Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 28th Sep 2008 22:47 Edited at: 28th Sep 2008 22:53
Sure I'll compile it for ya. Not sure if there's much difference but why not try.

[edit]
ohh by the way I have a file scanner function posted on the darkNoob project, check it out if you'd like to see how I do sliders when searching for files.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 28th Sep 2008 22:50
Thanks, here.


Feel free to look it over if you want.

Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 28th Sep 2008 22:53
Here ya go, the exe.

Attachments

Login to view attachments
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 28th Sep 2008 22:58
Thanks, I get about the same fps, I guess it just comes down to my editor being slow.

Yodaman Jer
User Banned
Posted: 29th Sep 2008 17:20
Quote: "I usually like to drop a project not to long after I start it..."


I kept doing that, but I'm a noob so I use that as my excuse.

Yodaman Jer

That guy with no idea of what to say here. Except that he is a geek, and likes cheese. And pickles. But mostly cheese.

Login to post a reply

Server time is: 2025-06-07 08:05:51
Your offset time is: 2025-06-07 08:05:51