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 / The DB Classic Programming Challenge Thread

Author
Message
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Apr 2007 18:27
Quote: "So you want an open file dialog or something?"


Not essential - just being able to type the name of the text file would be enough. As long as you can tell the program the name of the text file, how it's done doesn't really matter.

As for the severe exception problem, I don't get one with the test text file. I doubt it's anything to do with line length because as far as I remember, I'm sure you get an error message saying that the text file can't be loaded.

TDK_Man

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Apr 2007 11:33
I tried the code with a different text file and it worked. Still get the severe exception with the other file though. Just can't figure out why DBP handles it ok but not DBC.

Grrr, DB will say the file doesn't exist if you have it opened in another program.

Anyone know if there's a way to reset the file pointer back to the beginning of the file?




Pricey
21
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 20th Apr 2007 11:53
I will be entering this!
just gotta dig out the old DBC!!

hehe

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Apr 2007 21:27
I'm trying to think of other ways to do the word count, but nothing is coming to mind. I think this challenge will come down to presentation more than anything.


TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Apr 2007 00:59
Quote: "Anyone know if there's a way to reset the file pointer back to the beginning of the file?"


Only by closing the file and re-opening it.

Quote: "I think this challenge will come down to presentation more than anything."


Yes I think you are right... more or less - there aren't many ways to do a word count. However, I would have done it a little differently - by loading the lines into a string array before working on them.

Actually, doing that should solve the problem of not being able to reset the file pointer!

TDK_Man

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Apr 2007 01:19
So how big should I make the array? Since there's no way to find the exact number of lines without reading the whole file anyway. Too big and I'm just wasting ram.


TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Apr 2007 01:50 Edited at: 21st Apr 2007 10:01
Quote: "Too big and I'm just wasting ram"


I wouldn't be too worried about that - not for a challenge entry program anyway!

If you really wanted to be thrifty with memory, Open the File, read all lines in, counting and discarding them, then close the file. You can then DIM the array when you know the number of lines.

But like I say, for a challenge, dimensioning an array to 10,000 lines max isn't overly memory intensive and should be fine for most text files.

TDK_Man

Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 21st Apr 2007 08:53
hey just had a thought, and it might because i'm tired that i like it. So lets say that there is a hybrid text/graphical game and that you need to type for certain actions or conversations. Anyway, what if you reach a certain goal of letters, you get an upgrade from side quests or something like that?

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Apr 2007 10:03
Zombie 20:

What has that got to do with this challenge thread?

Try to keep on topic please!

TDK_Man

Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 21st Apr 2007 10:38
sorry tdk

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 21st Apr 2007 23:26
@Phaelax
Quote: "there's no way to find the exact number of lines without reading the whole file anyway. Too big and I'm just wasting ram."


Using lines of strings can tie your hands. Get the file size and dimension an array based on the number of bytes. Read the bytes into an array and use custom "string" manipulation. If you want to adapt to your line reading function, then you know each line ends with chr$(13) chr$(10). Look for those in the byte array to mark the termination of your lines (strings).

Enjoy your day.
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 22nd Apr 2007 06:49
I might enter the next challenge; arrays are a nightmare to me.

What happens when when you mix coke, pop rocks, vinegar, and baking soda?
I am currently working on 2 projects: The Ultimate Killing Game & The Turtle Game
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Apr 2007 15:27
Quote: "arrays are a nightmare to me"


Actually they are really, really simple when you get used to them. You just need them to be explained properly to you.

Check out Tutorial number 1 here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

After you've read it, come back and tell us you still don't understand arrays...

TDK_Man

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 23rd Apr 2007 05:15
Quote: "After you've read it, come back and tell us you still don't understand arrays... "

How'd you know?

What happens when when you mix coke, pop rocks, vinegar, and baking soda?
I am currently working on 2 projects: The Ultimate Killing Game & The Turtle Game
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Apr 2007 08:11
Quote: "How'd you know?"


Surely you would know if you still didn't understand arrays after reading a tutorial about them?

TDK_Man

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 24th Apr 2007 03:18
Well I don't understand arrays in general .

