Class: Terrain

Terrain(width, minHeight, maxHeight, noiseDetail)

Class Terrain describes the terrain object that represents the ground. This is passed into the game engine and can be damaged by projectiles.

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
Source:
Throws:
param pos should be instance of p5.Vector
Type
Error

draw()

Draw the ground using the desired method
Source:

drawRect()

Draw equal rectangles to represent the ground. This creates a retro appearance which is desirable and is performance friendly.
Source:

drawTriangleStrip()

Draw triangular strips for the ground. This creates a smoother appearance than rectangles but is more computationally intensive.
Source:

Documentation generated by JSDoc 4.0.2 on Wed Oct 29 2025 23:51:02 GMT-0700 (Pacific Daylight Time)