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:
function NewTerrain()
randomize timer() // Random seed
// Generate the terrain height points
ang# = rnd(360) : delta# = rnd(30)/10.0 : width = 0
for x = 0 to 640
if width = 0 then ang# = wrapvalue(ang# + delta#) else dec width
terrain(x) = (sin(ang#)*50)+280
width = rnd(4)
// by increasing the width number you will get a flatter landscape
// Sin makes the value into a degree
// Delta is important because it allows a SMALL CHANGE in angle, otherwise landscape would be flat
next x
// Generate an image from the height points
ink RGB(240,240,240), 0 // Snowy Color
create bitmap 1, 640, 480 // 640x480 image
for x = 0 to 640: line x, terrain(x), x, 480 : next x // Draw the hills
get image 2, 0, 0, 640, 480, 1 : delete bitmap 1 // Store the image
ink rgb(255, 255, 255), 0 // Reset drawing color
sprite 2, 0, 0, 2 // Draw the new terrain sprite
set sprite 2, 1, 0 // Turn on backsave
endfunction
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