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.

Newcomers DBPro Corner / Take the challenge - new or pro to DB

Author
Message
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Nov 2005 16:50 Edited at: 26th Nov 2005 13:41
These exercises are designed for people that are new to programming. The exercices will sharpen you logical thinking.

* : beginner. Very basic
** : more advanced. But still beginner.
*** : normal
**** : harder
***** : Thinkers.

BASIC

1) DBC + DBP :: text practice *



Edit the program so, that it will print “hello world” instead of “helloworld” without changing A$ and B$.

2) DBC + DBP :: arrays and rnd() *



Adjust the code, that each array element has to be filled with a random number ranging from !1! to 10. After that, each element has to be displayed, and not only the last one, like this program.

3) DBC + DBP :: Functions *



Make the function working. It has to return the sum of the first and the second number.

5) DBC + DBP :: Conditions *



Add a condition. IF the variable A is smaller than 10 THEN display the text “The value is smaller than 10”. ELSE display the text “The value is greater than 10”.

6) DBC :: doubles **

DBP-users can do this exercise too, but they will have to handle inaccurate values.



Change the code that everything has to be changes so that it are doubles. A and B have to be ranging from 0.0 to 20.0 (so 19.1 or 12.7 are possibilities).

7) DBC + DBP :: input + answer with cases **

No code this time.
- 1 - **
Create a code, that will ask you
“How do you feel today? (1 = good, 2 = normal, 3 = bad)”.
You have to input 1, 2, 3. By using cases, the, program has to answer
“Hey I feel great too!” for 1,
“Nothing special then…” for 2,
“Cheer up! Live while you can.”
For 3 and for everything else, “What did you say?” and restart the program.

- 2 – **(*)
Code a program that:
Asks the first number.
Asks the second number.
Ask the operator (*, /, +, -). (no numbers!)
Using cases, you calculate the solution. When the user gives a invalid operator name, you have to give an error message, and restart just before you asked the operator. (Not the entire program).
Finally, you display the answer to the screen.

8) DBC + DBP :: timer text function ***
(By phaelax)

Make a function teletype(txt$, starttime, interval). the function will return a string. It has to look like the computer is typing by itself. The txt$ is the complete text, the starttime is the timer where it started, and interval is the milliseconds between each character.

-- Try and beat Phaelax' function of 5 lines including function and endfunction --

TEXT

1) DBC + DBP :: text *



What you have to get, is text, jumping around to the screen. When you succeed, you can try to add changing the color jumping too.

2) DBC + DBP :: Buttons ****

Make a function that creates a button: button(x,y,text$). Only the text may be displayed and all sorts of text has to be able to fit in this function. Set text font and set text size may not affect the working of this function. The color has to changes when the mouse hovers over the text, and return a 1 when user clicked on the text.
Colors are free choices.

3) DBC + DBP :: Text commands **



Add to the code:
Display the ASCII numbers of each letter beneath each other.
Display the 3 last letters of the name.
Display the 3 first letters of the name.
Display the name in capital letters.
Display the name in lowercase letters.

4) DBP :: Fonts *

Make user input a font. Repeat this program and ask the same question in the previous inputted font. Start with the font “Arial”.

INPUT

1) DBC + DBP :: Basic keys *



Add to this program:
- The ability to move the circle using the up/down/left or right arrow keys.
- Using control you can adjust the circle place by mouse.

2) DBC + DBP :: Mouse control **

Make a program that draws boxes on the screen. The user has to drag a box and you have to render all boxes the user created. You don’t have to add clicking/deleting boxes.
All boxes have to be rendered to the screen every loop.

3) DBC + DBP :: Clipboard *

Make a program that will ask the user to input their name. Then write it to the clipboard and quit the program. See if it works by pressing Crtl + V in an editor like notepad or word.

4) DBC(enhanced) + DBP :: Editor ***** !!!

Make a program that will let the user input text without using the “input a$” command.
There are certain rules for this challenge:
- The user has to be able to type up to 100 lines
- The user can navigate between the lines by pressing the arrow keys. When at the start of a line and left key is pressed, the cursor goes to the end of the previous line. When at end of line and right key is pressed, go to the start of next line.
- A carriage return will let the user go to the end of the next line (not the same effect as down key), and will not add itself to the text.
- The backspace has to do what it is supposed to, such as the delete key.
- When pressing tab, the program has to add 3 spaces instead.
- All text has to be offset 5px to the right.
- You have to be able to scroll.
- The current line and position has to be marked with a flickering “_”.
- You have to be able to edit text at the start, in the text or at the end.
- Colors are free choices.

Tip: Look over the internet for an ASCII table.

FILE

1) DBC + DBP :: File list *

Make a list of all files in the current directory.
If the user presses any key, go to the parent folder, clear screen and display a list of the files in this parent directory.
TIP: “..” is the string that let you go to the parent folder.

2) DBC + DBP :: Reading and writing **

Imagine you have a game and you want to save your progress. The values that have to be stored are:
Name$ (players name) “The Hero”
Posx# (players x position) 502.53
Posy# (players y position) 10.65
Posz# (players z position) 842.94
Angy# (players y angle) 356.72
Level (players level) 17

After this, make another program in the same directory that will load and display these values on the screen. The name of the file is free to choose.

3) DBC + DBP :: File browser ***(*)

Make a file browser. A list of clickable buttons (see the button challenge). The user has to be able to browse through windows.
Changing drives isn’t necessary.

If you want to earn your fourth start, make a browser that – apart from browsing – also can open models, images, music and sounds.
Models can be rotated freely (controls are free choices)
Images can be scrolled, resized and rotated.
Music and sounds can be played, paused and resumed. Volume control for sounds(and in DBP also for music).

DISPLAY

1) DBC + DBP :: Most used commands *

This is very easy
Make a program that displays any text in the exact middle of the screen. In any display mode.

2) DBC + DBP :: Short example *(*)

Just to make you familiar with the window commands of DB.

First: Change the window title to “Window command test”. Turn the window on.
Make a checklist for display modes and display it on the screen.
Second: Hide the window and wait 2 seconds.
Third: Show window and wait 2 seconds.
Fourth: Minimize window and wait 2 seconds
Fifth: Maximize the window and wait 2 seconds
At least: turn the window off.

BASIC 2D

1) DBP + DBC :: Color picker **

DBP: Make a box with in the left-top corner a white color, in the right-top corner a red color, in the right-bottom color a green color and in the left-bottom corner a blue color size 200 on 200.

DBC: Copy this image to your computer and paste the image on the screen in DBC.


Make a color picker, detect the color under the mouse position and display the red, green and blue values separately.

2) DBC + DBP :: Math circle 1 **
(Variation on Math circle)

Make a function to draw a circle. Only use the dot command.
(Try to make an ellipse afterwards)
Goniometry needed!

3) DBC + DBP :: Math circle ***
By Phaelax

Make a function to draw a circle. Simple? You’re not allowed to use the circle command, only line.
Step 2: Use only boxes.

4) DBC + DBP :: Rounded box ***(*)
Originally by Antidote

Make a function for a box with rounded corners.
The color can be adjusted externally, since the function will only draw 2D commands.

-- Personal note: Try and beat my function of 5 lines, 1 command each line. (including function and endfunction) --

5) DBC + DBP :: N polygon function ****(*)
(By phaelax)

Make a function that will draw a N-polygon.
polygon(n, side)
For example, an octagon has 8 sides and each side has to be the size of 10, the function will look like this: polygon(8, 10).
When you've done the circle challenge, this will be easy, but the real challenge will be: make the polygon filled.

BITMAP

1) DBC + DBP :: Introduction *

Bitmap commands are very slow. Which means it’s not used very much.
Draw 10 randomized boxes on the screen. (bitmap 0).
Wait 2 seconds, flip the bitmap
Wait 2 seconds, flip the bitmap back and mirror the bitmap
Wait 2 seconds, blur the bitmap 3 times.
Wait 2 seconds and quit program.

SOUNDS

1) DBC + DBP :: Sounds *

Load any sound you like. Loop it until the user hits a key.

2) DBC + DBP :: Sound control *

