diff --git a/Notes b/Notes index 6a0d6b51..410f002a 100755 --- a/Notes +++ b/Notes @@ -1,6 +1,3 @@ -Bugs: - It's possible to put a cube under yourself without jumping. - Cubes: 0: Nothing 1: Stone diff --git a/TODO b/TODO index 5753e508..54a615b8 100755 --- a/TODO +++ b/TODO @@ -1,4 +1,6 @@ -- Physics +- Physics: + - Improve jump and collisions. + - Improve game speed. - Caves - Pause menu - Main menu diff --git a/include/config.h b/include/config.h index 135ca20e..7be368a1 100644 --- a/include/config.h +++ b/include/config.h @@ -39,9 +39,9 @@ #define CUBE_POS(x, y, z) (((x) - m_x) + (((y) - m_y) * CHUNK_WIDTH) + (((z) - m_z) * CHUNK_WIDTH * CHUNK_HEIGHT)) #define PLAYER_HEIGHT 1.8 -#define MOVEMENT_SPEED 3.0 +#define MOVEMENT_SPEED 3.5 #define FLY_SPEED 0.05 -#define JUMP_SPEED 0.5 -#define GRAVITY 0.025 +#define JUMP_SPEED 0.15 +#define GRAVITY 0.00981 #endif // CONFIG_H diff --git a/source/map.cpp b/source/map.cpp index a791283f..fdae22e1 100644 --- a/source/map.cpp +++ b/source/map.cpp @@ -70,10 +70,10 @@ Map::Map(u16 width, u16 depth, u16 height) { for (int xC = 0; xC < CHUNK_WIDTH; xC++) { int x = xx * CHUNK_WIDTH + xC; int y = yy * CHUNK_DEPTH + yC; - float perlin = get2DPerlinNoiseValue(x, y, 64) * 0 // 3 - + get2DPerlinNoiseValue(x, y, 32) * 4 // 0 - + get2DPerlinNoiseValue(x, y, 16) * 3 // 0.5 - + get2DPerlinNoiseValue(x, y, 8) * 2; // 0.1 + float perlin = get2DPerlinNoiseValue(x, y, 64) * 3 // 3 - 0 + + get2DPerlinNoiseValue(x, y, 32) * 2 // 0 - 4 + + get2DPerlinNoiseValue(x, y, 16) * 2 // 0.5 - 3 + + get2DPerlinNoiseValue(x, y, 8) * 1; // 0.1 - 2 int heightValue = int((perlin * float(CHUNK_HEIGHT)) + float(m_height / 2)); if (heightValue < 0) heightValue = 0; diff --git a/source/mapManager.cpp b/source/mapManager.cpp index d0f50846..a6a0adf8 100644 --- a/source/mapManager.cpp +++ b/source/mapManager.cpp @@ -50,7 +50,14 @@ bool inTable(u16 t[], u16 n) { } bool passable(s16 caseX, s16 caseY, s16 caseZ) { - if(inTable(nonPassableTiles, Game::map->map()[MAP_POS(caseX, caseY, caseZ)])) { + // TOO SLOW + /*if(inTable(nonPassableTiles, Game::map->map()[MAP_POS(caseX, caseY, caseZ)])) { + return false; + } else { + return true; + }*/ + int cubeid = Game::map->map()[MAP_POS(caseX, caseY, caseZ)]; + if(cubeid == 1 || cubeid == 2) { return false; } else { return true; diff --git a/source/player.cpp b/source/player.cpp index 8d6be392..e9076883 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -37,7 +37,7 @@ Player::Player(float x, float y, float z, float angle) { m_x = x; m_y = y; - m_eyeheight = z + 0.1; + m_eyeheight = z + 0.8; m_angleH = angle; m_angleV = 0.0; @@ -63,31 +63,30 @@ void Player::move(float distance, float direction) { } void Player::jump() { - if(m_isJumping) { - m_eyeheight += m_jumpSpeed / 4; + if((m_isJumping) && + (passable(m_x, m_y, m_eyeheight + m_jumpSpeed + 0.5))) { + m_eyeheight += m_jumpSpeed; m_jumpSpeed -= GRAVITY; if((m_jumpSpeed < 0) && - ((!passable(m_x, m_y, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed / 4 - 0.1)) /* || - (!passable(m_x + 0.25, m_y, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed / 4 - 0.3)) || - (!passable(m_x, m_y + 0.25, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed / 4 - 0.3)) || - (!passable(m_x + 0.25, m_y + 0.25, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed / 4 - 0.3)) */ )) { + ((!passable(m_x, m_y, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed - 0.3)) /* || + (!passable(m_x + 0.25, m_y, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed - 0.1)) || + (!passable(m_x, m_y + 0.25, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed - 0.1)) || + (!passable(m_x + 0.25, m_y + 0.25, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed - 0.1)) */ )) { m_jumpSpeed = 0.0; m_isJumping = false; - return; } - - if((m_jumpSpeed >= 0) && - ((!passable(m_x, m_y, m_eyeheight + m_jumpSpeed / 4 + 0.5)) /* || - (!passable(m_x + 0.25, m_y, m_eyeheight + m_jumpSpeed / 4 + 0.3)) || - (!passable(m_x, m_y + 0.25, m_eyeheight + m_jumpSpeed / 4 + 0.3)) || - (!passable(m_x + 0.25, m_y + 0.25, m_eyeheight + m_jumpSpeed / 4 + 0.3)) */ )) { + else if((m_jumpSpeed >= 0) && + ((!passable(m_x, m_y, m_eyeheight + m_jumpSpeed + 0.5)) /* || + (!passable(m_x + 0.25, m_y, m_eyeheight + m_jumpSpeed + 0.5)) || + (!passable(m_x, m_y + 0.25, m_eyeheight + m_jumpSpeed + 0.5)) || + (!passable(m_x + 0.25, m_y + 0.25, m_eyeheight + m_jumpSpeed + 0.5)) */ )) { m_jumpSpeed = 0.0; } } - else if((passable(m_x, m_y, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed / 4 - 0.1)) && - (passable(m_x, m_y, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed / 4 - 0.1))) { + else if((passable(m_x, m_y, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed - 0.3)) /*&& + (passable(m_x, m_y, m_eyeheight - PLAYER_HEIGHT - m_jumpSpeed - 0.1))*/) { m_jumpSpeed = 0.0; m_isJumping = true; }