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 / Is this the best way to make this simple game?

Author
Message
Billups138
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 25th Mar 2011 03:35
I am very new to DarkBASIC and this is one of many pointless things i have made, i am wondering if this is one of the best ways to make this. The game is basicly explained in the first 2 pages of it, just please help. I know the basic commands. I do not know what the "case" command is as i have seen it frequently of the "sync rate" command. Explain those if you can.

Thanks for whatever help i get, i made this game in 150 lines. (With empty lines for organization)

The object of war is not to die for your country, but to make all of the other bas***** die for theirs.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Mar 2011 18:46
That works fine but yes you might use "select" and "case" to tidy it up a bit:


Billups138
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 27th Mar 2011 04:53
i dont know select or case statements...

could you explain those?

The object of war is not to die for your country, but to make all of the other bas***** die for theirs.
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 27th Mar 2011 11:19 Edited at: 27th Mar 2011 11:22
I will,

Select Variable means, that we're selecting that variable for checking, now: Case 1 means something like; If variable=1. So does Case 2, but it stands for 2. Example:



That's all. It will display "Our variable equals 1!" because we set myvar to 1 at the beginning. If set to 2, it will display the second text.

Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 27th Mar 2011 11:42
Is using that method faster, or why everybody recommends it over IFTHEN all the time?
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 27th Mar 2011 12:31
It's useful when you have something liek this:



So it's better to change it on:



It just makes the code cleaner.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 27th Mar 2011 18:55
Quote: "Is using that method faster, or why everybody recommends it over IFTHEN all the time?"


It's only used for checking a single variable so if you need multiple checks like "if this and that" then IF/THEN is the way to go.

Billups138
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 27th Mar 2011 18:58
so does that only work for integers?

or can you do this


so would that work? but also having a way to have the user change the variable

The object of war is not to die for your country, but to make all of the other bas***** die for theirs.
Billups138
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 27th Mar 2011 19:27
ok, i did this in DBP and this worked



so am i getting the right idea of it?

The object of war is not to die for your country, but to make all of the other bas***** die for theirs.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 27th Mar 2011 23:24
Yup that's exactly how it's used. There is also a default option you can add if it isn't any of the CASEs.



It's also better when dealing with strings to convert the string to lower case or higher case before you check. If a$ was from user input and they typed in "LOL" or "lOl" or "Lol" and you're checking for "lol" it won't see it as the same. Use the UPPER$() or LOWER$() commands to convert to higher case or lower case.

Billups138
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 28th Mar 2011 04:06
thanks for reminding me how to do the lower and upper case translations, i need that to get extra credit on my hangman game

and the case and select makes perfect sense thanks to you!

and i really like that default option you can do, thanks for all the help Grog Grueslayer

The object of war is not to die for your country, but to make all of the other bas***** die for theirs.

Login to post a reply

Server time is: 2024-11-22 23:14:56
Your offset time is: 2024-11-22 23:14:56