Author Topic: A VERY Simple Game!  (Read 3477 times)

0 Members and 1 Guest are viewing this topic.

Offline Prithak

  • Newbie
  • Posts: 56
  • Life itself is a Programming Language!
    • View Profile
    • My Programming Language
A VERY Simple Game!
« on: December 31, 2018, 09:55:41 pm »
This is a game I made in just 1 Hour. This is a game me and my friends used to play on paper but now, It's on PC! Here's the code:
(BTW, this is a 2-player game)
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. COLOR , _RGB32(255, 255, 255)
  3. COLOR _RGB32(0, 0, 0)
  4. turn = 1
  5. a$ = "CUT-N-CUT"
  6. LOCATE 1, 40 - LEN(a$) / 2: PRINT a$
  7. b$ = "A Multiplayer Game!"
  8. LOCATE 2, 40 - LEN(b$) / 2: PRINT b$
  9. LOCATE 3, 1: PRINT "This game is in development... So no multiplayer for the next 3 updates"
  10. INPUT "Enter the total no. "; no
  11. DIM x$(no)
  12. FOR i = 1 TO no
  13.     x$(i) = STR$(i)
  14. x = 1
  15. y = 1
  16. PRINT "2ND PLAYER LOOK BACK!!!"
  17. INPUT "1st Player enter your chosen number"; cn1
  18. PRINT "1ST PLAYER LOOK BACK!!!"
  19. INPUT "2nd Player enter your chosen number"; cn2
  20.     x = 1
  21.     y = 1
  22.     FOR i = 1 TO no
  23.         LOCATE y, x: PRINT x$(i)
  24.         LOCATE 1, 20: PRINT "Turn: "; turn
  25.         y = y + 1
  26.         IF y > 25 THEN
  27.             y = 1
  28.             x = x + 10
  29.         END IF
  30.     NEXT
  31.     in:
  32.     LOCATE 26, 1: INPUT "Enter your num"; num
  33.     IF RIGHT$(x$(num), 5) = "(CUT)" THEN
  34.         PRINT "That number is already chosen!"
  35.         GOTO in
  36.     END IF
  37.     x$(num) = x$(num) + "(CUT)"
  38.     IF num = cn1 AND turn = 2 THEN
  39.         PRINT "PLAYER 1 WINS!!"
  40.         END
  41.     ELSEIF num = cn1 AND turn = 1 THEN
  42.         PRINT "PLAYER 1 CUT HIS/HER OWN NUMBER! PLAYER 2 WINS!!"
  43.         END
  44.     ELSEIF num = cn2 AND turn = 1 THEN
  45.         PRINT "PLAYER 2 WINS!!"
  46.         END
  47.     ELSEIF num = cn2 AND turn = 2 THEN
  48.         PRINT "PLAYER 2 CUT HIS/HER OWN NUMBER! PLAYER 1 WINS!!"
  49.         END
  50.     END IF
  51.     IF turn = 1 THEN
  52.         turn = 2
  53.     ELSEIF turn = 2 THEN
  54.         turn = 1
  55.     END IF
  56.  
  57.     _DISPLAY
  58.     CLS
  59.     _LIMIT 60
  60. 'LOL
  61. 'LOL
  62.  
And also, I'm looking for making this a competitive game, If any ideas bubble up your mind. Please let me know!
HOW TO PLAY:
1) Choose the limit of the numbers(Like, From 1 to 20)
2) Player 1 Chooses a Number from 1 to 20
3) Player 2 Chooses another Number from 1 to 20
4) If Player 1 Cuts the number of Player 2, Player 2 Wins.
5) If Player 2 Cuts the number of Player 1, Player 1 Wins.
6) If Player 1 or 2 Cuts his/her own number, he/she loses.

It's as simple as that!