Load any sound you like, and keep looping it.
Increase the speed of the sound with the upkey, decrease the speed with the downkey.
Move the sound pan to the left using the leftkey, move the sound pan to the right using the rightkey.
Try to add boundries.

3) DBC + DBP :: Sounds, sounds and sounds *

Load any sound you like.
Duplicate the sound(without reloading it) 8 times.
Make each sound respond to 1 of the numeric keys (1-2-3-4-5-6-7-8-9).

TIP: No scancode or inkey, because this only takes 1 key at a time. Different keys can be played simultaneously.

4) DBC + DBP :: Media player ***

Make a little media player:
Load any sound you like.
Make 3 buttons: play, stop, pause/resume depending on what state it is now.
Make a volume slider. Real time volume control.


- - - - - - - - - - - - - - - - - - - - -
More exercices will come, when this thread becomes succesful.
Please do not post the answers or parts of answers in this thread. However, questions are always welcome.
If you would like to know if it is correct, mail me at svenboulanger(AT)hotmail.com

Immunity and Annihalation makes Immunihalation...
Freddy 007
19
Years of Service
User Offline
Joined: 30th Nov 2004
Location: Denmark
Posted: 18th Nov 2005 11:44
This is very cool. I haven't looked into any of the challenges yet(I don't know if I'm classified as a newb or not, but I don't think I am), but theese challenges look fun anyway.


I can't be fired... Slaves are SOLD!
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 19th Nov 2005 03:36 Edited at: 19th Nov 2005 13:37
Sorry disregard


The old sig is back
Freddy 007
19
Years of Service
User Offline
Joined: 30th Nov 2004
Location: Denmark
Posted: 19th Nov 2005 10:47
Umm...

Quote: "Please do not post the answers or parts of answers in this thread."



I can't be fired... Slaves are SOLD!
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 19th Nov 2005 11:50 Edited at: 19th Nov 2005 12:20
<Nevermind>


Freddy 007
19
Years of Service
User Offline
Joined: 30th Nov 2004
Location: Denmark
Posted: 19th Nov 2005 11:58
Hey, did I misunderstand something?

Quote: "Please do not post the answers or parts of answers in this thread."



I can't be fired... Slaves are SOLD!
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 19th Nov 2005 12:06
I did ask everyone not to post any answers. Because if you do, people might look into the answers before even trying thereselves.

So I ask you: Please edit your post and remove the code.

Immunity and Annihalation makes Immunihalation...
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 19th Nov 2005 12:21
Sorry, lol, but if it's a challenge.. then umm, how is it judged without posting the answers?


Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 19th Nov 2005 12:56
I will be at your service.
Mail me your answers when you want to know if they're correct.
svenboulanger(AT)hotmail.com

Immunity and Annihalation makes Immunihalation...
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 19th Nov 2005 15:16
[Update]

Try and take the challenge of the editor. (5-stars under input)

Window commands aren't very challenging...

I hope you enjoy

Sven B

Immunity and Annihalation makes Immunihalation...
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Nov 2005 22:01
yay, I passed them all. I did a file browser and custom input routine in DBC a long time ago.

Here's another challenge for you guys. I'll give it a 3 star warning.

DBC + DBP :: Math***

Make a function to draw a circle. Simple? You're not allowed to use the circle command, only line.


Deadly Night Assassins
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 20th Nov 2005 12:27 Edited at: 20th Nov 2005 12:30
Phaelax,

Can you send me the source of the input challenge? I would like to compare to my code

I will copy your challenge in the main list.

[edit] Well I will add it in the next update anyway. I'm following the list of the help files in DBP. The last one is DISTPLAY, wich means, yes, it's 2D's turn.

Sven B

Immunity and Annihalation makes Immunihalation...
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 20th Nov 2005 15:38
I wouldn't mind seeing the input challenge code. I tried it out and managed to get the numbers and backspace working but there were some major bugs. I wont enter anything I just want to see how it is done for future reference.


The old sig is back
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 20th Nov 2005 16:43
Actually, these are challenges. You have to search, search again and try...

I think it's too easy to just give you the code. What I don't mind, is giving some extra tips. As long as you create the code yourself.

