My first game(written in BASIC)
I have finished my first actual game in BASIC. It is a weak slot machine type game yet it works and is quite fun. I was wondering how i could add a picture of coins whenever you win.
PRINT "READY FOR THE GAMES?"
INPUT PROMPT "Would you like to play? PRESS 1 FOR YES AND 2 FOR NO! ":answer
IF answer=2 then
STOP
ELSEIF answer=1 then
END IF
PRINT "We are going to make a slot machine for you!"
PRINT "You are going to start off with 100 tokens!"
LET tokens=100
FOR count=1 to 100
RANDOMIZE
LET box1=Int(Rnd*3)+1
LET box2=Int(Rnd*3)+1
LET box3=Int(Rnd*3)+1
PRINT "[";box1;"]","[";box2;"]","[";box3;"]"
IF box1=3 AND box2=3 AND box3=3 THEN
LET tokens=tokens+12
PRINT "You have won 12 tokens!"
PRINT tokens
ELSEIF box1=2 AND box2=2 AND box3=2 THEN
LET tokens=tokens+8
PRINT "You have won 8 tokens!"
PRINT tokens
ELSEIF box1=1 AND box2=1 AND box3=1 THEN
LET tokens=tokens+4
PRINT "You have won 4 tokens!"
PRINT tokens
ELSE
LET tokens=tokens-1
PRINT "YOU HAVE LOST 1 TOKEN!"
PRINT tokens
END IF
INPUT PROMPT "Would you like to play? PRESS 1 FOR YES AND 2 FOR NO!":answer
IF answer=2 then
STOP
ELSEIF answer=1 then
END IF
PRINT
PRINT "YOU NOW HAVE";tokens;" tokens!"
PRINT
NEXT count
END
I have also written a horrible BlackJack game I want to add cards to.
What flavour of basic are you using? Did you get a manual with it?
Most basic varieties provide for graphics, but it can vary from product to product...
Most basic varieties provide for graphics, but it can vary from product to product...
1. I am using TRUE BASIC
2. I am learning this language as a prerequisite to C++.
3. We have no textbook for TRUE BASIC, just notes and we are not messing with graphics in TRUE BASIC
2. I am learning this language as a prerequisite to C++.
3. We have no textbook for TRUE BASIC, just notes and we are not messing with graphics in TRUE BASIC
Congrats on your first game. Perhaps, for 'graphics', you could simply print out a row of asterisks, one per coin, or suchlike?
In the interest of efficiency, you may want to eliminate some redundant lines. For example, here:
IF answer=2 then
STOP
ELSEIF answer=1 then
END IF
Since your else case is not doing anything, you don't really need to clutter up your code with it. Just
IF (answer = 2) then STOP
ENDIF
would do. You may also want to get in the habit of putting parentheses around your test clauses in IF statements; it's helpful when they get more complicated. But this is a matter of taste, to be sure. (It is possible that TRUE BASIC doesn't allow this syntax, although I certainly hope it does. If that's so, you should ignore me. :) )
In the interest of efficiency, you may want to eliminate some redundant lines. For example, here:
IF answer=2 then
STOP
ELSEIF answer=1 then
END IF
Since your else case is not doing anything, you don't really need to clutter up your code with it. Just
IF (answer = 2) then STOP
ENDIF
would do. You may also want to get in the habit of putting parentheses around your test clauses in IF statements; it's helpful when they get more complicated. But this is a matter of taste, to be sure. (It is possible that TRUE BASIC doesn't allow this syntax, although I certainly hope it does. If that's so, you should ignore me. :) )
I am unfamiliar with TrueBasic, but from their site:
8) Does True BASIC Support Graphics?
True BASIC supports several forms of line and point graphics. It can also display image files in BMP and several other formats. For example, here is a simple program that draws a graph of the square root function.
FOR x = 0 to 1 step .01
PLOT x, sqr(x);
NEXT x
END
Displaying image files should be sufficent to what you need. I would check your product documentation.
8) Does True BASIC Support Graphics?
True BASIC supports several forms of line and point graphics. It can also display image files in BMP and several other formats. For example, here is a simple program that draws a graph of the square root function.
FOR x = 0 to 1 step .01
PLOT x, sqr(x);
NEXT x
END
Displaying image files should be sufficent to what you need. I would check your product documentation.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement