Hi guys :o) I am having a bit of a crisis with my code. When the ball hits the right side of the board, it doesn't reverse its direction for some reason. I have the code to print out the ball_x_speed variable, but it just displays an alternating number instead between 0 and 1.
here is my code:
Thanks guys!
here is my code:
Graphics3D 800,600 SetBuffer BackBuffer() Const BALL_COL = 1 Const BOARD_COL = 2 Global CAMERA = CreateCamera() PositionEntity CAMERA,0,54,-60 RotateEntity CAMERA,45,0,0 Global OMNI = CreateLight() AmbientLight 170,170,170 Global BOARD = LoadMesh("models/game_board.3ds") EntityType board,BOARD_COL Global ball_x# = 0 Global ball_x_speed = 1 Global ball_z# = 0 Global ball = CreateSphere() EntityType ball,BALL_COL EntityRadius ball,4 ScaleEntity ball,2,2,2 Collisions BALL_COL,BOARD_COL,2,2 While Not KeyHit(1) Cls PositionEntity ball,ball_x,2,ball_z ball_x = ball_x+ball_x_speed MoveEntity ball,ball_x_speed,0,0 If EntityCollided(ball,BOARD_COL) Then ball_x_speed = 1-ball_x_speed UpdateWorld RenderWorld Text 0,0,ball_x_speed Flip Wend End
Thanks guys!