Immunity and Annihalation makes Immunihalation...
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 20th Nov 2005 18:57 Edited at: 20th Nov 2005 18:58
OK I decided that I am gonna add my own challenge. It is kind of based off of Phaelax's circle challenge.

DBC + DBP :: Math ****
Make a box with rounded corners

Rules :
-The input should be x1, y1(upper left hand corner), x2, y2(bottom right hand corner), rad(The radius of the corners, should be able to go as high or low as the user wants)

-A background color is not necessary but if you add one make the color a parameter in the function

-You can also add thickness to the line but make sure to add that as a parameter

-You may only use the line command

-Hint: sine and cosine are your friends (sin(value), cos(value))


The old sig is back
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 20th Nov 2005 21:34
Great idea!

I adjusted it a little to make the challenge a bit more challenging:

Colors can be adjusted externally.
The box has to be filled.
You may use all 2D commands you want, but try not to cause a slowdown.

-- Personal note: Try and beat my function of 5 lines, including function and endfunction lines --

--> added to list of next update.

Immunity and Annihalation makes Immunihalation...
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 20th Nov 2005 22:08
I was thinking about how to fill it and the only way I came up with that doesn't require a ton of coding causes massive slowdown


The old sig is back
Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 20th Nov 2005 23:04
ok there's a lot of posts between the comment posts and the new chalenges... so I sugest that SvenB put all in the 1st topic


True Phantasy
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 21st Nov 2005 00:23
Quote: "More exercices will come, when this thread becomes succesful."


Quote: "
--> added to list of next update.
"


These quotes show that he is compiling everything so far into the first post


The old sig is back
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 21st Nov 2005 19:58
[update]

Added again a list of challenges!

The sound commands aren't complete, I know. But I'm planning to add them to the 3D-sector (3D listener, position sounds, etc.)

With thanks to antidote and phaelax for a couple of new challenges.

Immunity and Annihalation makes Immunihalation...
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 21st Nov 2005 22:32 Edited at: 21st Nov 2005 22:43
I love these challenges. There so much fun to make and then inspire you to make an entire set of GUI commands even if you already have 3 different .dba files with the exact same commands executed differently.

Also I just came up with another. I'm not sure where to put it or what the difficulty should be but here it is

Pixel Measurer
Click on the screen at one point, then draw a line from where you click to the mouse. Allow the user to click again and measure the distance between the first and second clicks. Have a message pop up telling the user the distance(in pixels).



Inaholler
19
Years of Service
User Offline
Joined: 31st Aug 2005
Location: A hollow in the woods
Posted: 22nd Nov 2005 20:25
A good idea and very well done!
Jim
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Nov 2005 08:28 Edited at: 23rd Nov 2005 08:40
Hope you don't mind me posting it here Sven. Custom input routine. It was part of a DBC game that handled typing of cheat codes into a console. I cut n' pasted the routines into DBP and made a little example. So this should work in both DBC and DBP. I did have another version which used commands from the DBC enhancment pack, but I don't know where that one is.



I also made a box with rounded corners, but the corners weren't adjustable.

Here's another challenge, 2D again.

Make a N polygon function. A shape with any number of sides the user wants. So 8 would draw an octagon, 6 is a hexagon, and a dodecagon would have 100 sides (i think). Should be pretty simple if you already did the circle challenge. Now the tough part, make it filled in. Either a solid color, or gradient for bonus points.



teletype function
function that outputs text 1 letter at a time. Allow the rest of the program to run while displaying the text. See if you can beat my function of only 5 lines of code, including function and endfunction.


Deadly Night Assassins
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 23rd Nov 2005 15:03
Phaelax,

I didn't understand what the teletype function has to do.
Could you send me an exe perhaps? (please zip or rar it if you do).

PS: dodeca means 12

Immunity and Annihalation makes Immunihalation...
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Nov 2005 08:51
email sent with exe


Deadly Night Assassins
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th Nov 2005 13:42
Thanks! I get it now. [added]

Immunity and Annihalation makes Immunihalation...

Login to post a reply

Server time is: 2024-09-24 09:37:39
Your offset time is: 2024-09-24 09:37:39