What happens when when you mix coke, pop rocks, vinegar, and baking soda?
I am currently working on 2 projects: The Ultimate Killing Game & The Turtle Game
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Apr 2007 04:48
Well I don't understand arrays in general


That's why we have tutorials!!

TDK_Man

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 24th Apr 2007 20:03 Edited at: 24th Apr 2007 20:04
OK here's my entry. Phew that took a long time! (The file access system that is) OK in it you can move the slider click under the slider to move it down, use the arrows, use the mouse wheel, use arrow keys, use the enter key, double click and go to the parent folder. The word counter includes progress, maximum file lenth, minimum file lenth, average file and past ten words scaned(just an extra thing to make it look nice) Here it is:




Nothing is impossible...
No really, it isn't.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Apr 2007 15:49
Deadline is Midnight tonight GMT, so any late entries, you have approximately 10 hours to finish them off...

TDK_Man

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 26th Apr 2007 18:31
Oh yeah, I forgot to mention, Thw word count doesn't include any character other than letters.


Nothing is impossible...
No really, it is.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Apr 2007 21:59
Nano, it looks great but I couldn't get it to load anything. When I double click a folder in the broswer I get a file does not exist error or something.


Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 27th Apr 2007 00:00
Phaelax, update the site.

What happens when when you mix coke, pop rocks, vinegar, and baking soda?
I am currently working on 2 projects: The Ultimate Killing Game & The Turtle Game
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 27th Apr 2007 00:05
Try changing the name of the directory at the start of the program. One glitch is that if you are in the C drive it doesn't read the contents properly and when you click on one of the folders it gets a file does not exist error with darkbasic. Don't know how to fix that problem because it's probaly something wrong with file scanning in darcbasic.


Nothing is impossible...
No really, it is.
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 27th Apr 2007 00:18
here's a quick version without the file access, just the word counter:




Nothing is impossible...
No really, it is.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Apr 2007 02:50
Quote: "Phaelax, update the site."

With what? It's up to date.

Well, here's the final code. Works great in DBP, but DBC is just f*ing horrible! File access is basically useless. The checklist functions return so many folders that are technically hidden system information and many I haven't even a clue what they're for. I've drawn boxes that just plain don't show up. And frankly, I'm fed up with trying to work around bugs.


I tried another method, putting my word count function in with TDK's old file-loader code. At first it worked, but subsequent runs (that don't even call my function) just lock up and crash DB. I really can't take this anymore.




TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Apr 2007 03:44
Lol!

Ah well - time's up. Sounds like you all had fun with that one...

I'll now read through the posts, pick out all the latest entries and test them out.

It's nearly 2am here, and I'm knackered, so I'll probably post the results tomorrow, so if you entered, start thinking of the next challenge just in case...

TDK_Man

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Apr 2007 18:44
OK - all done!

As mentioned before, there aren't many ways to write a program for this challenge so if an entry gives the correct word count, judging has to come down to presentation.

The text file used for testing:



The Entries:

Latch:

This entry allowed you to enter the path and filename of the text file to check. The correct number of words was returned, but the screen flashed when run.

Nanogames Guy - Entry 1

Wouldn't run - path does not exist at line 153

Nanogames Guy - Entry 2

User selectable text file, but wasn't sure what to put when it just said 'Directory>', but I just typed the filename in and away it went. Correct number of words returned. Nice touch was the max, min and average word sizes. But, like Latch's entry the screen flashed like crazy.

Phaelax - Entry 1

This entry was hard-coded with the text file so to test another file you had to modify the code. It also returned 20 instead of 23 for the word count in the test file and like the others the screen flashed.

Phaelax - Entry 2

The filename is still hard-coded in this version, but returned the correct word count. Screen also still flashes.

Phaelax - Entry 3

Nice attempt at a graphical file-select to choose the text file, but gave a File Not Found error when I actually selected one. I guess from the posts that at this point Phaelax was getting a little cheesed off with DBC - being used to the superior DB Pro for so long!

Just shows that us DBC coders must be the better programmers to do what we do. Lol!

Anyway, joking aside, the results...

Runner Up:



Winner:




And to finish off, I thought I'd post what my entry would have been if I hadn't set the challenge - just to give you an idea of what I thought you'd come up with:



