Results 1 to 3 of 3

Thread: A simple breakout game prob

  1. #1
    Buccanner
    Guest

    Unhappy A simple breakout game prob

    hello peps
    i am writing a simple breakout prog where there is a row of bricks at the top of the page and there is a bat at the bottom and a ball wizzing aroud the screen i can't quite get the code right dor when the ball is hitting the bat. when it hits the bat it bounces off but when it comes down the page the ball bounces off the same level of the top of the bat reguardless of the bat being there

    If shpBall.Top + shpBall.Height > shpBat.Top Then '_
    'And shpBall.Top + shpBall.Height < shpBat.Left _
    'And shpBall.Top + shpBall.Height > shpBat.Left + shpBat.Width Then
    yDirection = -1
    End If

    this is close but not quite right any help much appriciated

    [email protected]

  2. #2
    Lively Member The_Fog's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    65
    You need to check if the ball is inside the bats x-range. somthing like this..

    In this example my screen look something like this.

    0, 0
    -------------------------------------------

    |
    |
    |
    |
    |
    |
    -------------------------------------------100, 100
    so the y axis is inverted!

    if ball.y + intmove >= screenheight - bar.height then
    if (ball.x >= bat.x) and (ball.x + width <= bat.x + bat.width) then
    'The entire ball is within the bats range
    elseif (ball.x >= bat.x) and (ball.x <= bat.x + width) then
    'The left side of the ball is within the bats range
    elseif (ball.x + width >= bat.x) and (ball.x + width <= bat.x + width) then
    'The right side of the ball is within the bats range
    else
    'the ball is NOT within the bats range
    end if
    else
    'The ball is NOT going to collide with the bat. Keep moving
    end if
    They will try to steal everything you own,
    It goes on and on and on...


    Pain - On and On

  3. #3
    Buccanner
    Guest
    Yeah this was on the right lines i have sorted it out using this layout thanks a lot

    cheers buccanner

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width