# Three maths questions - I found these, can someone please explain what they mean?

in layman's terms if you can. Thanks for the help.

clamp(self.Strength+100*dt,0,100)(sort of get it)

xHand-cos(a)*arrow.str/10 (no idea how this works)

yHand+sin(a)*distPivot (no clue, whats the a?)

• sin and cos are trigonometric functions, used for angles

clamp is a function to compare a value to two thresholds.. in your case you will get 0 if your strength is under 0 or get 100 if you are over 100. in between you will get your strength... times 100.. sort of.

it is not possible for us to guess what self and a are in your particular case

• self.strength means there is a local variable on that object used there.

for example if you have a sprite named char you don't have to create global variables to keep track of his life damage or strength

you can use a local variable on the sprite itself and give it a value, then u can use those values by using an action or condition like

sprite.hero is self life =< 100

and

sprite.hero on collision with refill health item

then do action sprite.hero set self life to self.life+healthitem.liferefil value

that is the formula of image points used in this case to set the position of an object to a pivot point

formula for image points

thanks to newt on this one he recently posted in general

xhand is a global variable with the X coordinate of the characters hand in this case or a point position near the hand of the character.

is cosinus from

where

should be equal to

(i don't know where you get the angle value on this one though in your current case)

yhand is the global variable with y coordinate of the characters hand as with x hand

sinus from

where

again is the angle set and used in the x positioning also

arrow.str -local variable str on arrow object, is the strength or in the image point formula that is a distance value.

distPivot global variable that holds the distance of from or to a pivot point, this should be set somewhere in the code or already has it set by default in the global variables list.

this sets the position of the arrow when the bow is shooting basically. going back and forth nice little trick to animate a movement of an arrow before it flies off from the bow.

sets the power /speed at which the arrow will travel at probably, by comparing if strengths value which is probably set while keeping pressed down a button or the touch on screen. it also influences the X position on the xhand-cos(a)*arrow.str/10

xHand-cos(a)*arrow.str/10

I've been reading maths, but this still makes no sense. So cosine {sohcahtoa) is the adjecent / hypontinuse of a triangle.

So hand = position

— the cos angle (a is a global angle)

Multiply by the arrow strength divide by 10

Hand angle is set to a minus cos angle (I don't get what this cos angle is) then it's aimed when the arrow is equal to a certain strength?

My brain man, seriously maths formulas....

xHand-cos(a)*arrow.str/10

that is translated as this from the image point formula above

x = centerX + cos(angle) * distance

arrow.str/10 ( the value of arrow.str is probably to high and requires reduction) basically is a Live distance that is continuously changing while keeping touch down or some key of sorts or when a condition is met.

here is a website explaining the sin,cos and tan

this one website calculates ur cos values choose degree sign for angle

cos(a)*arrow.str/10 it will give u a value which is basically moving the arrow in this case backwards before it gets released as its subtracted from xhand.

cos(angle) it will return a value from 0 to like 100 or -100 or 200 even depending on the angle value. if the angle is somewhere around 45 degrees the angle value that would mean that cos(a) would be somewhere around 0.7 or so... so if u multiply 0.7 with 100/10 lets say that is 10 0.7*10 that is about 7 ... meaning xhand - 7 in the end... but remember that strength always changes, so it might be 7 the max value but the smallest where it begins drawing might be 1 or 0. as str can be anywhere from 0 to 100 /10.

I'm bad at math also don't worry.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Thank you Corp, always appreciate your detailed answers. I don't think you can explain that any better. I semi understand it.

I'm off to the library to get a maths book. High-school level. I think maths is going to be super important.

I'm glad I have found my passion in life, but constantly getting stuck is not productive.

Hopefully in a couple of months I can master sin, cos, tan and other wee things.

Cheers dude

• I'm off to the library to get a maths book. High-school level. I think maths is going to be super important.

I'm glad I have found my passion in life, but constantly getting stuck is not productive.

Maths is super important in programming, the networking part requires even more maths, but usual stuff we usually use in C2 and C3 for small games not complex stuff requires atleast basic maths... (which u know i tend to fail also).. so is normal to get stuck is being human, we can't do it all is impossible, unless u give it a long time period.

If you found your passion in making games that makes u a tinkerer in my book ^_^ ud love anything that puts ur brain to work, most of us are like that.

Have a good one mate!