With due regards,
-Prithak
CLS
IF computer$ = "ON" THEN
me$ = "Happy!"
ELSE
me$ = "Time To Draw!"
END IF
END

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A VERY Simple Game!
« Reply #1 on: January 01, 2019, 11:08:52 am »
Hi Prithak,

I love simple games.

So the object of this game is to NOT be the first to pick one of the picked numbers, as opposed to say trying to guess what the other player did pick before the other player does. So if the other player seems to be avoiding a number that might be the one he picked. Correct?

I am surprised the font effect achieved by _FULLSCREEN.

I will try a version to play against the computer, if you don't mind.
« Last Edit: January 01, 2019, 11:10:14 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A VERY Simple Game!
« Reply #2 on: January 01, 2019, 04:38:52 pm »
Ha, took an hour to write up, a couple of hours to debug (and overhaul) some more hours to refine:
Code: QB64: [Select]
  1. _TITLE "Who cut 1?" 'inspired by Prithak's game posted 2018-12-31
  2. 'the disadvantage of going first is you are first in line to risk the bomb
  3. 'the advantage is if both players pick the same number for the bomb the first will never get it.
  4.     CLS 'show instructions to game
  5.     cp 2, "Who Cut 1 ?"
  6.     cp 4, "This game has 0 to 9 numbers to pick from."
  7.     cp 5, "You will plant a bomb under one."
  8.     cp 6, "The computer will do the same."
  9.     cp 7, "You will take turns cutting numbers"
  10.     cp 8, "until one cuts a number with a bomb."
  11.     cp 10, "Player =" + STR$(player) + "  Computer =" + STR$(computer)
  12.     'computer chooses it's bomb site
  13.     choices$ = "0123456789"
  14.     computerBomb = INT(RND * 10)
  15.     MID$(choices$, computerBomb + 1, 1) = "b"
  16.  
  17.     'player choice's bomb site
  18.     DO
  19.         PRINT: cp 13, "Player, enter the number place (0 to 9) for your bomb > "
  20.         INPUT "", bomb
  21.         CLS
  22.     LOOP UNTIL bomb >= 0 AND bomb <= 9
  23.     MID$(choices$, bomb + 1, 1) = "b"
  24.  
  25.     'start game
  26.     gameover = 0
  27.     WHILE NOT gameover
  28.         'display cuts up to this point
  29.         CLS
  30.         'PRINT computerBomb; " Numbers left:  " + choices$ '<<<<<< debug track hidden game status
  31.         PRINT "Numbers left:"
  32.         nonCutChoices$ = ""
  33.         FOR i = 0 TO 9
  34.             IF MID$(choices$, i + 1, 1) <> "c" THEN
  35.                 PRINT i
  36.                 nonCutChoices$ = nonCutChoices$ + LTRIM$(STR$(i))
  37.             ELSE
  38.                 PRINT "Cut"
  39.             END IF
  40.         NEXT
  41.  
  42.         'computer moves first each turn
  43.         'don't be a stupid computer and pick the bomb you planted!!!
  44.         computerPick = computerBomb
  45.         WHILE computerPick = computerBomb
  46.             computerPick = VAL(MID$(nonCutChoices$, INT(RND * LEN(nonCutChoices$) + 1), 1))
  47.         WEND
  48.         LOCATE 13, 1: PRINT "Computer picks "; computerPick
  49.         IF MID$(choices$, computerPick + 1, 1) = "b" THEN
  50.             PRINT "BOOM!, Player wins!"
  51.             winner$ = "player"
  52.             LOCATE computerPick + 2, 4: PRINT "BOOM!"
  53.             gameover = -1
  54.         ELSE
  55.  
  56.             'computer picks successfully
  57.             MID$(choices$, computerPick + 1, 1) = "c"
  58.             LOCATE computerPick + 2, 4: PRINT "Cut"
  59.  
  60.             'player's turn, don't allow player cheat by cutting a number already cut
  61.             DO
  62.                 LOCATE 15, 1: PRINT SPACE$(79)
  63.                 LOCATE 15, 1: INPUT "Player, enter a number to cut (not yet cut) > ", playerPick
  64.             LOOP WHILE MID$(choices$, playerPick + 1, 1) = "c" OR playerPick = computerPick
  65.  
  66.             'handle player's legal choice
  67.             IF MID$(choices$, playerPick + 1, 1) = "b" THEN
  68.                 PRINT "BOOM!, Computer wins!"
  69.                 winner$ = "computer"
  70.                 LOCATE playerPick + 2, 4: PRINT "BOOM!"
  71.                 gameover = -1
  72.             ELSE
  73.                 MID$(choices$, playerPick + 1, 1) = "c"
  74.                 LOCATE playerPick + 2, 4: PRINT "Cut"
  75.                 LOCATE 16, 1: PRINT "Good pick."
  76.                 _DELAY 1
  77.             END IF
  78.         END IF
  79.         ' if gameover still = 0 then loop around
  80.     WEND
  81.  
  82.     'finish game, total scores
  83.     IF winner$ = "player" THEN player = player + 1 ELSE computer = computer + 1
  84.     cp 18, "Play again? enter y for yes > "
  85.     INPUT "", again$
  86.     IF again$ <> "y" THEN done = -1
  87. LOOP UNTIL done
  88.  
  89. SUB cp (row, text$)
  90.     LOCATE row, (80 - LEN(text$)) / 2: PRINT text$;
  91.  
  92.  
