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
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 20th Jul 2005 17:46
Lets concentrate on this challenge first Everyone concentrate on me winning.. Come on, lets chant.. Nick, Nick, Nick... Hehehe...

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 21st Jul 2005 03:18
I do believe today is deadline day.

Whistlin Trev
19
Years of Service
User Offline
Joined: 11th Feb 2005
Location: Battle of Nevermore
Posted: 21st Jul 2005 03:51
here is my code. sorry but didnt work last time. still needs alot of improvements but atleast i learnt alot from it.



sync on
autocam off
hide mouse
position camera 0,0,-500
make object cone 200,50
zrotate object 200,90
set object collision on 200
dim speed# (10)
dim size# (10)
for mjpet=1 to 10
size#(mjpet)=rnd (50000)/1000.0+5
speed#(mjpet)= rnd (75)/10.0+1
make object sphere mjpet,size#(mjpet)
position object mjpet,rnd(500)-250,rnd(500)-250,0
set object collision on mjpet
next mjpet
score=1000
do
scale object 200,100-g#,100-g#,100-g#
score =score-1
for mjpet=1 to 10
position object mjpet,object position x (mjpet)+ speed#(mjpet),object position y (mjpet),0
if object position x (mjpet) > 290 then position object (mjpet),-250,rnd(500)-250,0:show object mjpet
target = object collision (200,0)
if target=mjpet then hide object mjpet:score=score+3
next mjpet
print score
position object 200,325-y#,x#,0
if upkey()=1
x#=x#+3
endif
if downkey()=1
x#=x#-3
endif
if x#>240
x#=240
endif
if x#<-240
x#=-240
endif
if leftkey()=1
y#=y#+3
endif
if rightkey()=1
y#=y#-3
endif
if y#<0
y#=0
endif
if y#>670
y#=670
endif
if score<0
cls
text 0,0,"Game Over"
endif
if score>2000
g#=20
endif
if score>3000
g#=40
endif
if score>4000
g#=60
endif
if score>5000
g#=80
endif
if score<500
ink rgb(255,0,0),1
else
ink rgb(255,255,255),1
endif
sync
loop
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 21st Jul 2005 04:43 Edited at: 21st Jul 2005 04:43
Hey Whistlin Trev, the code didn't post. Post it in the message area using the [code ] [/code ] tags (button in the top right of the message window. While your account is still set to newb-status, the Source code area won't work.

Edit: The deadline is today... and the suspense is building...

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 21st Jul 2005 05:14
Riidii - even if you're not set to newb status, the code box rarely works anyway! Lol..

My Website:
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 21st Jul 2005 12:16 Edited at: 21st Jul 2005 12:27
Code box works for me. It seems to be the delay for newbs.

Edit: Trev - that's a great start. Thanks for joining the compo! And that's why I like this compo too - not for winning, but I learn a heck of a lot about coding! I didn't quite understand what was going on in the game - if I was dodging, shooting, collecting? But you definately have the basics down solid. Go ahead and finish the code and post it here. Also, join in on the next compo!

I think I know what you felt like Ric on the last judging. This is one TOUGH call!

And the winner is...


"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 21st Jul 2005 17:59 Edited at: 21st Jul 2005 18:03
Yay!! That makes Two Hehe

Hmm.. I'll have a think about this - but I do like the sound of a Code indenter/neatener... Or maybe a syntax highlighter of some sort? Actually.. A code indenter would be good - especially if it could work for languages that were not just DBP, like if you provided it with HTML tags and it did it for that (only because I'm lazy and I keep getting thrown HTML files that have never seen a Tab in their life and I end up with tables stacked withing tables stacked within tables... You get the idea).

Sod it - a code indenter. It doesn't have to be graphically fancy, in fact.. The more re-useable it is the better (ie I wanna see functions people!! ).

Challenge [insert number here]: Code indenter/neatener


Points Awarded for:
Re-usability (in terms of transporting to another project)
Re-usability (in terms of using other languages)
Commenting, so that other people can learn
General genius technique

And as a final note - I'd like to thank Riidii for this honour and I'd also like to say "I BEAT YOU RIC!! HAHAHAHA"... Hehehe... Seriously though, Ric - your entry was great! With a little tweaking on the controls I think that could be a really cool freeware/shareware game! I wonder if it'd be possible to add bends into it?

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 21st Jul 2005 20:20
Congratulations Nick! Nice effect.

I might have a go at adding some bends in my game - I'll post what I come up with here. Btw, what did you have in mind when you said 'tweak the controls'?

@Whistlin Trev: Good start - turning it into 3d should be reasonably straight forward - you'll need to give the planets an initial random z position as well as x and y positions, and then instead of subtracting the speed from the x vale, subtract it from the z value. Bear in mind though, that if you point the cone away from you, it will probably look invisible, as cones don't have bases. Maybe just use a box instead.

Deadline on the indenter challenge? Usual two weeks?

