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

Darkbasic help!!!!

GrailKnightGrailKnight 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

Comments

  • RemarRemar 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

Sign In or Register to comment.