Congrats to the winner - your turn to set the challenge!

TDK_Man

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 27th Apr 2007 19:02
Thanks TDK_man,

Here it is:

Graphics screensaver

Specification

Desing a screensaver in 2D or 3D. Play around with the graphics to make it look cool!

Deadline

Midnight, Friday 4th May

I hope that this will be one that everyone can participate in.


Nothing is impossible...
No really, it is.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Apr 2007 19:16
@Nano
Congratulations!

@TDK
Flashes? Is that because of XP? I code DB on Windows 98 and don't see any of the flashing. Should I include Sync On: CLS 0: Sync
or something similar that refreshes the screen before the program runs even if it's not 3d?

Enjoy your day.
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 27th Apr 2007 19:20
I've got an XP but mine dosen't flash either.


Nothing is impossible...
No really, it is.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Apr 2007 22:41
Quote: "Flashes? Is that because of XP? I code DB on Windows 98 and don't see any of the flashing."


I used Win2k and didn't notice any flashing either. I think DBC has had some sync issues in the past.

Congrats on another win to Nano.

I updated the website with the new entries.


TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Apr 2007 01:36 Edited at: 28th Apr 2007 01:53
Strange - I've always had the flashing with DBC and XP. Over time, I've assumed it was XP, my graphics card, my system, DB Classic, DirectX - the lot!

But, I've recently updated my system to a 3.5G 64bit CPU with new Mobo and a new PCI Express nVidia GFX card. I've re-installed XP Pro in the process and installed the new 2007 download of DB Classic and it still does it.

If you look at the code I posted in my last post, that's what I have to do to stop the flashing (Sync On: CLS 0: Sync - as Latch says).

I thought it was a common problem. Hope it's not just me...

[Edit] Oh yes - I forgot to say...

For the benefit of any newcomers who don't know what's involved in writing a screensaver, here's a quick guide.

Write your program as normal - whether it's 2D or 3D, but instead of using a Do..Loop for your main program loop as you would normally do, use a Repeat..Until instead - which you only exit if the mouse is moved or a key is pressed.

A rough skeleton program you can base it on would look something like this:



When your program is finished and you want to test it, compile it into an exe and change the extension to SCR. Eg: MyProg.exe would be renamed to MyProg.scr.

This file is then copied to the Windows directory with Win98/ME or Windows\System32 on XP (and I believe Win2K) systems. It should then be selectable from the list on the Screen Saver tab in Control Panel..Display.

TDK_Man

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Apr 2007 03:59 Edited at: 28th Apr 2007 21:16
I've got a few different things to come for this challenge.



Tone3e
17
Years of Service
User Offline
Joined: 17th Feb 2007
Location: here
Posted: 28th Apr 2007 04:19
Quote: "Strange - I've always had the flashing with DBC and XP. Over time, I've assumed it was XP, my graphics card, my system, DB Classic, DirectX - the lot!
"

I have had this problem sometimes as well. Especially when using the built in media browser for dbc. I like this new challenge. I think I will give this a try. it sounds fairly easy.

Future programming master.
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 28th Apr 2007 04:36 Edited at: 28th Apr 2007 04:39
Quote: "If you look at the code I posted in my last post, that's what I have to do to stop the flashing (Sync On: CLS 0: Sync - as Latch says)."

... or you can just begin the application with CLS.

What happens when when you mix coke, pop rocks, vinegar, and baking soda?
I am currently working on 2 projects: The Ultimate Killing Game & The Turtle Game
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 28th Apr 2007 04:43 Edited at: 28th Apr 2007 07:27
When you say "Screensaver" does it have to just be an application where it does everything for you and no controlling? If it is, can we use media? It would probably be hard if we could not use media.

I gotta be entering this time! I have some old planets that I made from Anim8or that I never used, so I'll be making one about planets orbiting around the sun.

What happens when when you mix coke, pop rocks, vinegar, and baking soda?
I am currently working on 2 projects: The Ultimate Killing Game & The Turtle Game
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Apr 2007 05:58
@Phaelax

That is really cool!