Whistlin Trev
19
Years of Service
User Offline
Joined: 11th Feb 2005
Location: Battle of Nevermore
Posted: 21st Jul 2005 20:22
riidii- well the game can be changed to anything as it started off as dodge then went to shoot but on this version i made it to collect them. will try and finish it off and make it easier to understand. also will try te other challenges and i will be able to finish them as i got six weeks off.

Nicholas Thompson- well done on winning. it would make a cool screensaver.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Jul 2005 22:10
Quote: "what did you have in mind when you said 'tweak the controls'?"

When I played it, I had to get rid of that inverted camera control.

PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 21st Jul 2005 22:53
Tweaking the controls - I found it way to responsive. 1mm mouse movement ended up being about 1/4 of the screen. Not sure why though - might try to look tonight.. Is the control timer based or "per loop"? If its per loop you need to be carefull as you might end up updating more often depending on FPS...

Ad for this challenge - usual 2 weeks. I'm gonna try to get the past 2 challenges onto the DB Database and I really wanna do some work on that site. Its just annoying that by the time I get home and I've had dinner its 8pm and I have to be up at 6am meaning I normally get 3 hours to myself at most a night!

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 22nd Jul 2005 00:34
Quote: "Its just annoying that by the time I get home and I've had dinner its 8pm and I have to be up at 6am meaning I normally get 3 hours to myself at most a night!"


Unlucky! I get up just before 8, finish work at 3.30, and spend most of the day surfing the net. When I get home, I play some games, do some more surfing, have some dinner (cooked for me), give the gf some loving attention, watch a movie or two and go to bed. Plus I get 13 weeks of holiday a year. God I love my life!

I'll try and sort out the control aspect of my game when I get a chance - my life is so busy you know!

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 22nd Jul 2005 00:59
Ric, you make teaching sound like a great job!

Better use some of that time on this challenge Ric. This is something I've had as a concept for a while.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 22nd Jul 2005 03:33
I might also try and write a 20-line-challenge-format condenser, to save hours pressing <<delete><end><<delete><end> over and over again!

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 22nd Jul 2005 21:14
That would vey a very usefull idea. Kinda the excat oposite of an indenter

My Website:
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Jul 2005 01:05
Heh-heh! The colon's came out as smilies.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 23rd Jul 2005 04:00
Yeah - I noticed that, and the instant I went to edit it the forums all went offline! Ah well, at least you knew what I meant!

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Jul 2005 05:07 Edited at: 23rd Jul 2005 05:08
Quote: "Ah well, at least you knew what I meant!"

And I do!

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Jul 2005 04:58
hmmm, I just got a pretty neat idea for this one. One that'll prevent me from having to write an excessive amount of code.

PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 24th Jul 2005 06:24
I'm intruiged!!

My Website:
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 27th Jul 2005 01:19
Anyone done anything yet?

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 27th Jul 2005 19:36
Not yet - spending all my free time at the moment on VI-Studio (my main project). When it's done (if I ever get it finished), I might offer it up as a prize for anyone who wins a challenge here.

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 28th Jul 2005 00:50
Not yet. I am procrastinating for optimum performance!

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Jul 2005 14:12
my free time has been going to my music player.

PETA - People for the Eating of Tasty Animals
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 28th Jul 2005 18:03
I see

My Website:
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 29th Jul 2005 08:15
Here's the basis for how I want to do mine. It's a little something I wrote a while ago.

Instructions: Make an executable of this code and name it something other than "temp". Run the executable - it should run in the background. If not, just minimize it. Start a blank Source Code in the IDE and type "Make Robot" or Make Spring" (without the quote marks). Copy the words to the clipboard, wait a second, then paste it right back down into the IDE. To stop the code from running in the background, copy "Exit999" to the clipboard.



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 29th Jul 2005 17:33
over 1 week past and only RiiDii's done something and even that is regurgetated code from "a while ago" :-( (Not that there is anything wrong with that! ). Come on people - we cant let Riidii win by default! Winking Trev - how about you with your 6 weeks off?

My Website:
Whistlin Trev
19
Years of Service
User Offline
Joined: 11th Feb 2005
Location: Battle of Nevermore
Posted: 29th Jul 2005 20:18
well just got back off holiday and was thinking but dont have a clue.looking at riidii's code and trying to think of something but at the moment stumpted for ideas.
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 30th Jul 2005 01:53 Edited at: 30th Jul 2005 01:54
Look out for my entry tomorrow ...... need a break from my other stuff

Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 30th Jul 2005 13:10
I'll join the net game challenge if you want

life's a game and a games a life More games at www.freewebs.com/halorc
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 31st Jul 2005 02:34
Everybody is welcome to take part in any challenge.

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 31st Jul 2005 20:41
Join this - its quite a simple challenge and judging by the massive lack of entries, you're quite likely to win anyway You have until thursday to make a program that simply neatens code up OR converts a 20 liner to a normal program (or vice versa).

This is really a test to help you learn how to look through code and basically parse it!

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 31st Jul 2005 22:08 Edited at: 31st Jul 2005 22:11
Ok, this code should convert normal code into 20-line format (with 25 commands per line as per the stated rules).



Short but sweet!

Here's some example code to try it out on:



For those who can't figure out what to do with the two bits of code - it's very straight forward:

You just need to save the compression code as a project, in its own folder. You then save the example code as a source file (dba) in the same folder.

Once run, code save the compressed version as another dba file with "_compressed" after the file name.

Limitations:
-it won't work for code which has functions
-it wont work for code which uses if-thens .... you must use if-endifs instead.
-it wont' work if the code has rems or ` symbols to remark text

Btw, those are not bugs in my code, they are just things you can't do when stacking multiple commands on one line.

It does, however, know to skip over empty lines!

Anyone who wants to use my code as their starting point for this challenge is welcome to - for example, dealing with if-thens by turning them into if-endifs should be reasonably straight forward I would think.



Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 31st Jul 2005 22:17
nice code entry!

1 suggestion - how about, instead of using input, you use CL$? I think, NOT SURE, but if you drag a file and drop it on a DBP EXE, the filename and path of that file is in the CL$? If so - you could drag and drop files onto the compressor?

What happens if your code is more than 20 lines? Does it just "crop" the end off?

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 31st Jul 2005 22:26
Answer to second question -

yes, just thought about that problem. It does just crop the end off. This update won't crop the end, but it will tell you if it exceeded 20 lines:



I'll have a think about the file dropping thing!

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 31st Jul 2005 22:37
Hmm, didn't know that about dropping files on an executable. Can't seem to figure out how to use cl$, even having read the help file. Can you give any examples of usage?

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 31st Jul 2005 22:59
CL$ should just be the file and path as a string shouldn't it? Its meant to be just what gets passed to the EXE as a command line arguement...

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 31st Jul 2005 23:46 Edited at: 1st Aug 2005 00:08
Ok, I get it now thanks. Having a dumb moment, though - is there a simple way to get the file name instead of the entire path+file name? The only way I can think of, is by parsing it to get the characters after the last /, but that must be the long way around!?

<edit>
well, even if it was the long way around, I managed to parse the path to get the file name successfully - however, when I drop the example code onto the executable, it tells me that the example file does not exist. I know the file name is correct, but could it be that the file momentarily vanishes due to being dropped into the executable, and therefore can't be found? How then does one open the file to read it?

btw, the code:


Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Aug 2005 00:09
Hmm.. maybe when its dragged and dropped windows marks it as in use? Could a while loop work (like wait for 2 second?)

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Aug 2005 04:08
Quote: "maybe when its dragged and dropped windows marks it as in use?"


I think that must be the problem - as if you select 'open with' for the example dba, and select the compressor executable, it works fine. However, I'm not sure that makes life much easier, so I think I'll just go with the original code!

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Aug 2005 10:55
:-( Oh well :-( Hehe

My Website:
Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 1st Aug 2005 20:37
what's the current comp?

life's a game and a games a life More games at www.freewebs.com/halorc
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 1st Aug 2005 22:02
Nope. It seems the relative path is the problem. Give this a go.



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Aug 2005 22:29
Quote: " what's the current comp?"


Its to make a program that takes some code and either indents it so it looks neat, or modifies it in some way. Ric's doing program that converts a piece of code into a 20-liner entry.

You gonna enter?

If you win - you get to set the next challenge..

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Aug 2005 22:57
Cheers Rii - that works now. Now to figure out why I couldn't get it to work when I tried using the absolute path ..... think maybe that was before I realised I needed to get rid of the ""s. Tell you what, though - that parser challenge has come in handy for me several times since then!

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Aug 2005 23:13
These challenges are really really usefull - if only people realised how much you can learn from doing lots of little things like this!

My Website:
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 2nd Aug 2005 01:03 Edited at: 2nd Aug 2005 07:04
Quote: "if only people realised how much you can learn from doing lots of little things like this!"

What are we? Dogs?

... Oh, never mind. You mean OTHER people. Got it.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Aug 2005 02:54 Edited at: 2nd Aug 2005 03:03
Ok - this code should decompress from twenty line format to normal format:



Works in the same way as the compressor - make an executable of the code, then drag and drop the twenty liner .dba file onto the decompressor executable.

Heres an example twenty liner to try it out on:



Limitation: Doesn't like it if you have colons ( within speech marks as part of a text statement. eg Print "damping: ",damping# will think the colon is the end of one command and the beginning of the next. Anyone who has the motivation could probably figure out a solution to that if they wanted to!

Thanks to xolotron and spooky for the undocumented token$ command, which a) I knew nothing about until today, and b)quite coincidentally happens to be exactly the command this code needed!

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 2nd Aug 2005 04:42 Edited at: 2nd Aug 2005 07:03
I haven't tried it. And I did get rid of those really cool undocumented commands (I did try to figure out how to use them, but no luck), so this is probably a tad slower. But it should work it's way through quote marks.



Edit: Now working on an IF THEN ELSE to IF:ELSE:ENDIF converter.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 2nd Aug 2005 10:51
token$?? Is that like CL$?!

My Website:

Login to post a reply

Server time is: 2024-11-23 05:45:59
Your offset time is: 2024-11-23 05:45:59