Hello fellow programmers, i have been having a strange problem recently, as the title suggests. I'm messing around with some pseudo-gravity (havent gotten around to adding in any sort of compensation for distance yet), and every time I try to use the sqrt() function (as is rather nessisary), DBC decides that im trying to use an array that I havent dementionalized yet. I've gone twice over my code, but havent had any breakthroughs yet. Any insights?
`object data
dim pnt#(2,2)
`object's initial x position
pnt#(1,1) = 1380
`object's initial y position
pnt#(2,1) = 1060
`object's initial x speed
pnt#(1,2) = 20
`object's initial y speed
pnt#(2,2) = 20
cls
do
`plot point
dot pnt#(1,1)/4,pnt#(2,1)/4
`*calculate acceleration from "gravity" seperate in x and y*
`Distance formula
if pnt#(1,1) - 1280 > 0 then a#=pnt#(1,1) - 1280
if pnt#(1,1) - 1280 < 0 then a#= -1*(pnt#(1,1) - 1280)
if pnt#(2,1) - 960 > 0 then b#=pnt#(2,1) - 960
if pnt#(2,1) - 960 < 0 then b#= -1*(pnt#(2,1) - 960)
w# = (a# ^ 2) + (b# ^ 2)
sqrt(w#) = z#
`Distance to acceleration. Think two similar triangles; one for the lines of velocity and one for the distances.
`With the distance formula we found the hypotenuce of the distance triangle. We already knew the hypotenuce of the acceleration triangle because it is the total
`acceleration, the origional acceleration from gravity that we are dividing up. Now that we have two corrisponding sides,
`this section is just the simple matter of using that ratio to find the last two missing sides of the acceleration triangle: the x and y acceleration
x# = (4 * a#) / z#
y# = (4 * b#) / z#
`add gravity acceleration to origional velocity
pnt#(1,2) = pnt#(1,2) + x#
pnt#(2,2) = pnt#(2,2) + y#
`add velocities to coordinates
pnt#(1,1) = pnt#(1,1) + pnt#(1,2)
pnt#(2,1) = pnt#(2,1) + pnt#(2,2)
loop
Everything is more than the sum of its parts.