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 / - DBPro Coding Challenges -

Author
Message
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Jul 2006 18:59
I wondering how much work is going to get done on this challenge with the 4th of july weekend. Of course, probably half of you live in UK.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
sixblades
21
Years of Service
User Offline
Joined: 30th Jul 2004
Location:
Posted: 1st Jul 2006 20:44
Hmmm...what to choose, what to choose...I could work on my floodfill algorithm...OR i could go explode stuff...
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 1st Jul 2006 21:57
Do both...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 1st Jul 2006 23:52
yes make an exploding flood fill

http://www.cafepress.com/blackarrowgames
Check out my great stuff here
sixblades
21
Years of Service
User Offline
Joined: 30th Jul 2004
Location:
Posted: 2nd Jul 2006 09:15
Arrrg! Ok, I've been working on just the floodfill tool for over a day now and I can't seem to make any progress. I'm using a basic recursive technique that works by checking all of the points around a known valid point, then declaring those as valid points if they are the correct color (it then colors the old valid points and deletes their data). Whenever I run the following code, I seem to just get a small block filled in, then it slows down to a crawl. I think it might have something to do with the size of the array not being properly controlled (I really don't know about much in this area, this is the first time I've used a dynamic array). Any ideas?!

Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 2nd Jul 2006 11:21
If you look at my code above there is a floodfill routine that works fine (most of the time) the only error I get is the same that you likely will by using the point command.

http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 2nd Jul 2006 12:04
This is what I use:


Before you're calling the function the first time (gx,gy = seed pos), you have to control that the Base color (color that should be changed) doesn't equal the current color (ForColor). And ofcourse that gx and gy aren't positioned outside the memblock.
(imgsx is the width of the memblock image. I made it a global)

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
lower logic
20
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 2nd Jul 2006 12:21 Edited at: 2nd Jul 2006 12:22
I started out trying to get sixblades's code to work, but got carried away ended up rewriting more code than I needed to. It works now, but is completely different. You can see the flood fill in progress, which is kinda neat.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Jul 2006 20:14
Alright, I can't seem to figure out what's wrong with my floodfill. Same basic recursive idea, but it keeps crashing silently. The error log says:

Quote: "m_dwRuntimeErrorDWORD=Internal Code:0
m_dwRuntimeErrorLineDWORD=564"


which is this line:
temp = memblock dword(index, pos)




I've checked and rechecked the boundary checks and memblock position a dozen times, it looks ok.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 2nd Jul 2006 20:39
Quote: "((y-1)*width + x - 1)*4 + 12"


That concerns me... Lots of oppertunity for the maths to go in the wrong order. Try chucking in more brackets to make sure all the bits happen in the right order.

[center]
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 2nd Jul 2006 23:18
I hope you didn't make the same mistake as I did:

When pressing, it fills, but keep pressing it -> it will crash, because of the simple infinite loop:

floodfill on one point
floodfill on the next point
and floodfill on the prev point again (because targetColor = temp)

So I'd check if the targetColor <> temp

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Jul 2006 04:43 Edited at: 3rd Jul 2006 09:00
I'm pretty familiar with order of operations, I shouldn't need anymore brackets than I already have. Plus, it's worked fine for everything else.

I put it a simple check to exit the function if its called more than 10k times. It fills part of the area, so its obviously a overflow problem, but then the rest of the program locks, so something is still cause an infinite loop probably.

argh, well i had created a flag to stop repetitive flood filling (like holding the mouse down), too bad I forgot to actually check for the flag. :-p

It's basically working, it just doesn't seem to be able to handle the whole screen at once. Stack size just becomes too great.

Here's an updated function, it should not call the function if the new point is the same as the root point for the current point. (if that makes sense) But it still can't handle the depth.




@Sven,
I tried your code and it has the same issue. I can fill areas under a certain size, but nothing as large as half the screen.

@Hobgoblin Lord,
It takes almost 30s for the fill to cover the whole screen. (btw, I swiped your pencil icon)

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Jul 2006 12:06
There's no friggin way to draw 2D over sprites is there?

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 3rd Jul 2006 12:08
Quote: "It takes almost 30s for the fill to cover the whole screen. (btw, I swiped your pencil icon)"


