[GameState] Now using left mouse click to delete block.
This commit is contained in:
parent
dee8629160
commit
4c3fe96ca4
5
TODO
5
TODO
@ -11,10 +11,15 @@ TODO
|
||||
◦ TODO: `Window` (depuis `ZeldaOOL`)
|
||||
◦ TODO: `Debug` / `Exception` (+ gestion dans le `main()`)
|
||||
◦ TODO: Input system (Mouse + Keyboard)
|
||||
• TODO: Catch SDLLoader exception
|
||||
• TODO: Passer un clang-tidy sur le code
|
||||
• TODO: Découper les gros pâtés en sous-classes
|
||||
• TODO: Séparer le code client du code serveur
|
||||
|
||||
# FixMe
|
||||
|
||||
• FIXME: Les blocs sont ciblables dans le vide depuis l’extérieur du monde
|
||||
|
||||
# ToDoList
|
||||
|
||||
## Joueur
|
||||
|
@ -25,7 +25,7 @@ class World {
|
||||
public:
|
||||
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);
|
||||
|
||||
@ -36,9 +36,9 @@ class World {
|
||||
static const u16 renderDistance = 8;
|
||||
|
||||
private:
|
||||
const s32 m_width = 100;
|
||||
const s32 m_width = 20;
|
||||
const s32 m_height = 1; // FIXME: Never used
|
||||
const s32 m_depth = 100;
|
||||
const s32 m_depth = 20;
|
||||
|
||||
Texture m_texture;
|
||||
|
||||
|
@ -35,32 +35,3 @@ void Application::init() {
|
||||
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;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
@ -56,15 +56,15 @@ void GameState::onEvent(const SDL_Event &event) {
|
||||
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() {
|
||||
m_viewMatrix = m_camera.processInputs();
|
||||
|
||||
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() {
|
||||
@ -74,7 +74,7 @@ void GameState::draw() {
|
||||
|
||||
// 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();
|
||||
drawCross();
|
||||
|
@ -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;
|
||||
s32 ux = 0;
|
||||
s32 uz = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user