Hey all,
I've been making a BrickBreaker clone and I've got most of it done, just the fancy stuff left. One of these fancy things is the line showing the direction of where the ball is going to go when released from the paddle at the beginning of each level.
I've found this equation for finding the coordinates of any point on the circumference of a circle :
x=(a+r)*cos(t) : y=(b+r)*sin(t)
Except that when I've implemented that into my code, I got strange results(way off to the left or off the screen).
Here's the code I'm using currently(gets slope and y-intercept for linear equation of the current mouse position and draws a line from the paddle to the mouse point):
player.x=320
player.y=450
repeat
m_x=mousex()
m_y=mousey()
slope#=(m_y-player.y)/(m_x-player.x)
intercept#=(player.y-(slope#*player.x))
ypos=(m_x*slope#)+intercept#
xpos=m_x
if mouseclick()=1
direction_chosen=true
endif
DrawScreen()
ManageBoxes()
DrawPlayer(player.x,player.y)
set cursor 50,50
print slope#
set cursor 50,60
print player.x
set cursor 50,70
print intercept#
set cursor 50,80
print m_x
set cursor 50,90
print ypos
D3D_line player.x,player.y-10,xpos,ypos
sync
until direction_chosen=true
If anyone can help me, I'd greatly appreciate it.