Le bonhomme n'a plus la maladie de Parkinson, et le jeu refonctionne sur MSVC++.
This commit is contained in:
parent
bb62651c62
commit
cee946028a
@ -68,13 +68,13 @@
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
|
@ -96,7 +96,7 @@ void Engine::Init()
|
||||
// for (int x = 0; x < CHUNK_SIZE_X; ++x)
|
||||
// for (int z = 0; z < CHUNK_SIZE_Z; ++z)
|
||||
// for (int y = 0; y < 32; ++y)
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(x, y, z, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(x, y, z, ((chx + chy) % (BTYPE_LAST - 1)) + 1);
|
||||
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(5, 32, 15, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(5, 33, 15, BTYPE_GRASS);
|
||||
@ -126,8 +126,6 @@ void Engine::Init()
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(14, 34, 5, BTYPE_GRASS);
|
||||
// m_world.GetChunks().Get(chx, chy)->SetBlock(14, 35, 5, BTYPE_GRASS);
|
||||
|
||||
// //m_world.GetChunks().Get(chx, chy)->SetBlock(8, chx + 32, 8, BTYPE_DIRT);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
@ -302,6 +300,8 @@ void Engine::Render(float elapsedTime) {
|
||||
if (m_wireframe)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
|
||||
if (m_player.GetPosition().y < -10.f) m_player = Player(Vector3f(64, 64, 64));
|
||||
}
|
||||
|
||||
void Engine::KeyPressEvent(unsigned char key)
|
||||
|
@ -30,11 +30,12 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
|
||||
-sin(m_rotX / 57.2957795056f),
|
||||
sin(m_rotY / 57.2957795056f) * cos(m_rotX / 57.2957795056f));
|
||||
|
||||
if (m_airborne && !jump) m_airborne = false; // Anti-rebondissement du saut, pour pouvoir rebondir.
|
||||
//if (m_airborne && !jump) m_airborne = false; // Anti-rebondissement du saut, pour pouvoir rebondir.
|
||||
|
||||
if ((jump || dash) && !m_airborne) {
|
||||
delta.y += jump ? m_jumpforce : 0.01f;
|
||||
m_airborne = true;
|
||||
//m_jumped = true;
|
||||
m_dbljump++;
|
||||
}
|
||||
|
||||
@ -201,7 +202,7 @@ void Player::ApplyPhysics(Vector3f input, World world, float elapsedTime) {
|
||||
if (!m_airborne) m_position.y = (int)m_position.y + .7f;
|
||||
m_airborne = false;
|
||||
}
|
||||
else {
|
||||
else if (m_airborne) {
|
||||
if (abs(m_velocity.y) < 1.1f) m_velocity.y += input.y - 1.1f * elapsedTime;
|
||||
m_airborne = true;
|
||||
}
|
||||
@ -223,14 +224,13 @@ void Player::ApplyPhysics(Vector3f input, World world, float elapsedTime) {
|
||||
/* Fin gestion de collisions */
|
||||
|
||||
m_position += input;
|
||||
m_POV = input;
|
||||
m_position.y += m_velocity.y;
|
||||
if (m_airborne) m_position.y += m_velocity.y;
|
||||
|
||||
//static float bobbingtime = 0; // Gestion de la caméra
|
||||
//if (bobbingtime <= 360.f) bobbingtime += elapsedTime * m_topspeed / 2; else bobbingtime = 0;
|
||||
//m_POV.x = m_position.x;
|
||||
//m_POV.z = m_position.z;
|
||||
//m_POV.y = m_position.y - 1.7f + m_airborne ? 0 : ((sin(bobbingtime) - 0.5f) * (abs(m_velocity.x * 40) + abs(m_velocity.z * 40)) / (10.f * m_topspeed));
|
||||
static float bobbingtime = 0; // Gestion de la caméra
|
||||
if (bobbingtime <= 360.f) bobbingtime += elapsedTime * m_topspeed / 2; else bobbingtime = 0;
|
||||
m_POV.x = m_position.x;
|
||||
m_POV.z = m_position.z;
|
||||
m_POV.y = m_position.y - 1.7f + m_airborne ? 0 : ((sin(bobbingtime) - 0.5f) * (abs(m_velocity.x * 40) + abs(m_velocity.z * 40)) / (10.f * m_topspeed));
|
||||
}
|
||||
|
||||
void Player::ApplyTransformation(Transformation& transformation, bool rel) const {
|
||||
|
@ -31,6 +31,7 @@ private:
|
||||
float m_jumpforce = 0.3f;
|
||||
|
||||
bool m_airborne;
|
||||
bool m_jumped;
|
||||
int m_dbljump; // Peut sauter ou dasher tant que la variable est en dessous de 2.
|
||||
};
|
||||
#endif //_PLAYER_H__
|
||||
|
@ -5,3 +5,34 @@ World::World(){}
|
||||
World::~World(){}
|
||||
|
||||
Array2d<Chunk*>& World::GetChunks() { return m_chunks; }
|
||||
|
||||
Chunk* World::ChunkAt(float x, float y, float z) const {
|
||||
int cx = (int)x / CHUNK_SIZE_X;
|
||||
int cz = (int)z / CHUNK_SIZE_Z;
|
||||
|
||||
if (cx >= VIEW_DISTANCE || // L'array en ce moment est de VIEW_DISTANCE par VIEW_DISTANCE.
|
||||
cz >= VIEW_DISTANCE ||
|
||||
cx < 0 || cz < 0)
|
||||
return 0;
|
||||
|
||||
return m_chunks.Get(cx, cz);
|
||||
}
|
||||
|
||||
Chunk* World::ChunkAt(const Vector3f& pos) const { return ChunkAt(pos.x, pos.y, pos.z); }
|
||||
|
||||
BlockType World::BlockAt(float x, float y, float z, BlockType defaultBlockType) const {
|
||||
Chunk* c = ChunkAt(x, y, z);
|
||||
|
||||
if (!c)
|
||||
return defaultBlockType;
|
||||
|
||||
int bx = (int)x % CHUNK_SIZE_X;
|
||||
int by = (int)y % CHUNK_SIZE_Y;
|
||||
int bz = (int)z % CHUNK_SIZE_Z;
|
||||
|
||||
return c->GetBlock(bx, by, bz);
|
||||
}
|
||||
|
||||
BlockType World::BlockAt(const Vector3f& pos, BlockType defaultBlockType) const {
|
||||
return BlockAt(pos.x, pos.y, pos.z, defaultBlockType);
|
||||
}
|
||||
|
@ -13,45 +13,53 @@ class World {
|
||||
|
||||
Array2d<Chunk*>& GetChunks();
|
||||
|
||||
template <class T>
|
||||
Chunk* World::ChunkAt(T x, T y, T z) const {
|
||||
int cx = (int)x / CHUNK_SIZE_X;
|
||||
int cz = (int)z / CHUNK_SIZE_Z;
|
||||
|
||||
if (cx >= VIEW_DISTANCE || // L'array en ce moment est de VIEW_DISTANCE par VIEW_DISTANCE.
|
||||
cz >= VIEW_DISTANCE ||
|
||||
cx < 0 || cz < 0)
|
||||
return 0;
|
||||
Chunk* ChunkAt(float x, float y, float z) const;
|
||||
Chunk* ChunkAt(const Vector3f& pos) const;
|
||||
|
||||
return m_chunks.Get(cx, cz);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Chunk* World::ChunkAt(const Vector3<T>& pos) const { return ChunkAt(pos.x, pos.y, pos.z); }
|
||||
|
||||
template <class T>
|
||||
BlockType World::BlockAt(T x, T y, T z, BlockType defaultBlockType = BTYPE_AIR) const {
|
||||
Chunk* c = ChunkAt(x, y, z);
|
||||
|
||||
if (!c)
|
||||
return defaultBlockType;
|
||||
|
||||
int bx = (int)x % CHUNK_SIZE_X;
|
||||
int by = (int)y % CHUNK_SIZE_Y;
|
||||
int bz = (int)z % CHUNK_SIZE_Z;
|
||||
|
||||
return c->GetBlock(bx, by, bz);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
BlockType World::BlockAt(Vector3<T>& pos, BlockType defaultBlockType = BTYPE_AIR) const {
|
||||
return BlockAt(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||
|
||||
private:
|
||||
Array2d<Chunk*> m_chunks = Array2d<Chunk*>(VIEW_DISTANCE, VIEW_DISTANCE);
|
||||
|
||||
int m_center[2] = {0, 0};
|
||||
};
|
||||
//
|
||||
//template <class T>
|
||||
//Chunk* World::ChunkAt(T x, T y, T z) const {
|
||||
// int cx = (int)x / CHUNK_SIZE_X;
|
||||
// int cz = (int)z / CHUNK_SIZE_Z;
|
||||
//
|
||||
// if (cx >= VIEW_DISTANCE || // L'array en ce moment est de VIEW_DISTANCE par VIEW_DISTANCE.
|
||||
// cz >= VIEW_DISTANCE ||
|
||||
// cx < 0 || cz < 0)
|
||||
// return 0;
|
||||
//
|
||||
// return m_chunks.Get(cx, cz);
|
||||
//}
|
||||
//
|
||||
//template <class T>
|
||||
//Chunk* World::ChunkAt(const Vector3<T>& pos) const { return ChunkAt(pos.x, pos.y, pos.z); }
|
||||
//
|
||||
//template <class T>
|
||||
//BlockType World::BlockAt(T x, T y, T z, BlockType defaultBlockType) const {
|
||||
// Chunk* c = ChunkAt(x, y, z);
|
||||
//
|
||||
// if (!c)
|
||||
// return defaultBlockType;
|
||||
//
|
||||
// int bx = (int)x % CHUNK_SIZE_X;
|
||||
// int by = (int)y % CHUNK_SIZE_Y;
|
||||
// int bz = (int)z % CHUNK_SIZE_Z;
|
||||
//
|
||||
// return c->GetBlock(bx, by, bz);
|
||||
//}
|
||||
//
|
||||
//template <class T>
|
||||
//BlockType World::BlockAt(const Vector3<T>& pos, BlockType defaultBlockType) const {
|
||||
// return BlockAt(pos.x, pos.y, pos.z);
|
||||
//}
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user