• Need Help
    6 replies, posted
Hi I am making a Clue remake in Qbasic but I don't know how to make the program give out the cards and not duplicating the same card I tried with a small program but when I try to do it in a bigger program it stats to Loop when I make it check the cards. Sorry if this doesn't make sense my head hurts from trying all night to get this to work. And if my spelling is off.
I don't know QBasic, but something among the lines of [code]CardsArray = { CardA, CardB, ... } for(int i = 1; i < CardsArray.length; ++i) CardArray.swap(i, rand(0, i));[/code]
[QUOTE=ZeekyHBomb;25305939]I don't know QBasic, but something among the lines of [code]CardsArray = { CardA, CardB, ... } for(int i = 0; i < CardsArray.length; ++i) CardArray.swap(0, rand(0, i));[/code][/QUOTE] It's not like any Basic has C-style for-loops. Or objects. Or arrays like that.
[QUOTE=esalaka;25306426]It's not like any Basic has C-style for-loops. Or objects. Or arrays like that.[/QUOTE] It's not like I implied that.
[QUOTE=Jacob_sword;25305858]Hi I am making a Clue remake in Qbasic but I don't know how to make the program give out the cards and not duplicating the same card I tried with a small program but when I try to do it in a bigger program it stats to Loop when I make it check the cards. Sorry if this doesn't make sense my head hurts from trying all night to get this to work. And if my spelling is off.[/QUOTE] Post the code you have. IIRC QBasic has a SWAP command.
This is the small version of it CLS RANDOMIZE TIMER REM CARDS= 1 CARD1 = INT(RND * 3) + 1 CARD2 = INT(RND * 3) + 1 CARD3 = INT(RND * 3) + 1 REM GOTO 1 IF CARD IS THE SAME IF CARD1 = CARD2 THEN GOTO 1 IF CARD1 = CARD3 THEN GOTO 1 IF CARD2 = CARD1 THEN GOTO 1 IF CARD2 = CARD3 THEN GOTO 1 IF CARD3 = CARD1 THEN GOTO 1 IF CARD3 = CARD2 THEN GOTO 1 REM WHAT THE CARDS ARE IF CARD1 = 1 THEN PRINT "1" IF CARD1 = 2 THEN PRINT "2" IF CARD1 = 3 THEN PRINT "3" IF CARD2 = 1 THEN PRINT "1" IF CARD2 = 2 THEN PRINT "2" IF CARD2 = 3 THEN PRINT "3" IF CARD3 = 1 THEN PRINT "1" IF CARD3 = 2 THEN PRINT "2" IF CARD3 = 3 THEN PRINT "3" 2 PRINT "AGAIN" PRINT "Y/N" INPUT YN$ YN$ = UCASE$(YN$) IF YN$ = "Y" THEN CLS IF YN$ = "Y" THEN GOTO 1 IF YN$ = "N" THEN END GOTO 2 Sorry for any misspellings. [editline]06:18PM[/editline] This is the small version of it CLS RANDOMIZE TIMER REM CARDS= 1 CARD1 = INT(RND * 3) + 1 CARD2 = INT(RND * 3) + 1 CARD3 = INT(RND * 3) + 1 REM GOTO 1 IF CARD IS THE SAME IF CARD1 = CARD2 THEN GOTO 1 IF CARD1 = CARD3 THEN GOTO 1 IF CARD2 = CARD1 THEN GOTO 1 IF CARD2 = CARD3 THEN GOTO 1 IF CARD3 = CARD1 THEN GOTO 1 IF CARD3 = CARD2 THEN GOTO 1 REM WHAT THE CARDS ARE IF CARD1 = 1 THEN PRINT "1" IF CARD1 = 2 THEN PRINT "2" IF CARD1 = 3 THEN PRINT "3" IF CARD2 = 1 THEN PRINT "1" IF CARD2 = 2 THEN PRINT "2" IF CARD2 = 3 THEN PRINT "3" IF CARD3 = 1 THEN PRINT "1" IF CARD3 = 2 THEN PRINT "2" IF CARD3 = 3 THEN PRINT "3" 2 PRINT "AGAIN" PRINT "Y/N" INPUT YN$ YN$ = UCASE$(YN$) IF YN$ = "Y" THEN CLS IF YN$ = "Y" THEN GOTO 1 IF YN$ = "N" THEN END GOTO 2 Sorry for any misspellings. [editline]06:20PM[/editline] Don't know why it copied and says edited?
You don't need that IF CARDx = y, just do PRINT CARDx. And lookup QBasic arrays: [code]DIM CARD(3) FOR I = 0 TO 3 CARD(I) = I + 1 FOR I = 1 TO 3 SWAP(CARD(I), CARD(INT(RND * I)))[/code]
Sorry, you need to Log In to post a reply to this thread.