2.2.7 Cycle 7 Randomised Terrain

Design

The aim of this cycle is to create a function which can create randomised terrain. The way I will do this is by generating random amplitudes for the terrain and using linear interpolation between the points to fill in the terrain. In the future I could possibly add a different method of interpolation which will appear much more smoother by using segments of a cosine wave.

Objectives

Key functions

Function Name
Use

Terrain object

For simplicity, all of the functions and variables to do with generating terrain have been placed into this object which is imported into the main code

seedTerrain

Generates random points along the screen for the basic structure of the terrain

tCollision

Spawns in objects to add collision to the terrain as drawings don't have collision

interpolateLinear

Linear interpolation between points of the terrain created by seedTerrain

Pseudocode

Development

Outcome

The outcome is a terrain which is randomly generated and rendered every time the game starts.

Challenges

The only challenge for this cycle is figuring where to start, so I did some research on randomised terrain generating and different sound algorithms and eventually decided to do a simple method which consists of generating different amplitudes at set intervals across the screen and using linear interpolation between the points.

Testing

Tests

Test
Instructions
What I expect
What actually happens
Pass/Fail

1

Run code

Kaboom should run

Kaboom ran normally

Pass

2

Enter "practice"

Terrain randomly generated and should be different each time the game is entered

Terrain works

Pass

Evidence

Some examples of randomly generated terrain

Last updated