I have noticed a delay in very large fills though not quite that much. Reminds me of some of the old paint programs I have used where a flood could take 2-3 minutes sometimes. I should probably learn more about memblocks and try using them. On the bright side I have not hit an infinite loop as of yet with it and have gotten it to fill some pretty complex shapes (as long as the point command works)

As for the pencil Icon, no problem, I swiped it from MS paint and just modified it a little

http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Jul 2006 12:37 Edited at: 3rd Jul 2006 12:38
Setup a tool bar for selecting different actions, not all of them are implemented yet. Flood fill somewhat works. The fill size is capped by the number of recursive calls allowed. Handles about 20% of the screen at a time, so its not limited to tiny shapes. Also fixed a bug with layer ordering. Line tool is half complete, shows where the line will be drawn before it does so. The problem is the line drawing behind sprites. I may have to make my own "canvas" and overlay it above the sprites.

I take that back, layer ordering still screwed up and really starting to piss me off.



"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 3rd Jul 2006 22:49 Edited at: 3rd Jul 2006 22:50
Got my flood fill working 100% now. The problem I found was not with the point command but making a white box with the box command. it was not actually all the same color. by setting my initial canvas with the dot command they all now have the same base value. Here is my updated code and a screenie showing a pretty complex (lotsa nooks and crannies) shape I filled out pretty quick.






http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 4th Jul 2006 01:12 Edited at: 4th Jul 2006 01:13
Have added in spray can and starting to add adjustable brushes. You can adjust the spray size at the moment but not the pencil tool.

I finally made an image that looks a little like a drawing





http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 4th Jul 2006 01:20
Wooooooooooooo!! The deadline is looming isn't it? I kinda fancy a go at this - but fear I wont have time :-(

[center]
sixblades
21
Years of Service
User Offline
Joined: 30th Jul 2004
Location:
Posted: 4th Jul 2006 04:12
Arrrrg! I have so much good code already built that I just need to format for the final program to work and already the deadline is getting near...I definitely think I'll pursue this program tho, although I can't say how much I'll get done before the contest ends...
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 4th Jul 2006 11:05
How about an extended deadline as this seems a fairly active challenge?

[center]
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 4th Jul 2006 12:23
Well this is the begining of my entry. Pres space to minimised/maximise and left click on the window while maximised to draw.



[center]
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 4th Jul 2006 12:26 Edited at: 4th Jul 2006 12:27
I think we should ask Dave G to be an extra judge on this one, since he is our resident artist, and get his input on how easy to use and how good a graphic he can make with the different apps.

Here is my latest, you now select the pallete color with the right or left mouse button LMB selects your primary color, RMB your secondary. You can draw/fill with either button and you get the color selected. Boxes are 1 click to start 1 to finish, again color by LMB or RMB. I have implemented drawing with two colors at once at the moment this is activated by pressing the space bar and deactivated the same way. I have also added brush sizes from 1-10 this affects the pencil tool and outlines for 2 tone boxes. Not sure if I mentioned before that the Undo is on Ctrl-Z now. Next up lines, circles, saving, and different size canvas. Then if I have time zooming.








http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 4th Jul 2006 15:47


I added circle/box tool (filled every time), zoom tool (it's the box on the top left of the screen), if you have troubles with the resolution, you can change it to anything you like (though you can't create big images then).

Oh, and click on the colored box (just on top of the 3 rgb bars) to get the color picker.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
lower logic
20
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 5th Jul 2006 12:45 Edited at: 5th Jul 2006 12:53
@Hobgoblin Lord, I agree that an artist, Dave G if he wishes to, should help judge this challenge. Perhaps we could both rate each entry somewhere between 1 (lowest) and 10 (highest) and declare the entry with the highest sum as the winner?

@Sven B, looking great. Could you make the pencil tool draw a continuous line when I keep the mouse button down (like in MS Paint), instead of unconnected dots? That would make it easier to draw curved lines. Also the zoom tool is really cool, very nice.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 5th Jul 2006 13:15 Edited at: 5th Jul 2006 13:17
Quote: "Could you make the pencil tool draw a continuous line when I keep the mouse button down (like in MS Paint), instead of unconnected dots? That would make it easier to draw curved lines."

