Skip to content

Commit

Permalink
safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopson97 committed May 29, 2017
1 parent 55733dd commit e803ca5
Show file tree
Hide file tree
Showing 35 changed files with 95 additions and 152 deletions.
6 changes: 3 additions & 3 deletions Data/Blocks/Rose.block
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Style
1

Texture Top
10 0
9 0

Texture Side
10 0
9 0

Texture Bottom
10 0
9 0

15 changes: 0 additions & 15 deletions Data/Blocks/Snow.block

This file was deleted.

8 changes: 4 additions & 4 deletions Data/Blocks/Tall_Grass.block
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name
Tall Grass

ID
10

Expand All @@ -17,10 +17,10 @@ Style
1

Texture Top
11 0
10 0

Texture Side
11 0
10 0

Texture Bottom
11 0
10 0
4 changes: 2 additions & 2 deletions Data/Shaders/Liquid_Vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ uniform float timer;
vec4 getWorldPos()
{
vec3 inVert = inVertexPosition.xyz;
inVert.y += sin((timer + inVert.x) * 2.5) / 8.8f;
inVert.y += cos((timer + inVert.z) * 2.3) / 8.1f;
inVert.y += sin((timer + inVert.x) * 1.5) / 8.8f;
inVert.y += cos((timer + inVert.z) * 1.5) / 8.1f;
inVert.y -= 0.2;
return vec4(inVert, 1);
}
Expand Down
Binary file modified Data/Textures/Atlas/Low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions Data/WorldGen/Classic/Dense Forest.biome
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Surface
3

Flora
9
8
1

Flora
10
9
4

Tree
Expand Down
4 changes: 2 additions & 2 deletions Data/WorldGen/Classic/Forest.biome
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Surface
2

Flora
9
8
1

Flora
10
9
4

Tree
Expand Down
4 changes: 2 additions & 2 deletions Data/WorldGen/Classic/Grassland.biome
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Surface
1

Flora
9
8
1

Flora
10
9
4

Tree
Expand Down
4 changes: 2 additions & 2 deletions Data/WorldGen/Classic/Mountains.biome
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Surface
3

Flora
9
8
1

Flora
10
8
5

Tree
Expand Down
4 changes: 2 additions & 2 deletions Data/WorldGen/Classic/Ocean.biome
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Surface
2

Flora
9
8
1

Flora
10
9
5

Tree
Expand Down
4 changes: 0 additions & 4 deletions Data/WorldGen/Islands/Highland.biome
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ Surface

Flora
9
1

Flora
10
5

Tree
Expand Down
4 changes: 2 additions & 2 deletions Data/WorldGen/Islands/Land.biome
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Surface


Flora
9
8
1

Flora
10
9
10

Tree
Expand Down
4 changes: 2 additions & 2 deletions Data/WorldGen/Islands/Land2.biome
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Surface


Flora
9
8
1

Flora
10
9
10

Tree
Expand Down
4 changes: 0 additions & 4 deletions Data/WorldGen/Islands/Ocean.biome
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ Surface

Flora
9
1

Flora
10
5

Tree
Expand Down
1 change: 1 addition & 0 deletions Source/HUD/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Renderer
class Master;
}

///@TODO Right now this only works with floats. Needs to work with string, integer, etc
class Debug_HUD
{
struct Section
Expand Down
33 changes: 0 additions & 33 deletions Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
#include "Application.h"
#include "Display.h"

#include "World/Chunk/Section.h"


//#define TEST_NOISE

#ifdef __WIN32
#include <windows.h>

Expand Down Expand Up @@ -96,17 +91,6 @@ namespace
}


void logRun( const std::string& start,
const std::string& end,
const std::string& additionalInfo = "")
{
std::ofstream timeLogOutFile(start + ".txt");

timeLogOutFile << "Start: " << start << "\n"
<< "End: " << end << "\n"
<< "Additional info: " << additionalInfo << "\n";
}

void runGame()
{
initilize();
Expand All @@ -115,10 +99,6 @@ namespace
Application app;
app.runMainGameLoop();
}

std::time_t startTime;
std::time_t endTime;

}

/*
Expand All @@ -128,25 +108,12 @@ namespace
*/
int main() try
{
std::cout << sizeof(AABB) << "\n";
std::time(&startTime);
runGame();
std::time(&endTime);
/*
logRun( std::ctime(&startTime),
std::ctime(&endTime));
*/
return 0;
}
catch(std::exception& e)
{
std::time(&endTime);
errorMessage(std::string(e.what()));
/*
logRun( std::ctime(&startTime),
std::ctime(&endTime),
std::string(e.what()));
*/
}


