angle and speed

Blitz3D Forums/Blitz3D Beginners Area/angle and speed

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.

Easiest way quite frankly is not worry about speed and angle.

Use Xspeed and Yspeed

When the ball hits the bat may yspeed = -yspeed, and adjust the xspeed depending on where on the bat the ball hits.

Graphics 400,300,0,2

x#=200
y#=150
xd#=Rnd(-2,2)
yd#=Rnd(-2,2)

SetBuffer BackBuffer()

Repeat

	; draw screen
	Cls
	Text x,y,"O",True,True
	
	; update location
	x=x+xd
	y=y+yd
	
	; bounce of sides
	If x<0 Then xd=-xd
	If x>400 Then xd=-xd
	If y<0 Then yd=-yd
	If y>300 Then yd=-yd
	Flip

Until KeyHit(1)