Darkbasic help!!!! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Darkbasic help!!!!

Posts: 1Member
Hi, i've been learning how to use dark basic and I know, well, the basics of it..lol. For my first program I decided to make a dice roll generatore..like, you input what sided dice and how many of them to roll, and the program tells you what you got. Well, I'm having a problem. I can get it to output what sided dice they chose.

For example, the user decides he wants to roll 2, 6 sided dice. I can only get the program to put out a random number for 1, 6 sided dice..I have no idea how to make it so if the user wants to roll 2, it rolls 2 dice, instead of once.

Please, any help would be appreciated.

~Eric

• Posts: 28Member
: Hi, i've been learning how to use dark basic and I know, well, the basics of it..lol. For my first program I decided to make a dice roll generatore..like, you input what sided dice and how many of them to roll, and the program tells you what you got. Well, I'm having a problem. I can get it to output what sided dice they chose.
:
: For example, the user decides he wants to roll 2, 6 sided dice. I can only get the program to put out a random number for 1, 6 sided dice..I have no idea how to make it so if the user wants to roll 2, it rolls 2 dice, instead of once.
:
: Please, any help would be appreciated.
:
: ~Eric
:

Simple, use a FOR-loop:
[code]
FOR i = 1 TO nrDice
diceroll = INT(RND*sidesonDie) + 1
PRINT diceroll
NEXT i
[/code]
Note that the 'i' could be used in the loop as a counter, but it's not necessary here.

I really hope DarkBasic has the same syntax as QBasic, or this code might not work :-)
Lookup how FOR-loops works in that case...

/ remar