Help with linear lines

helpwithcode

#1

Hey guys. I'm making a project I think is pretty cool. And it should be easy. But it's not.

It is a linear calculator (oh yeah, I need a math-y person by the way). You adjust the coefficient and constant and it graphs the line. It seems easy enough because linear lines have very strict relationships...but it's obviously not working.

Here's the main stuff. The other stuff is minor like pressing the up arrow increases a value. Each block of 50 is acting as one unit to me.

It seems like it'd work, right? Is it because since the screen is (1024,764) it is distorting it? Or is it just my calculations are wrong? Anything would help! Thanks!


#2

Hi @CreativeCoder cool project! Your code looked fine to me but I realised just one thing you have to fix.

For the Set Position block inside the Leave a Trail, you need to multiply the Constant variable by 50, since 50 is your units.

Set Position to X=400 Y=(50*Constant) + (400*Coefficient)

The graph shouldn't distort it since you've made each square 50 units wide. Try that and let me know how it goes :smiley:


#3

Yay! That fixed it. I can't believe it was such a silly little thing like that :sweat_smile: Thanks!