plinky prob

Blitz3D Forums/Blitz3D Programming/plinky prob

I am having a prob with my plink game:

I can't get the ball to bounce off the pegs!

Thus us my source code
; PLINKS
; Ralph Dunn ne Rook Zimbabwe
; 4 FEB 2004
; ##############################################################

Graphics3D 800,600,32,1
SetBuffer BackBuffer()

camera=CreateCamera()
CameraRange camera,.1,999    ; changed to 999 for large distance
PositionEntity camera,-1.5,11.5,28

light = CreateLight() ; Turn on the lights

; ##################################### LOAD B3D MESH

ballz=LoadMesh( "ball.b3d" )
EntityType ballz,1
ScaleEntity ballz,.2,.2,.2
PositionEntity ballz,0,15,-10

board=LoadMesh( "board.b3d" )
EntityType board,2
TurnEntity board,25,0,0

plinkz=LoadMesh( "plinks.b3d" )
EntityType plinkz,3
TurnEntity plinkz,25,0,0

; ###################################### LOOK AT THE BOARD

lookboard=CreatePivot(board) ; create a pivot so we see the board

PointEntity camera,lookboard ; turn the cam to see the pivot of lookboard... we see it!

; ######################################  Set collisions

Collisions 1,2,2,3
Collisions 1,3,2,2

que$="OFF"

While Not KeyHit(1) ; ####################### START LOOP


x#=EntityX(ballz)   ; These get the position of the ball so we can fling it about
y#=EntityY(ballz)
z#=EntityZ(ballz)

; ---- HOW TO USE GRAVITY

y#=y#-1   ; the subtle force of gravity
z#=z#+.5   ; the impetus to move forward!

PositionEntity ballz,x#,y#,z# ; this puts the ball somewhere

If MeshesIntersect(ballz,plinkz)=True Then  ;New ball direction
	ang=ATan2(y#+90,x#+90)
		x#=2*Cos(ang)
		y#=2*Sin(ang)
EndIf


; ################################################################### KEY CONTROLS
If KeyHit(17) Then ; [W] for wireframe ON / OFF
	If w = 0 Then w = 1: Else w = 0
	If w=0 Then que$="OFF"
	If w=1 Then que$="ON"
	WireFrame w
EndIf


  UpdateWorld()
  RenderWorld()

	Text 10, 10 + (12 * 28), "Wireframe = " + que$


	
  Flip
Wend
End


And the link for all the B3D goodies is here:
http://www.silverimports.com/blitz/

I need some help!

-RZ

Well I know some of you out there have downloaded the b3D goodies... No one has any ideas either? I figure I am just not calling the TAN correctly... Now if I could just figure out the bounce as well...
-RZ

I haven't tried your code yet, but just a thought. ATan2 returns angles from -180 to 180 instead of 0 to 360. 0 points positive x, 180/-180 points negative x, 90 points positive y, -90 points negative y.

Well that could be it. I also may have to lay the board down FLAT instead of rotating it 20 degrees. Working towards a OXYD game idea.

-RZ