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
RiiDii
18
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 22nd Feb 2005 13:37
If no judging soon, I concede to Ric.

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
TEH_CODERER
19
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 22nd Feb 2005 18:31
NathF is judge.

[url]andrewneale2004@yahoo.com[/url]
http://www.elbsoftware.tk
IBOL
Retired Moderator
18
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 22nd Feb 2005 21:12
ha ha!
i am rogue judge!
i declare ric is winner!
bob

Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 23rd Feb 2005 00:47
OK becuase this is taking a bit longer than I expected. I cede to ric's totally most excellent entry.

This is significant because I think we are about to adopt a new rule.

- Should the entries fail to be judged within 24 hours of the stated deadline, the entrants may elect a winner from amongst themselves by simple majority. The voting period will last an additional 24 hours.
It is not required that all entrants vote. At the end of the total 48 hours. The entrant with the most votes will declare themselves the winner and post a new challenge.

Any disputes will have to be handled by some reputable and frequent user of this thread.

This way we will have at maximum two down days. Hopefully it won't happen much

The judge should also nominate a runner-up just in case someone does not post a new challenge. The runner-up would then step in.

I cede runner-up to riidii. although it is not likely that ric will fail to post.

So go ahead ric. Declare yourself the winner. Simplify the above rules as you see fit and give us a stinkin' challenge

Peace out,

Fodder

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Chris64
18
Years of Service
User Offline
Joined: 16th Oct 2004
Location: San Diego
Posted: 23rd Feb 2005 01:00
Well Ric had the best graphics...although Riidii was right there.

I still like my game though

