5
#include "level_logic.hpp"
7
bool cliff_edge_within(const level& lvl, int xpos, int ypos, int deltax)
9
const int FeetWidth = 5;
10
return !lvl.standable(xpos + deltax, ypos) &&
11
!lvl.standable(xpos + deltax, ypos + std::abs(deltax) + FeetWidth);
14
int distance_to_cliff(const level& lvl, int xpos, int ypos, int facing)
16
const int max_search = 1000;
17
const int cliff_face = 5;
18
const int cliff_drop = 2;
22
//search for up to three pixels below us to try to get a starting
23
//position which is standable.
24
for(int n = 0; n != 3; ++n) {
25
if(lvl.standable_tile(xpos, ypos)) {
37
//make sure we are at the surface.
38
while(lvl.standable_tile(xpos, ypos-1)) {
43
for(; result < max_search; xpos += facing, ++result) {
44
if(lvl.standable_tile(xpos, ypos) || lvl.standable_tile(xpos, ypos-1)) {
46
while(lvl.standable_tile(xpos, ypos-1) && ydiff < cliff_face) {
51
if(ydiff == cliff_face) {
56
while(!lvl.standable_tile(xpos, ypos) && ydiff < cliff_drop) {
61
if(ydiff == cliff_drop) {
70
int find_ground_level(const level& lvl, int xpos, int ypos, int max_search)
72
if(lvl.standable(xpos, ypos)) {
74
while(lvl.standable(xpos, ypos) && --max_search > 0) {
84
//search both up and down, since in the case of a platform the
85
//ground may be above us.
86
for(int n = 1; n < max_search; ++n) {
87
if(lvl.standable(xpos, ypos + n)) {
91
if(lvl.standable(xpos, ypos - n) && !lvl.standable(xpos, ypos - n - 1)) {