2 changes: 1 addition & 1 deletion Source/Maths/Matrix_Maths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ namespace Maths
return glm::perspective(glm::radians(fieldOfView),
(float)Display::get().getSize().x/ (float)Display::get().getSize().y,
0.1f,
1500.0f);
1000.0f);
}
}
2 changes: 2 additions & 0 deletions Source/Physics/AABB.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct AABB
Vector3 getVN(const Vector3& normal) const;
Vector3 getVP(const Vector3& normal) const;

const Vector3& getDimensions() const { return m_dimensions; }

private:
Vector3 m_min;
Vector3 m_max;
Expand Down
47 changes: 25 additions & 22 deletions Source/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "../Maths/General_Maths.h"

Player::Player(Camera& camera)
: box ({0.5, 1.7, 0.5})
: box ({0.5, 1.5, 0.5})
, m_p_camera (&camera)
, m_flyModeToggle {sf::Keyboard::F, sf::seconds(0.3), m_isFlying}
, m_mouseLock {sf::Keyboard::L, sf::seconds(0.5)}
Expand Down Expand Up @@ -52,56 +52,59 @@ void Player::doCollisionTest(World& world, float dt)
}

position.x += m_velocity.x * dt;
collisionTest(world, dt, m_velocity.x, 0, 0);
collisionTest(world, {m_velocity.x, 0, 0}, dt);

position.y += m_velocity.y * dt;
collisionTest(world, dt, 0, m_velocity.y, 0);
collisionTest(world, {0, m_velocity.y, 0}, dt);

position.z += m_velocity.z * dt;
collisionTest(world, dt, 0, 0, m_velocity.z);
collisionTest(world, {0, 0, m_velocity.z}, dt);
}

void Player::collisionTest(World& world, float dt, float vx, float vy, float vz)
void Player::collisionTest(World& world,
const Vector3& velocity,
float dt)
{
float size = 0.5;
float height = 1.5;
const auto& dim = box.getDimensions();

for (int32_t x = position.x - size ; x < position.x + size ; x++)
for (int32_t y = position.y - height ; y < position.y + 0.7 ; y++)///@TODO Allow player
for (int32_t z = position.z - size ; z < position.z + size ; z++)///to enter 2 height hole
///@TODO Allow player
///to enter 2 height hole
for (int32_t x = position.x - dim.x ; x < position.x + dim.x ; x++)
for (int32_t y = position.y - dim.y ; y < position.y + 0.7 ; y++)
for (int32_t z = position.z - dim.z ; z < position.z + dim.z ; z++)
{
auto block = world.getBlock({x, y, z});

m_isInLiquid = (block.getData().state == Block::State::Liquid);

if (block.getData().isObstacle)
{
if (vx > 0)
if (velocity.x > 0)
{
position.x = x - size;
position.x = x - dim.x;
}
if (vx < 0)
if (velocity.x < 0)
{
position.x = x + size + 1;
position.x = x + dim.x + 1;
}
if (vy > 0)
if (velocity.y > 0)
{
position.y = y - height;
position.y = y - dim.y;
m_velocity.y = 0;
}
if (vy < 0)
if (velocity.y < 0)
{
position.y = y + height + 1;
position.y = y + dim.y + 1;
m_isOnGround = true;
m_velocity.y = 0;
}
if (vz > 0)
if (velocity.z > 0)
{
position.z = z - size;
position.z = z - dim.z;
}
if (vz < 0)
if (velocity.z < 0)
{
position.z = z + size + 1;
position.z = z + dim.z + 1;
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions Source/Player/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ class Player : public Entity

private:
void collisionTest (World& world,
float dt,
float vx,
float vy,
float vz);
const Vector3& velocity,
float dt);

void keyBoardInput ();
void mouseInput ();
Expand Down
2 changes: 0 additions & 2 deletions Source/World/Block/Block_Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ namespace Block

m_blocks[(int)ID::Water ] = std::make_unique<BWater> ();

m_blocks[(int)ID::Snow ] = std::make_unique<Default> ("Snow");

m_blocks[(int)ID::Rose ] = std::make_unique<BPlant> ("Rose");
m_blocks[(int)ID::Tall_Grass ] = std::make_unique<BPlant> ("Tall_Grass");
}
Expand Down
5 changes: 2 additions & 3 deletions Source/World/Block/Block_ID.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ namespace Block
Oak_Wood = 5,
Oak_Leaf = 6,
Water = 7,
Snow = 8,
Rose = 9,
Tall_Grass = 10,
Rose = 8,
Tall_Grass = 9,

NUM_BLOCK_TYPES
};
Expand Down
Loading

0 comments on commit e803ca5

Please sign in to comment.