Enjoy your day.
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 28th Apr 2007 12:11
Sorry Sinani201,
no external media is allowed. Try playing around with 2D graphics like box,line,circle,ink rgb etc...


Nothing is impossible...
No really, it is.
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 28th Apr 2007 12:40 Edited at: 28th Apr 2007 12:41
@Phaelax

Awesome! Only one thing, you need to add an end at the end of your main loop otherwise is says that the program ran into function decleration. Very clever though!


Nothing is impossible...
No really, it is.
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 28th Apr 2007 18:28
Awwww man. What about online textures?

What happens when when you mix coke, pop rocks, vinegar, and baking soda?
I am currently working on 2 projects: The Ultimate Killing Game & The Turtle Game
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Apr 2007 21:46
You can have ANY textures in your program as long as the program generates them in code.

The rest of us should be able to copy and paste the snippet you post on here straight into DBC and just run it.

You just can't post a snippet that needs other files (downloaded or otherwise) before it will run.

Creating your own textures is quite easy, as NanoGamez guy says, using DB's 2D drawing commands.

Any particular texture you need? I'll help if I can.

TDK_Man

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Apr 2007 23:06
Ok, tried to cram a bunch of stuff into this: 3d, 2d, split screen, mirror reflections, rotating camera...

I left the fps in the top left corner. As a screen saver on my AMD 1.5 ghz it clocks at about 60 fps with no jitter. Directly in DBC, it clocks at about 80 fps. Please let me know what fps you get.



Enjoy your day.
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 28th Apr 2007 23:25
@latch

Cool reflections! 77fps


Nothing is impossible...
No really, it is.
Binary Coder
17
Years of Service
User Offline
Joined: 26th Feb 2007
Location: Queensland, Australia
Posted: 29th Apr 2007 06:08
Latch and Phaelax
Neither worked for me, latch's was just a blank screen and phaelax's said "warning at line 45 cannot create display mode"

Anyway im sure they were both good.

Why buy a game when you can make one?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 29th Apr 2007 09:48
Quote: "latch's was just a blank screen"


You're not using DB Pro are you? This is the DB Classic coding challenge thread.

Quote: "warning at line 45 cannot create display mode"


If your GFX card doesn't support 32bit, try changing the 32 to 16 - if you are using DBC of course...

TDK_Man

heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 30th Apr 2007 15:37
One tiny oversight TDK_Man,
you need put a Mouseclick() <> 0 check in your skeleton.

I use a trackball and often just click a button to exit a screensaver.

I'm unique, just like everybody else.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Apr 2007 17:01
Most people just move the mouse, so I don't usually add mouse button support in a screensaver, but fair point. Amended code below (just add the bit in bold if you have already used the skeleton in your program).



TDK_Man

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd May 2007 22:52
Common Everybody... This challenge allows you to do almost anything you want. Here's 3 short entries:

Very Boring:


Lots of Dots:


Orbiting words:


Enjoy your day.
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 4th May 2007 05:34 Edited at: 4th May 2007 06:03
Sorry latch, do i still have time, i can try something, i'm feeling confident. Aha i have returned, so this is my attempt. I wanna make more, more complex with particles. so that will be my night, i'm in a coding mood now, thanks guys .

oh yea, he's my first attempt.


a quivering dot fest


Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th May 2007 10:30 Edited at: 4th May 2007 11:30
Whoever is judging this one is gonna have a lot of entries to look at. And I'm gonna have a lot of database submissions to enter.

Latch, good idea on the break function, mind if I swipe the idea?

Starfield screensaver, not very original just doing it for fun.



Another starfield, slightly different method. This is actually an old version I did a long time ago and just found it. No sin/cos so I figure its probably faster.


I dug up some old code, made a few changes, and well here ya go.
Watch it draw a fern fractal, then it stays on the final image for 5 seconds before starting over with another fern with different values. Hold spacebar to speed up the drawing process by exiting out of the recursion earlier then wait to see the next one start.




I have 2 other ideas, but its 4:30am now. So if I got time later in the day and the challenge isn't over yet I'll try to work on them.


Login to post a reply

Server time is: 2024-04-23 07:04:49
Your offset time is: 2024-04-23 07:04:49