« Last Edit: January 01, 2019, 04:40:46 pm by bplus »

Offline Prithak

  • Newbie
  • Posts: 56
  • Life itself is a Programming Language!
    • View Profile
    • My Programming Language
Re: A VERY Simple Game!
« Reply #3 on: January 02, 2019, 10:44:48 pm »
Ha, took an hour to write up, a couple of hours to debug (and overhaul) some more hours to refine:
Code: QB64: [Select]
  1. _TITLE "Who cut 1?" 'inspired by Prithak's game posted 2018-12-31
  2. 'the disadvantage of going first is you are first in line to risk the bomb
  3. 'the advantage is if both players pick the same number for the bomb the first will never get it.
  4.     CLS 'show instructions to game
  5.     cp 2, "Who Cut 1 ?"
  6.     cp 4, "This game has 0 to 9 numbers to pick from."
  7.     cp 5, "You will plant a bomb under one."
  8.     cp 6, "The computer will do the same."
  9.     cp 7, "You will take turns cutting numbers"
  10.     cp 8, "until one cuts a number with a bomb."
  11.     cp 10, "Player =" + STR$(player) + "  Computer =" + STR$(computer)
  12.     'computer chooses it's bomb site
  13.     choices$ = "0123456789"
  14.     computerBomb = INT(RND * 10)
  15.     MID$(choices$, computerBomb + 1, 1) = "b"
  16.  
  17.     'player choice's bomb site
  18.     DO
  19.         PRINT: cp 13, "Player, enter the number place (0 to 9) for your bomb > "
  20.         INPUT "", bomb
  21.         CLS
  22.     LOOP UNTIL bomb >= 0 AND bomb <= 9
  23.     MID$(choices$, bomb + 1, 1) = "b"
  24.  
  25.     'start game
  26.     gameover = 0
  27.     WHILE NOT gameover
  28.         'display cuts up to this point
  29.         CLS
  30.         'PRINT computerBomb; " Numbers left:  " + choices$ '<<<<<< debug track hidden game status
  31.         PRINT "Numbers left:"
  32.         nonCutChoices$ = ""
  33.         FOR i = 0 TO 9
  34.             IF MID$(choices$, i + 1, 1) <> "c" THEN
  35.                 PRINT i
  36.                 nonCutChoices$ = nonCutChoices$ + LTRIM$(STR$(i))
  37.             ELSE
  38.                 PRINT "Cut"
  39.             END IF
  40.         NEXT
  41.  
  42.         'computer moves first each turn
  43.         'don't be a stupid computer and pick the bomb you planted!!!
  44.         computerPick = computerBomb
  45.         WHILE computerPick = computerBomb
  46.             computerPick = VAL(MID$(nonCutChoices$, INT(RND * LEN(nonCutChoices$) + 1), 1))
  47.         WEND
  48.         LOCATE 13, 1: PRINT "Computer picks "; computerPick
  49.         IF MID$(choices$, computerPick + 1, 1) = "b" THEN
  50.             PRINT "BOOM!, Player wins!"
  51.             winner$ = "player"
  52.             LOCATE computerPick + 2, 4: PRINT "BOOM!"
  53.             gameover = -1
  54.         ELSE
  55.  
  56.             'computer picks successfully
  57.             MID$(choices$, computerPick + 1, 1) = "c"
  58.             LOCATE computerPick + 2, 4: PRINT "Cut"
  59.  
  60.             'player's turn, don't allow player cheat by cutting a number already cut
  61.             DO
  62.                 LOCATE 15, 1: PRINT SPACE$(79)
  63.                 LOCATE 15, 1: INPUT "Player, enter a number to cut (not yet cut) > ", playerPick
  64.             LOOP WHILE MID$(choices$, playerPick + 1, 1) = "c" OR playerPick = computerPick
  65.  
  66.             'handle player's legal choice
  67.             IF MID$(choices$, playerPick + 1, 1) = "b" THEN
  68.                 PRINT "BOOM!, Computer wins!"
  69.                 winner$ = "computer"
  70.                 LOCATE playerPick + 2, 4: PRINT "BOOM!"
  71.                 gameover = -1
  72.             ELSE
  73.                 MID$(choices$, playerPick + 1, 1) = "c"
  74.                 LOCATE playerPick + 2, 4: PRINT "Cut"
  75.                 LOCATE 16, 1: PRINT "Good pick."
  76.                 _DELAY 1
  77.             END IF
  78.         END IF
  79.         ' if gameover still = 0 then loop around
  80.     WEND
  81.  
  82.     'finish game, total scores
  83.     IF winner$ = "player" THEN player = player + 1 ELSE computer = computer + 1
  84.     cp 18, "Play again? enter y for yes > "
  85.     INPUT "", again$
  86.     IF again$ <> "y" THEN done = -1
  87. LOOP UNTIL done
  88.  
  89. SUB cp (row, text$)
  90.     LOCATE row, (80 - LEN(text$)) / 2: PRINT text$;
  91.  
  92.  
