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 / TheComet this is what I had in mind for the unfilled box

Author
Message
Brazos
22
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 7th Jun 2009 03:06 Edited at: 7th Jun 2009 03:43
Thanks for the unfilled box code that you wrote. The following code shows a small sample of what I intended to do with it. If you or anyone sees any way of improving or shortening the code, please let me know. I'm eager to learn new techniques.



Sorry for starting new thread, if I wasn't supposed to. I wanted TheComet to be sure and see this.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 7th Jun 2009 05:51
I have a couple of suggestions...
Instead of that "click" flag you could do this:

Play around with that snippet and you'll see how it works. It would take out a few lines and make your code a bit simpler.

You're checking whether the start position is "less" than the end, that's clever but how about taking that further:

Do the same with y and grab the image ax,ay,bx,by.
As for checking they are on screen; you could look at it as checking how far away from the middle they are If abs(320-startx) < 320.

Using lines to draw the box is slow, use boxes instead (same co-ords).

Enough for one evening I think

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Brazos
22
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 7th Jun 2009 07:33 Edited at: 7th Jun 2009 07:57
I tried your first code and when I make my second selection the start position of the box goes back to the first selection start position. I may have not used the snippet as I should have.

I think I understand your second code snippet.

When I changed the line command to box I lost the left and bottom lines of the select box.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Jun 2009 13:32 Edited at: 7th Jun 2009 13:32
That was cool, Brazos! I'm glad you made something out of that code.

Quote: "Using lines to draw the box is slow, use boxes instead (same co-ords)."


I did some tests in speed, and here are the results:



I drew the empty box with lines 10000 times and checked how long it took, and then did the same with boxes. As you can see, lines are almost 13 times slower than boxes, so use boxes.

Here is the new function:



TheComet


Make the path of your enemies easier with Waypoint Pro!
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Jun 2009 00:03
THANKS! i dindn't know it was that big of a difference but i used it in my WinGUI functions and it cut the update time in half!!!!!

New Site! Check it out \/
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Jun 2009 03:45 Edited at: 8th Jun 2009 03:46
@Comet
As a general tip, try to avoid using numbers in your variable names, they work fine but they make code harder to follow as it looks like there are values in there when there aren't. Stick to letters and you can instantly see you are dealing with variables.

@Bravos
Quote: "I tried your first code and when I make my second selection the start position of the box goes back to the first selection start position."

Do you mean second selection as in the end point?
Or as in the second time you use the whole routine?
Supply the code please.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer

Login to post a reply

Server time is: 2025-05-16 15:24:01
Your offset time is: 2025-05-16 15:24:01