-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlevel.cpp
More file actions
24 lines (17 loc) · 716 Bytes
/
Copy pathlevel.cpp
File metadata and controls
24 lines (17 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "level.h"
void LEVEL::create() {
int divider;
image = create_bitmap(SCREEN_W, MAX_LEVELHEIGHT + 50); // the +50 adds room for gore to pile up
terrain = (BITMAP*)terrain_data[0].dat;
clear_to_color(image, makecol(255, 0, 255)); // Clear it to transparent pink
height[0] = 20 + rand() % (MAX_LEVELHEIGHT - 70);
draw_sprite(image, terrain, 0, MAX_LEVELHEIGHT - height[0]);
for (int i = 1; i < SCREEN_W; ++i) {
do {
divider = 1 + rand() % 8;
height[i] = height[i-1] + rand() % 2 - rand() % 2;
height[i] = height[i] + int(sin(rand()%SCREEN_W) / divider);
} while (height[i] > MAX_LEVELHEIGHT || height[i] < 10);
draw_sprite(image, terrain, i, MAX_LEVELHEIGHT - height[i]);
}
}