WOW! I'd love including this in my main game but I need to learn this not CTRL + C and CTRL + V it xD. This was a nice play bplus! Thanks for making this

-Prithak
CLS
IF computer$ = "ON" THEN
me$ = "Happy!"
ELSE
me$ = "Time To Draw!"
END IF
END

Offline Prithak

  • Newbie
  • Posts: 56
  • Life itself is a Programming Language!
    • View Profile
    • My Programming Language
Re: A VERY Simple Game!
« Reply #4 on: January 02, 2019, 10:46:49 pm »
Hi Prithak,

I love simple games.

So the object of this game is to NOT be the first to pick one of the picked numbers, as opposed to say trying to guess what the other player did pick before the other player does. So if the other player seems to be avoiding a number that might be the one he picked. Correct?

I am surprised the font effect achieved by _FULLSCREEN.

I will try a version to play against the computer, if you don't mind.
Correct! BTW, I came up with this game at school xD. Instead of guessing others number, we have to avoid it lol.
I'm surprised as well at the font of _FULLSCREEN! It looks cool!

-Prithak
CLS
IF computer$ = "ON" THEN
me$ = "Happy!"
ELSE
me$ = "Time To Draw!"
END IF
END

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A VERY Simple Game!
« Reply #5 on: January 03, 2019, 07:50:51 am »
A nice game and a pleasure to share ideas with someone across the world! :)