[GameState] Now using left mouse click to delete block.

This commit is contained in:
Quentin Bazin 2018-06-14 03:02:47 +02:00
parent dee8629160
commit 4c3fe96ca4
5 changed files with 13 additions and 37 deletions

5
TODO
View File

@ -11,10 +11,15 @@ TODO
◦ TODO: `Window` (depuis `ZeldaOOL`) ◦ TODO: `Window` (depuis `ZeldaOOL`)
◦ TODO: `Debug` / `Exception` (+ gestion dans le `main()`) ◦ TODO: `Debug` / `Exception` (+ gestion dans le `main()`)
◦ TODO: Input system (Mouse + Keyboard) ◦ TODO: Input system (Mouse + Keyboard)
• TODO: Catch SDLLoader exception
• TODO: Passer un clang-tidy sur le code • TODO: Passer un clang-tidy sur le code
• TODO: Découper les gros pâtés en sous-classes • TODO: Découper les gros pâtés en sous-classes
• TODO: Séparer le code client du code serveur • TODO: Séparer le code client du code serveur
# FixMe
• FIXME: Les blocs sont ciblables dans le vide depuis lextérieur du monde
# ToDoList # ToDoList
## Joueur ## Joueur

View File

@ -25,7 +25,7 @@ class World {
public: public:
World(); World();
void draw(Camera &camera, Shader &shader, const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix); void draw(Shader &shader, const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
Chunk *getChunk(int cx, int cz); Chunk *getChunk(int cx, int cz);
@ -36,9 +36,9 @@ class World {
static const u16 renderDistance = 8; static const u16 renderDistance = 8;
private: private:
const s32 m_width = 100; const s32 m_width = 20;
const s32 m_height = 1; // FIXME: Never used const s32 m_height = 1; // FIXME: Never used
const s32 m_depth = 100; const s32 m_depth = 20;
Texture m_texture; Texture m_texture;

View File

@ -35,32 +35,3 @@ void Application::init() {
m_stateStack.push<GameState>(); m_stateStack.push<GameState>();
} }
// void Application::handleEvents() {
// Mouse::reset();
//
// SDL_Event event;
// while(SDL_PollEvent(&event) != 0) {
// switch(event.type) {
// case SDL_QUIT:
// m_window.close();
// break;
// case SDL_KEYDOWN:
// if(event.key.keysym.sym == SDLK_ESCAPE) {
// m_window.close();
// }
// break;
// case SDL_MOUSEMOTION:
// // Mouse::update(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel);
// if(SCREEN_WIDTH / 2 != event.motion.x || SCREEN_HEIGHT / 2 != event.motion.y) {
// Camera::getInstance().turnH(event.motion.xrel * 0.06);
// Camera::getInstance().turnV(-event.motion.yrel * 0.06);
//
// SDL_WarpMouseInWindow(m_window.window(), SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
// }
// break;
// default:
// break;
// }
// }
// }

View File

@ -56,15 +56,15 @@ void GameState::onEvent(const SDL_Event &event) {
Mouse::resetToWindowCenter(); Mouse::resetToWindowCenter();
} }
} }
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) {
m_world.setBlock(m_selectedBlock.x, m_selectedBlock.y, m_selectedBlock.z, 0);
}
} }
void GameState::update() { void GameState::update() {
m_viewMatrix = m_camera.processInputs(); m_viewMatrix = m_camera.processInputs();
m_selectedBlock = findSelectedBlock(false); m_selectedBlock = findSelectedBlock(false);
if (Keyboard::isKeyPressedOnce(Keyboard::X)) {
m_world.setBlock(m_selectedBlock.x, m_selectedBlock.y, m_selectedBlock.z, 0);
}
} }
void GameState::draw() { void GameState::draw() {
@ -74,7 +74,7 @@ void GameState::draw() {
// m_skybox.draw(m_shader); // m_skybox.draw(m_shader);
m_world.draw(m_camera, m_shader, m_projectionMatrix, m_viewMatrix); m_world.draw(m_shader, m_projectionMatrix, m_viewMatrix);
drawSelectedBlock(); drawSelectedBlock();
drawCross(); drawCross();

View File

@ -41,7 +41,7 @@ World::World() {
} }
} }
void World::draw(Camera &camera, Shader &shader, const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) { void World::draw(Shader &shader, const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) {
float ud = 1000.0; float ud = 1000.0;
s32 ux = 0; s32 ux = 0;
s32 uz = 0; s32 uz = 0;