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 / Speed issues with simple squares

Author
Message
Bulsatar
13
Years of Service
User Offline
Joined: 19th Apr 2011
Location:
Posted: 13th Sep 2011 16:33
Hello Everyone,

This is coming from a little program written for fun in this thread: http://forum.thegamecreators.com/?m=forum_view&t=188948&b=7

When the grid gets over a certain size, it drags the system down really slow! I have taken out the size restrictions so try making a grid that is 75x75 with 10 colors and just watch the timer, you will see what I mean. It isn't doing the calculations on the fly for what color or size all the squares are since they are held in an array. Squares are pretty basic and I thought they would be drawn much faster than that even in a double loop (look at the drawboards() function). Any ideas?



zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 13th Sep 2011 17:04 Edited at: 13th Sep 2011 18:45
{edit} I was suggesting using sprites rather than the 2d commands and ink... but for some reason my test results aren't what I expected.

It seems "box" is a lot faster than I remember. Even more suprising to me is a box of 1 pixel x 1 pixel is 10x's faster than a dot.

try swapping the rem-out to the box or the dot line
I took out the timer code as this speaks for itself.


When I attempted a sprite example, it was about as slow as the dot command.

Your signature has been erased by a mod please reduce it to 600 x 120.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Sep 2011 21:57
These commands aren't the best, but if you want to use them in great numbers, use LOCK PIXELS and UNLOCK PIXELS, wrapping them around your 2D drawing process.

Bulsatar
13
Years of Service
User Offline
Joined: 19th Apr 2011
Location:
Posted: 15th Sep 2011 03:52
So, what would be the better setup for this kind of drawing action, BatVink? Am I looking at things in an incorrect way? Should I force draw the whole playing area and then render it out as a single bitmap?

All help is appreciated

~~~ I tried the Lock/Unlock Pixels, no perceived difference. Got rid of the double loop and made it a single, no perceived difference. Also tried drawing a black box over the timer numbers to blank them out and then draw over it again with the number so that way the numbers don't blur. That worked but now it flickers and it still runs slow when updating even after I added code to only update the playing area after a change has been called (picking a color for instance). Testing with 10 colors and 100x100 grid takes approximately 6.5 seconds to refresh the screen....
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 15th Sep 2011 08:01
It looks like you're drawing the left side of the screen over and over again too. You really only need to draw it once, and grab the image with just the text "New Game", "Help", "Number of Moves:", and "Time Played:". Paste the image and put the only text you need to actually send to the screen (the variables for number of moves, and time). Pasting an image will clear that side of the screen so you don't need to use CLS over and over again either (the right side will be redone by the BOX command).

The part that's remed off (the call to DrawBoards()) needs to be unremed but it should only update the right side of the screen. The left side only needs to be pasted (as mentioned above) every second (in the same area and only when the time changes or a move has been made).

I also noticed that pressing the mouse button no matter where it is adds another move. When the user hits an actual button it is the only time it should add to the number of moves.

To use a single image you may want to check out Sven B's Image Kit where you can use his IK PASTE IMAGE TO IMAGE command. You just have to grab each box color as an image and use it to paste onto a single image, then paste that to the screen. Image Kit is fast too.

http://forum.thegamecreators.com/?m=forum_view&t=176270&b=8&p=0#m2100619

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Sep 2011 22:57
You should also look at Advanced 2D by Diggsey (the search will find it). It's a DLL, you put it in your plugins-user folder and it just works. All of the standard 2D commands are replaced by these, and they are many times faster.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Sep 2011 20:21
The problem with the program is with the fill, not with DBPro's drawing.

75x75 = 5625

Why on earth are you running the fill that many times?


Remove those loops, and make sure that the colour chosen isn't the same as the colour you are overwriting:


It's still slow at 75 x 75, but if you take a quick look back at the floodfill thread you started, you'll see one or two optimisations in there that I posted. Get it as fast as you can, then see if it's fast enough. If not, then I will take you through a rewrite of the fill.

Login to post a reply

Server time is: 2024-11-22 11:53:45
Your offset time is: 2024-11-22 11:53:45