Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Sin Value Help Needed

Author
Message
soysauce
15
Years of Service
User Offline
Joined: 8th Sep 2009
Location: At my computer coding
Posted: 6th Dec 2009 03:47 Edited at: 6th Dec 2009 03:56
Let me start about by saying this: I am only half way through my algebra course (1 semester completed).
Therefore I am unaware of Sine values and how they work. I have read the help files and I still don't understand. I am working with the following code:


This part of the code just racks my brain, "terrain(x) = (sin(ang#)*50)+280"... I can't understand how this comes up with a number! How does Sin get calculated from ang#? What does multiplying it by 50 actually do? The reason I want to know is so I can manipulate this code to actually make a map with my WANTED SLOPE, rather than just random numbers (which are completely useless in making a real map!)
Oh and one more question, why does it get a changed "terrain(x)" every time the for/next statement is run? Is this what Randomize timer() does? because the "ang# = rnd(360)" is never restated so that must be it, right? Please give as much information as possible, and examples would be great, because I've been working on this for hours and I'm so lost... THANKS

Proud owner of Dark Game Studio
Visigoth
20
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 6th Dec 2009 08:26
sin (or sine) is actually a trigonometry function. For every angle, the sine of that angle will be represented by a real number between -1 and + 1. To understand sine, you have to understand a little trig. I learned about it here:
http://www.clarku.edu/~djoyce/trig/

usually, you would use sine to calculate the x value of a coordinate and cosine for the y value. Since sine and cosine only return a real number between -1 and 1, you have to multiply by some scale value if you are working with numbers larger than 1.
So, say you have a height value for a terrain, you could use sine to generate a wave to create those values. IF say 100 is the highest height, you would multiply all values returned from sine by 100 to get a percentage of the highest height. Once you understand the sine function, you'll find all kinds of uses for it. Good luck.

Login to post a reply

Server time is: 2025-05-28 04:38:13
Your offset time is: 2025-05-28 04:38:13