Constructor
new Terrain(width, minHeight, maxHeight, noiseDetail)
constructor of the terrain
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
width |
number | the width of the screen | |
minHeight |
number | the minimum height of the ground in screen coordinates | |
maxHeight |
number | the maximum height of the ground in screen coordinates | |
noiseDetail |
number | 1 | used to scale the period of the perlin noise |
- Source:
- See:
Methods
addCrater(pos, radius)
Function to add a crater in the ground where an explosion occurred.
Parameters:
| Name | Type | Description |
|---|---|---|
pos |
p5.Vector | position of the explosion |
radius |
number | radius of the explosion |
Throws:
-
param pos should be instance of p5.Vector
- Type
- Error
draw()
Draw the ground using the desired method
drawRect()
Draw equal rectangles to represent the ground. This creates a retro
appearance which is desirable and is performance friendly.
drawTriangleStrip()
Draw triangular strips for the ground. This creates a smoother appearance
than rectangles but is more computationally intensive.