Breakout clone help

Blitz3D Forums/Blitz3D Beginners Area/Breakout clone help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Alright, i don't know what i'm doing wrong, but its not working, the ball isnt flying off right only up and down:

first off i changed most of my images into real images and auto midhandled 'em and drew em and also got rid of the player_x+50 thing and just made it player_x because the midhandle allows that Everthing looks in working order when the ball is centered the text display says its 0.0 and each edge is 1.0 and -1.0:

The drawing codes changes the ball and the player into real images alowing midhandles:
;creates the empty containers to draw on using the buffer
AutoMidHandle True
player=CreateImage(100,20)
ball=CreateImage(20,20)
life1=CreateImage(20,20)
life2=CreateImage(20,20)
life3=CreateImage(20,20)

SetBuffer ImageBuffer(player)
Rect 0,0,100,20

SetBuffer ImageBuffer(ball)
Oval 0,0,20,20


SetBuffer BackBuffer()


shows how i drew the images onto the screen:
    ;Draws the MouseDot
    Oval mouse_x,mouse_y,1,1

    ;Draws the ball
    DrawImage ball,ball_x,ball_y
    
    ;Draws the life's depending on the lifes veriable
    If lifes>1 Then
    Oval 1411,1005,20,20
  End If
    If lifes>2 Then
    Oval 1433,1005,20,20
  End If
    If lifes>3 Then
    Oval 1455,1005,20,20
  End If
  
    ;Draws the player controled object
    DrawImage player,player_x,player_y

    ;Draws the "Power" block and some of its functions E.G if reachs a point it resets
    Color pr,pb,pg
    Rect PL,power_y,60,38
    power_y = power_y+ 10
    If power_y = 1050 Then power_y = 0
    If power_y =0 Then PL=Rand(0,1580)
    
    ;Color switched back to white
    Color 255,255,255
  
    ;Draws the pillars using types
   For pillars.pillar=Each pillar
   If pillars\hp=1 Then Color pillars\r,pillars\b,pillars\g:Rect pillars\X,pillars\Y,100,30,1:Color 0,0,0:Rect pillars\X,pillars\Y,100,30,0
Next


Shows how i did the ball movement function:
Function ballmovement()

newspeedx = (ball_x - player_x)*.01

ball_x = ball_x + bal_xdir*5
ball_y = ball_y + bal_ydir*5

If ball_y < 0 Then bal_ydir = 1
If ball_y > 1040 Then move=0 lifes=lifes-1
If ball_x < 0 Then bal_xdir = 1
If ball_x > 1670 Then bal_xdir = -1

If ImagesCollide (ball,ball_x,ball_y,0,player,player_x,player_y,0) Then bal_ydir = -1 bal_xdir = newspeedx

If move=0 Then
ball_y=player_y+-20
ball_x=player_x
End If

End Function


And shows that the display matchs the function
Color 255,255,255
Text 0, 0,(ball_x - player_x)*.01


Well thats everything that would have to do with the ball bouncing off the paddle the wrong way(i think)

Any ideas what i did wrong? and if you need more code let me know, also thanks for all the help i'm still learning.