I'll concede to Ric or Riidii.
Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 23rd Feb 2005 01:20
yah chris, It is tough when you have to make a call other than your own. That is why we are supposed to have a judge. I still like mine. It is the only 2-D entry and the background is just brilliant Oh well. I just want to program. I would amost hate to win one of these..

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
KimoSabi
18
Years of Service
User Offline
Joined: 18th Jan 2005
Location:
Posted: 23rd Feb 2005 01:43
yes i agree ric is winner (sry guys i haven't been posting much i have been very very busy *sigh* but maybe if you post some "easier" challanges i will come in (im not THAT great of a coder... yet

I must say I am quite a »»ç¶´¬¬Géñíú§¬¬´¶««
RiiDii
18
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Feb 2005 02:19
Congratulations Ric!!


"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
RiiDii
18
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Feb 2005 05:59
Don't know if Ric's going to post soon or not, but here's my suggestion for a quick'n'easy next challenge:

Game Menus (2d or 3d):
to be judged on:
Graphics (style, cool looking, etc.)
Functionality (Objects work as intended)
Flexibility (Can easily add or remove menu items. Can call new menus)
Variety (diffent types of objects/buttons/drop-downs,etc.)

Menu objects should actually demonstrate their functionality, but in a very limited sense (i.e. pressing a "Start" button would simply print "Game Start" or something).

2 Days?

Thoughts? Yea/Nay?
@Ric, feel free to override this.

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Monsieur Mort
17
Years of Service
User Offline
Joined: 12th Feb 2005
Location:
Posted: 23rd Feb 2005 06:08
Yeh Ric, override it - R2's probably been working on his menus for days so he get one back on you

Come up with something yourself. Trust no-one.

Why do you sink I ave zees outRAGEOUS accente?!
RiiDii
18
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Feb 2005 07:31
@MM - I wasn't going to enter!
Okay, If you think I was going to enter my own contest, press 1, otherwise, press 2.

Menu:
[1]
[2]
[Exit]

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Monsieur Mort
17
Years of Service
User Offline
Joined: 12th Feb 2005
Location:
Posted: 23rd Feb 2005 07:38
Haha, obviously you don't want us to _think_ you were going to enter now that your evil plans have been revealed... then we'd ban you from enterering the next contest you engineered from the side lines you devious droid...

Why do you sink I ave zees outRAGEOUS accente?!
RiiDii
18
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Feb 2005 07:48
I thought that you would think that I thought everyone would think I would want them to think I wanted to enter thinking that if I thought that then I couldn't really possibly think that, thinking that everyone would then think I was thinking exactly the opposite! Ha!

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Monsieur Mort
17
Years of Service
User Offline
Joined: 12th Feb 2005
Location:
Posted: 23rd Feb 2005 07:51
Don't cough, I don't want your verbal diarrhoea

Why do you sink I ave zees outRAGEOUS accente?!
Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 23rd Feb 2005 07:55
Man ric is so regular.. Until we need him. I want a challenge. I mean a challenge other than actually working on my main project. Which I should be going like crazy on since riidii solved my little blackboard problem. *nods toward riidii*

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Ric
18
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 23rd Feb 2005 08:35
I'm back! Thanks for electing me winner of the last challenge - and kudos to CF and Rii for their great entries too - both of which will be very useful for others to learn from. I did email Nath a couple of days ago to move things along but he seems to have disappeared for the while, so lets get the ball rolling again.

I'm going to take a little inspiration from Rii's menu idea, but try to break it down a bit - and hopefully get some entries which will be useful for menu creation as well as other things:-


Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 23rd Feb 2005 08:40
Hey ric Are you going to officially update the rules, so we don't have to second guess agian?

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Ric
18
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 23rd Feb 2005 08:46 Edited at: 23rd Feb 2005 09:04
Challenge 4

- Challenge: Write a function that will create a 2d primitive

- Time limit: 4 days (until Saturday night, 26/2/05)

- Challenge setter: Ric

___________________________________________________________________

Notes:

The 2-d primitives in Dark Basic are the commands box, circle and ellipse. The challenge is to write functions that will expand the collection (for example, triangle, star, rounded box, hexagon etc. etc......) and also expand their flexibilty - so you could for example set fill/no fill, colour(s), line thickness, etc.

These functions should be useful for anyone wanting to create buttons on a menu, shapes on a HUD, a drawing program, and other things.

The challenge is open to everyone - the more entries, the better!


Monsieur Mort
17
Years of Service
User Offline
Joined: 12th Feb 2005
Location:
Posted: 23rd Feb 2005 08:47
Is it really necessary to 'officially' update the rules? Surely we can just take it by tacit agreement that if the previous winner doesn't get around to judging entries quickly enough entrants magically pick a winner on their own?

Why do you sink I ave zees outRAGEOUS accente?!
Ric
18
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 23rd Feb 2005 09:02 Edited at: 23rd Feb 2005 09:13
Rules have been updated, just so there's no confusion. The changes are:

Quote: "
4. The challenge setter is the judge for the current challenge, and must select a winner and a runner up.

8. If the challenge setter fails to judge entries within 24 hours of the deadline, responsibility for judging and setting a new challenge will pass to the previous runner up. If that person also fails to judge promptly, entrants may vote for a winner."



By the way, here's the first entry - thought I'd get the easiest one out of the way!




Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 23rd Feb 2005 09:23
I just like to think that this thread will be around when daisies are blooming on my grave. Other people will come along and need to know what we agreed on page 4. Confusion is the downfall of perfectly good threads

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
blueselah
18
Years of Service
User Offline
Joined: 15th Dec 2004
Location: TN, USA
Posted: 23rd Feb 2005 10:47
I always missed the 'original' box command from QBASIC. Here's my try ...



Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 23rd Feb 2005 13:09 Edited at: 24th Feb 2005 06:43
Here is my entry. the function can make any n-gon at any angle. It is much slower than I like but I don't know how I could make it faster in DB. I added a bit of code to showcase it's abilities



[edit] fixed a truncation error that was causing unrotated polygons to look shifted

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Feb 2005 22:44 Edited at: 23rd Feb 2005 23:04
Someone just had to do this!




and here's a cube


"eureka" - Archimedes
Monsieur Mort
17
Years of Service
User Offline
Joined: 12th Feb 2005
Location:
Posted: 24th Feb 2005 02:08
I love the way the teapot flips over as size# goes below zero

Why do you sink I ave zees outRAGEOUS accente?!
Tom_d
18
Years of Service
User Offline
Joined: 3rd Jun 2004
Location:
Posted: 24th Feb 2005 04:19
hello all,
i came up with this although it doesnt really meet the challenge and is horrendessly simple but its a nice effect none the less. if you've seen the film 'Contact' you'll know what I'm getting at - its that spinning time machine thing they build. enjoy!

IBOL
Retired Moderator
18
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 24th Feb 2005 05:33 Edited at: 24th Feb 2005 05:34
the n_gons, teapot, and even the contact()
are out of my mathematical league,
and impressive in themselves.

i await another challenge...
(although it usually takes me a few weeks of subconscious
planning to write anything, so this thing may be too fast for me)

bob

ps:
riidii: it took me this long to figure out that your name actually
WAS r2d2...i've been pronouncing it reedee. man...

Monsieur Mort
17
Years of Service
User Offline
Joined: 12th Feb 2005
Location:
Posted: 24th Feb 2005 05:56
Haha! you didn't see the avatar?

Why do you sink I ave zees outRAGEOUS accente?!
Ric
18
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 24th Feb 2005 06:39 Edited at: 24th Feb 2005 06:40
4 entries in under 24 hours - excellent!

@ CF: That's great - care to explain how it works? I mean, this bit:




I shouldn't worry about the speed - I would imagine that in most cases a user would draw it just once, grab it as a sprite and then move it, rotate it, scale it etc.

@ Phaelax: Presuming you made that in an editor? If so, can you post that as well? (Don't say you coded the teapot line by line?)


Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 24th Feb 2005 06:54 Edited at: 24th Feb 2005 06:56
Hmm, Good question ric. Basically for each side of the polygon I am checking to see if the current pixel is below the line that makes up that side in the direction of the orgin. If it is true for all sides then the pixel is inside the polygon. This only works for convex shapes. To be honest I don't really know what all the bits of that equation are. I derived it and simplified it, but basically it it the general equation of a line the "<" symbol allows everything below the line. Of course "below" is reletive and gets rotated all over the place.

If this does not help much I will rederive the equation for you.

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
RiiDii
18
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 24th Feb 2005 06:59
CF, great work on that! I was trying to derive a similar equation, but was struggling (been years since trig). You beat me to it! Now I have to go back to the drawing board

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 24th Feb 2005 08:21
Riidii, The rules state that you are welcome to plagerize (with proper documentation that is. The Idea is to get the best possible code we can out of these challenges. So if you can use some of my own code to beat me, go right ahead. I would be honored.

Oh and don't laugh at poor IBOL. I read it as Reedee for a while as well and quite frankly still think of you that way, even after it dawned on me that your name and avatar might be related. I think you should insist people refer to you as Reedee. It is more exotic.

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
RiiDii
18
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 24th Feb 2005 08:35 Edited at: 24th Feb 2005 08:38
Roflmao!! That's cool either way. I've even said/thought that a few times myself. and I totally missed IBOL's ps. Not that Reality II is a real company or anything, but that's actually why I chose RiiDii (RIIDII was my first thought). If I ever start a game company or anything, that would be the name: Reality II. Still working on what Dii is for; Developer II? Demension II? Who knows, it's all fun.

Edit: Oh, I have another idea. Lot of work on the boards about writing on objects (like for text or bullet holes). Thought I'd make some randomized bullet holes, laser holes, etc.

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Feb 2005 09:22
Quote: "@ Phaelax: Presuming you made that in an editor? If so, can you post that as well? (Don't say you coded the teapot line by line?)"


guess and check. did take a few minutes and many compiles.

"eureka" - Archimedes
Ric
18
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 24th Feb 2005 09:31 Edited at: 24th Feb 2005 09:32
Quote: "If this does not help much I will rederive the equation for you.
"


It's ok, I think I see it now ..... vector coordinates. Took me a while drawing on a piece of paper, but I realise now your i and j values test coordinates about an origin, and the equation tests whether the the vector from the origin to the coordinate (ie. i*cos theta + j*sin theta) is less than size2, which is the distance from the origin to the closest part of the particular side. Neat. I'm happy now.

@ Phaelax: Oh. The old fashioned way.


Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 24th Feb 2005 10:11 Edited at: 24th Feb 2005 13:03
Yes ric. Thats about it, and better than I could have explained myself. I tend to do all this stuff as I type and in my head, so I know it works but I forget the steps I took to get there

Well here is N-Gons RC 1.2



*note this is a free update

[edit] I should probably say what is different..
I added the ability to change the thickness

[edit 2] Just because I don't know when to quit.

here is N-gons 1.3



I added a star flag. If set to one it will make the n-gon into a star
of course it fails for n less than 5

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Chris64
18
Years of Service
User Offline
Joined: 16th Oct 2004
Location: San Diego
Posted: 24th Feb 2005 13:44 Edited at: 24th Feb 2005 13:51
Bezier Curves
OK...maybe this is so easy that nobody wanted it...but pratically speaking, this is one that I wish really existed. The funny thing is that I wrote this a long time ago but lost the code so this was a great chance to remember how Beziers work.

The Other funny thing is the code to demo the Bezier is so much bigger than the actual function...I hope the fact that my function is small, clean and refined doesn't count against me

Oh yea, I was getting 168 FPS on a P3/600 w/16meg video.

Monsieur Mort
17
Years of Service
User Offline
Joined: 12th Feb 2005
Location:
Posted: 24th Feb 2005 23:05
I think the n-gon thing has to be the current winner. The Bezier curves are extremely pretty but they're not really primitives, the teapot's cool but not enormously flexible, the contact thing isn't a primitive either because it moves, though again it's pretty. The box thing makes primitives, but again, it's not very flexible. I'd enter myself, but I can't think of many useful 2D primitives less, so the only thing I could do would be to steal the n-gon program completely and add fill options.

Why do you sink I ave zees outRAGEOUS accente?!
Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Feb 2005 23:18
The star shape was cool

"eureka" - Archimedes
Chris64
18
Years of Service
User Offline
Joined: 16th Oct 2004
Location: San Diego
Posted: 24th Feb 2005 23:39 Edited at: 25th Feb 2005 02:02
Quote: "The Bezier curves are extremely pretty but they're not really primitives"


How's that? Maybe someone could explain what a primative is? EPS file formats are almost entirely built with Bezier Curves. Microsoft Paint has several basic tools...square, circle and Bezier.

The real trick is that Bezier curves done properly are extremely complicated and the math behind them is ridiculous...the Bezier I made was using a "bezier simulation" technique. It is very accurate but can be processed 100 times faster than a normal Bezier.
Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Feb 2005 00:08 Edited at: 25th Feb 2005 00:08
A primitive is just a basic, simple shape. (and a teapot ) The bezier is just a more complex line.

Not trying to steal CF's idea, but the n-gon shape was what I originally had in mind. But since he did it first, I made the teapot. Here's my n-gon function, no start shape but it does fill in the shapes. If you don't want a filled polygon, use a negative size.



"eureka" - Archimedes
Chris64
18
Years of Service
User Offline
Joined: 16th Oct 2004
Location: San Diego
Posted: 25th Feb 2005 00:11
So a line is not a primitive?
KimoSabi
18
Years of Service
User Offline
Joined: 18th Jan 2005
Location:
Posted: 25th Feb 2005 02:00
lol i am with "reedee" to lol although i pronounced it "ridee" lol strange huh

well i also think that that curves are cool but im with CF's code

I must say I am quite a »»ç¶´¬¬Géñíú§¬¬´¶««
Monsieur Mort
17
Years of Service
User Offline
Joined: 12th Feb 2005
Location:
Posted: 25th Feb 2005 02:38
I don't think lines really count. Mind you teapots are debateable too - some might say they were to complex to be primitives, but I think when they're made out of lines in the way Phaelax's is they do count.

Why do you sink I ave zees outRAGEOUS accente?!
Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Feb 2005 03:21
if 3d studio max considers a teapot to be a primitive, then who are we to argue?

"eureka" - Archimedes
robo cat
18
Years of Service
User Offline
Joined: 23rd Feb 2004
Location: In a cat litter tray, near you...
Posted: 25th Feb 2005 04:51 Edited at: 25th Feb 2005 05:04
Heres my entry, it allows you to open a drawing, from a text file. A drawing is just a text file consisting of the commands ink, dot, line, box, circle and ellipse. You can load the drawing to the screen and offset or scale the drawing in each dimension. Not sure if I've explained it well, but looking at the code should make it clear:



Should be quite useful as you could program the drawing operations for drawing a car and then it will let you position and scale the car loaded from a file. Enjoy!


EDIT: Fixed broken code, all works perfectly now.

Simple... yet fun!
Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 25th Feb 2005 07:05 Edited at: 25th Feb 2005 07:11
phalanx, mine does filled also, you just need to set the thickness to some high number. Kind of a silly way to do it, but it keeps another if statement out of my already too slow function.

@Chris64, that is cool, I am going to have to look into it to see how it works. I don't know nearly enough about beziers. Yes I agree that it is a primitve, and quite a powerful one. A bezier can form any conic section precisely. Perhaps you could add a little code to demonstraigt circles, elipses, parabolas, the like. The average layman simply does not know what to do with a bezier.

-fodder

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Ric
18
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Feb 2005 07:12 Edited at: 25th Feb 2005 07:33
I've taken CF's code and added a colour gradient option - the colour should fade smoothly from colour 1 to colour 2. At the moment, I can only get it to shade from left to right - I'm still thinking about how I'd add the option to shade from top to bottom.....

N-Gons 1.4, if that's alright with you CF!



Just about to take a look at the other entries too ......

<edit>

Good stuff coming in here.

@ Robocat - how do you create the drawing in the first place? It seems like half of a program to me at the moment ........


Coding Fodder
19
Years of Service
User Offline
Joined: 25th Sep 2003
Location: Somewhere in my cerebralcortex
Posted: 25th Feb 2005 07:20
Nice ric. You need to add the parameter "gradient_angle#" I might try to do it myself, becuase it is cool

Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"
Ric
18
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Feb 2005 07:34 Edited at: 25th Feb 2005 07:50
Please do CF - I think you know what you're doing better than me with that.

@MM:
Quote: "I'd enter myself, but I can't think of many useful 2D primitives left"


A really useful one would be a rounded rectangle - good for menu buttons etc. Fancy having a go at that ..... ?


Login to post a reply

Server time is: 2023-02-06 19:46:41
Your offset time is: 2023-02-06 19:46:41