From 318c7ad77f7071d1e8653600342a6f2ca2998ff2 Mon Sep 17 00:00:00 2001 From: Quentin Bazin Date: Sun, 21 Dec 2014 17:02:09 +0100 Subject: [PATCH] [README] Updated. --- README.textile | 20 ++++++++++++++++++++ include/gl/Camera.hpp | 5 ++++- include/world/Chunk.hpp | 3 ++- source/world/Chunk.cpp | 12 ++++++++---- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/README.textile b/README.textile index 7015d941..cbd516b3 100755 --- a/README.textile +++ b/README.textile @@ -3,3 +3,23 @@ h1. KubKraft h2. By Quentin Bazin (aka. Quent42340) * KubKraft is a Minecraft-like game. + +h2. Keys + +* View: mouse controlled +* Movement: @Z@, @Q@, @S@ and @D@ +* Land: @Shift@ +* Fly: @Space@ +* Exit: @Escape@ + +h2. How to compile (Linux and Mac OS-X only) + +* Required: @SDL@ (>= 2.0), @OpenGL@ (=> 2.1), @glm@ +* Run @make@ at the root of the game folder +* Run @make run@, and enjoy! + +h2. Note for Windows users + +* Windows requires @glew@ to compile +* The @Makefile@ is not yet compatible with Windows + diff --git a/include/gl/Camera.hpp b/include/gl/Camera.hpp index d770e3d3..cf4eada0 100644 --- a/include/gl/Camera.hpp +++ b/include/gl/Camera.hpp @@ -22,8 +22,11 @@ #include -#define RADIANS_PER_DEGREES 0.0174532925199 +#ifndef M_PI #define M_PI 3.14159265358979323846 +#endif + +#define RADIANS_PER_DEGREES 0.0174532925199 class Camera { public: diff --git a/include/world/Chunk.hpp b/include/world/Chunk.hpp index 049eeae0..bacb0932 100644 --- a/include/world/Chunk.hpp +++ b/include/world/Chunk.hpp @@ -37,7 +37,8 @@ class Chunk { u8 getBlock(s8 x, s8 y, s8 z); - s32 getVertexID(u8 x, u8 y, u8 z, u8 i, u8 j, u8 coordinate, u8 nbCoordinates = 3); + s32 getVertexID(u8 x, u8 y, u8 z, u8 i, u8 j, u8 coordinate); + s32 getTexCoordID(u8 x, u8 y, u8 z, u8 i, u8 j, u8 coordinate); static float noise2d(float x, float y, int seed, int octaves, float persistence); static float noise3d_abs(float x, float y, float z, int seed, int octaves, float persistence); diff --git a/source/world/Chunk.cpp b/source/world/Chunk.cpp index e82a722b..6a5c6901 100644 --- a/source/world/Chunk.cpp +++ b/source/world/Chunk.cpp @@ -180,8 +180,8 @@ void Chunk::update() { m_vertices[m_verticesID[getVertexID(x - 1, y, z, 5, 0, 0)]] += 1; m_vertices[m_verticesID[getVertexID(x - 1, y, z, 5, 1, 0)]] += 1; - m_texCoords[m_verticesID[getVertexID(x - 1, y, z, 5, 0, 0, 2)]] += 1; - m_texCoords[m_verticesID[getVertexID(x - 1, y, z, 5, 1, 0, 2)]] += 1; + m_texCoords[getTexCoordID(x - 1, y, z, 5, 0, 0)] += 1; + m_texCoords[getTexCoordID(x - 1, y, z, 5, 1, 0)] += 1; //m_texCoords[getTexCoordID(x - 1, y, z, 5, 0, 1, skipped)] += 1; //m_texCoords[getTexCoordID(x - 1, y, z, 5, 1, 1)] += 1; @@ -283,8 +283,12 @@ u8 Chunk::getBlock(s8 x, s8 y, s8 z) { } } -s32 Chunk::getVertexID(u8 x, u8 y, u8 z, u8 i, u8 j, u8 coordinate, u8 nbCoordinates) { - return (j + i * 4 + x * 4 * 6 + y * 4 * 6 * Chunk::width + z * 4 * 6 * Chunk::width * Chunk::height) * nbCoordinates + coordinate; +s32 Chunk::getVertexID(u8 x, u8 y, u8 z, u8 i, u8 j, u8 coordinate) { + return (j + i * 4 + x * 4 * 6 + y * 4 * 6 * Chunk::width + z * 4 * 6 * Chunk::width * Chunk::height) * 3 + coordinate; +} + +s32 Chunk::getTexCoordID(u8 x, u8 y, u8 z, u8 i, u8 j, u8 coordinate) { + return m_verticesID[getVertexID(x, y, z, i, j, coordinate)] - m_vertices.size() / 3; } float Chunk::noise2d(float x, float y, int seed, int octaves, float persistence) {