Author Topic: BreakThru won't work and I'm only at the beginning  (Read 2101 times)

0 Members and 1 Guest are viewing this topic.

Offline Jaze

  • Newbie
  • Posts: 86
    • View Profile
BreakThru won't work and I'm only at the beginning
« on: May 17, 2021, 04:55:58 pm »
Trying to make a BreakThru clone. As per my abilities, I'm making the clone with strings. BreakThru was a very old Atari 2600 video game. There are bricks on the top of the screen that you have to break through. To do this you have a ball bounce around the screen. The ball cannot go below the bottom of the screen or you lose a life. You have a paddle you can move left or right at the bottom of the screen. The idea is to get the paddle underneath the ball so it bounces to the top of the screen and breaks a brick. I'm only at the beginning of the code but I cannot get the paddle to move to the left and I don't know why. Please help
Code: QB64: [Select]
  1. CONST TRUE = 1 '       Constants I put in every program
  2. CONST FALSE = 0 '      Constant
  3. CONST t$ = "Û" '       I print out chr$(219) often so I use this constsant
  4.  
  5. WIDTH 80, 50 '         My programs are text based so I use this to get more lines
  6. _FULLSCREEN '          Pretty self explanatory. Maximize the window
  7. COLOR , 1: CLS '      Make the entire screen blue
  8.  
  9. 'I share most variables with all the subs and functions
  10.  
  11. DIM SHARED board(1 TO 80, 1 TO 48, 1 TO 2) ' create the playing area. when I do y as 50 or 49 the screen fucks up. either a character (x, y, 1) or a color (x, y, 2)
  12.  
  13. 'possibly change the paddle length to make the game easier or harder
  14. DIM SHARED paddleLength AS INTEGER: paddleLength = 7
  15. DIM SHARED paddleLeft AS INTEGER: paddleLeft = 36
  16.  
  17. GOTO beginning
  18. crap:
  19. PRINT "Error, error line"
  20.  
  21. beginning:
  22. CALL Main
  23.  
  24. SUB Main
  25.     CALL InstallBackground '          Make the playing area blue with a read boarder
  26.     CALL InstallPaddle(TRUE, paddleLeft) '    Put the paddle in the playing area
  27.     CALL InstallBall(TRUE, 40, 47) '  Put the ball in the playing area
  28.     CALL PrintBoard '                 Display the current board
  29.     dontContinuouslyPrintScreen = TRUE
  30.  
  31.     DO
  32.         currentCommand$ = INKEY$
  33.         'use the left and right arrow keys
  34.         SELECT CASE currentCommand$
  35.             CASE CHR$(0) + "K" ' left
  36.                 CALL InstallPaddle(FALSE, paddleLeft)
  37.                 paddleLeft = paddleLeft - 1
  38.                 IF paddleLeft <= 1 THEN paddleLeft = 2
  39.                 CALL InstallPaddle(TRUE, paddleLeft)
  40.                 dontContinuouslyPrintScreen = FALSE
  41.             CASE CHR$(0) + "M" 'right
  42.  
  43.                 IF dontContinuouslyPrintScreen = FALSE THEN
  44.                     CALL PrintBoard
  45.                     dontContinuouslyPrintScreen = TRUE
  46.                 END IF
  47.         END SELECT
  48.     LOOP
  49. SUB P '                          I use this for debugging and put it in every program I write
  50.     pause$ = INPUT$(1)
  51.     IF pause$ = CHR$(27) THEN END
  52.  
  53. SUB InstallBackground
  54.     FOR x = 1 TO 80 '             make the default board
  55.         FOR y = 1 TO 48
  56.             board(x, y, 1) = 219 ' make the background on the playiung area blue
  57.             board(x, y, 2) = 1 ' make the board print out blocks
  58.         NEXT y
  59.     NEXT x
  60.     FOR y = 1 TO 48
  61.         board(1, y, 1) = 219
  62.         board(1, y, 2) = 12
  63.         board(80, y, 1) = 219
  64.         board(80, y, 2) = 12
  65.     NEXT y
  66.     FOR x = 1 TO 80
  67.         board(x, 1, 1) = 219
  68.         board(x, 1, 2) = 12
  69.     NEXT x
  70.  
  71. SUB PrintBoard ' Print out the current board to the screen
  72.     FOR x = 1 TO 80
  73.         FOR y = 1 TO 48
  74.             LOCATE y, x '      position the cursor
  75.             COLOR board(x, y, 2), 1 '     make the color of the cursor
  76.             PRINT CHR$(board(x, y, 1)) '      display the correct character code for that position
  77.         NEXT y
  78.     NEXT x
  79.  
  80. SUB InstallPaddle (OnOrOff, x) '     put the paddle on the board
  81.     FOR count = x TO x + paddleLength '     variable paddle length to make the game easier or harder
  82.         IF OnOrOff = TRUE THEN '     put the paddle on the board
  83.             board(count, 48, 1) = 219
  84.             board(count, 48, 2) = 15
  85.         ELSEIF OnOrOff = FALSE THEN '        remove the padde from the board
  86.             board(count, 48, 1) = 219
  87.             board(count, 48, 2) = 1
  88.         END IF
  89.     NEXT count
  90.  
  91. SUB InstallBall (OnOrOff, x, y)
  92.     IF OnOrOff = TRUE THEN '    put the ball on the board
  93.         board(x, y, 1) = 254
  94.         board(x, y, 2) = 11
  95.     ELSEIF OnOrOff = FALSE THEN '      remove the ball from the board
  96.         board(x, y, 1) = 219
  97.         board(x, y, 2) = 1
  98.     END IF

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: BreakThru won't work and I'm only at the beginning
« Reply #1 on: May 17, 2021, 05:38:01 pm »
Oh do you mean Breakout?

I can't figure out what you are using to track your paddle location? PaddleX, PaddleY
« Last Edit: May 17, 2021, 05:47:31 pm by bplus »

Offline Jaze

  • Newbie
  • Posts: 86
    • View Profile
Re: BreakThru won't work and I'm only at the beginning
« Reply #2 on: May 17, 2021, 06:04:11 pm »
Never mind. Found the error. Thanks anyway