Ok... Surprisingly, this went pretty well without dropping too much fps.



<edit> Oh and don't mind the color change. If you would have a problem with it, change the constants in the begin of the program to any color you'd like. (Theme = main color, ThemeBack = background color, ThemeTxt = text color, ThemeFont = text font)

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
David Gervais
Retired Moderator
20
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 5th Jul 2006 13:51 Edited at: 5th Jul 2006 23:07
What's this? People are mentioning my name? No wonder my ears were burning. lol

I can pass on my comments on these drawing programs. Let me know who the judge is and I'll feed him/her my thoughts.

Just one thing, please. Sum up the entries in one post so that it is easy for me to grab and test them. (yes I'm lazy, but in a good way.)

Cheers!
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 5th Jul 2006 13:57
@Sven B - CreateWindow is a reserved word, I get a compile error.
Either from DBPro 6.2, or from a package I am beta testing for TGC, or some other plug-in......who knows.

I changed it to CreateWindow2, it works fine now.
BTW, nice paint program!
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 5th Jul 2006 15:07
Quote: "CreateWindow is a reserved word"



I'll change it to SBCreateWindow or something...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 6th Jul 2006 13:18 Edited at: 6th Jul 2006 13:22
@Hobgoblin Lord, also a great job, I love your color picker!

You guys are good!
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 6th Jul 2006 14:55 Edited at: 6th Jul 2006 14:56
Updated screenshot showing my line tool in 1 and 2 color mode all brush sizes.

You can draw a single line or by double clicking it will make a continuos line with a new point at each click until you double click again.



http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 6th Jul 2006 16:11 Edited at: 6th Jul 2006 16:11
Just found out why BillR had CreateWindow as reserved: BlueGUI.
(I know because I just bought it Sorry, i'm proud)

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 6th Jul 2006 18:17 Edited at: 6th Jul 2006 18:20


Wow, my program is getting... big

Anyway, everything should work except for the brush tool (spray tool works). The brush tool will be for a next time, my head is starting to get heavy...

I added:
- load images (only if they aren't too big for the screen. I was thinking of dividing them into multiple window sections when it was too big, and make an export option to put them back together, but I still have to get the deadline, so I left that out).
- export images.
- Resize and move no longer hide the pictures.

<edit> Just saw the deadline was 12.00 tomorrow. Oh well, maybe I'll work a bit on this later, but for now, this is my final.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Daemon
20
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 6th Jul 2006 19:12
@Sven - Don't stop now, you still have a problem to solve (although your sig could have told you that).

When I click to move my image window the image moves outside of the window. It goes back after I stop clicking on it, but it still looks strange.

The image is 512*512. I have a screen shot of before I click it compared to after I click it, when I haven't moved the window.

Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 6th Jul 2006 20:05
Sven it crashes on me when I try to fill a 512x512

http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jul 2006 20:52 Edited at: 7th Jul 2006 00:32
added menus. the layers hide while a menu is active, otherwise the layers will draw over top of the menu.
smoother drawing tool (using lines) with variable thickness
image loading via standard windows open-dialog box.

[rant]
cable trouble in the area and mine feels like im on a 28.8kbps. Been trying to upload an image for 30minutes now, keeps timing out. Not to mention the packet loss.
[/rant]





"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 7th Jul 2006 12:22 Edited at: 7th Jul 2006 12:27
I have been strapped for time lately so don't know if I will get everything in that I want to. Here is the latest version of my art pack in case I don't have a chance to update it later.

I have it set for different size canvases just have not actually coded in changing them yet.

brush width affects - pencil, line, box, and circle

floodfill still a little slow for entire canvas.





http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Jul 2006 13:10 Edited at: 7th Jul 2006 13:55
Quote: "@Sven - Don't stop now, you still have a problem to solve (although your sig could have told you that).

When I click to move my image window the image moves outside of the window. It goes back after I stop clicking on it, but it still looks strange.

The image is 512*512. I have a screen shot of before I click it compared to after I click it, when I haven't moved the window."


This seems only to be happening when 2 windows are created.

The fill thing is because DBP doesn't support this many functions in functions (it's recursive).

I'll try to fix before, well... the winner is declared

<edit> There's something wrong with the memblocks...
<edit2> I found it!!! It's because I used "array insert at bottom" to create a new window, and used the last index number to store my data in.
<edit3> Weird. The array seems to be losing data when I use "array insert at top"
<edit4> It seems not to be the problem . Back to off.
<edit5> I found it. And this time for real.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Jul 2006 14:00 Edited at: 7th Jul 2006 14:01


Quote: "@Sven - Don't stop now"


Thx for saying that. I would've given up ages ago if you didn't.
But I found it

And I'll try to find something on the fill tool.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Jul 2006 18:24
well im stuck in class till noon, i know i dont have enough time to complete everything I wanted. Unless, people are agreeable to a weekend extension?

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
lower logic
20
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 7th Jul 2006 19:19
@David G - I tried to post all the final entries but the post was too long and the forum gave an error, so I attached the post as a text file.

I have to run out the door right now but I'll give each a score when I get back.
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 7th Jul 2006 19:42
Darn it, knew I wouldn't have time to finish it, glad I made that last post.

http://www.cafepress.com/blackarrowgames
Check out my great stuff here
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 7th Jul 2006 20:03
awwwwwww extend it till sunday!! There are some fantastic entries here!

[center]
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Jul 2006 21:47 Edited at: 7th Jul 2006 21:48
It means I can think over my fill algorithm

But also means that my rush this noon was for nothing.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 7th Jul 2006 22:24
Sven,

If you take a look at my fill function it is slow because so many calls to the point command, but I have succesfully filled areas up to 1024 x 768 without a problem just slow because I am not all to familiar with memblocks.

http://www.cafepress.com/blackarrowgames
Check out my great stuff here
lower logic
20
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 8th Jul 2006 02:21 Edited at: 8th Jul 2006 02:28
Alright, now that a few more of you have said they want the extension, I guess we can extend it till Sunday. Sorry I didn't decide earlier, I was gone all day. Also the deadline will be midnight EST on Sunday so you have the rest of today and all of saturday and sunday to finish up your paint programs - many of which are looking very impressive!
David Gervais
Retired Moderator
20
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 8th Jul 2006 05:18
I'd like to suggest that each person who has an entry in the paint program compo zip up their source and ulpoad it here. Then then Lower Logic could simply put linke in the final post to each attachment. making life easier. The one huge txt file while nice is allot more work than any judge should have to sort through.

Sunday midnight sounds fine. I'll however be gone untill Tuesday so I'll only be able to check in then.

Cheers!
Darth Vader
21
Years of Service
User Offline
Joined: 10th May 2005
Location: Adelaide SA, I am the only DB user here!
Posted: 8th Jul 2006 10:46
Heres my entry:
(Too big for the code snippets)
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/mspaint_overview.mspx?mfr=true



I have the longest Biog under my profile button!

"You don't know the power of Dark Basic Pro!"

-Darth Vader-
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Jul 2006 13:30 Edited at: 8th Jul 2006 13:53
Quote: "Sven,

If you take a look at my fill function it is slow because so many calls to the point command, but I have succesfully filled areas up to 1024 x 768 without a problem just slow because I am not all to familiar with memblocks."


I'll look into it and try to adapt to memblocks.

It is this part right?
<edit> It was the old one...


<edit> I have to say that is a nice algorithm

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Jul 2006 14:14 Edited at: 8th Jul 2006 18:51


Even with memblocks, 512x512 is very slow. You have to wait 10 seconds or something to fill it completely...
But at least it works...

@Lower Logic: You can choose (lol). Either the slow and working one, or the fast and half working one.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 8th Jul 2006 19:49
Quote: "Even with memblocks, 512x512 is very slow. You have to wait 10 seconds or something to fill it completely...
But at least it works..."


Darn I figured it was slow because of my inability to use memblocks, must be all the add/delete to the array. In theory you should never have more elements in it then the perimeter of your canvas. Still I am glad it worked for you, oddly enough it is basically my ai pathing routine slightly rewritten, I use the old "flood the maze with water and see where it came from" routine.

http://www.cafepress.com/blackarrowgames
Check out my great stuff here

Login to post a reply

Server time is: 2026-07-21 01:12:43
Your offset time is: 2026-07-21 01:12:43