diff --git a/res/tex/texture.png b/res/tex/texture.png index 58c3ab2..9d6e08a 100644 Binary files a/res/tex/texture.png and b/res/tex/texture.png differ diff --git a/src/camera.c b/src/camera.c index 9a80666..3fcd885 100644 --- a/src/camera.c +++ b/src/camera.c @@ -3,8 +3,8 @@ void Camera_Init(Camera* c) { - c->position[0] = -50.0f; - c->position[1] = 130.0f; + c->position[0] = 5.0f; + c->position[1] = 0.0f; c->position[2] = 0.0f; c->width[0] = 0.6f; c->width[1] = 5.8f; diff --git a/src/game.c b/src/game.c index 554ebb2..58cb6f4 100644 --- a/src/game.c +++ b/src/game.c @@ -19,10 +19,13 @@ void Game_Update(GameState *gs) { vec3 move; glm_vec3_zero(move); - if (gs->input.w) move[0] = 0.3f; - else if (gs->input.s) move[0] = -0.3f; - if (gs->input.a) move[1] = 0.3f; - else if (gs->input.d) move[1] = -0.3f; + const float speed = 0.3f; + if (gs->input.w) move[0] = speed; + else if (gs->input.s) move[0] = -speed; + if (gs->input.a) move[1] = speed; + else if (gs->input.d) move[1] = -speed; + if (gs->input.q) move[2] = speed; + else if (gs->input.e) move[2] = -speed; glm_vec3_add(gs->camera.position, move, gs->camera.position); Camera_UpdateVectors(&gs->camera); diff --git a/src/game.h b/src/game.h index fb09d17..052c80d 100644 --- a/src/game.h +++ b/src/game.h @@ -12,6 +12,8 @@ typedef struct bool a; bool s; bool d; + bool q; + bool e; } InputState; typedef struct diff --git a/src/input.c b/src/input.c index 2dc003a..dad151b 100644 --- a/src/input.c +++ b/src/input.c @@ -27,6 +27,8 @@ static void HandleKeyDown(GameState *gs, SDL_KeyCode sym) case SDLK_a: gs->input.a = true; break; case SDLK_s: gs->input.s = true; break; case SDLK_d: gs->input.d = true; break; + case SDLK_q: gs->input.q = true; break; + case SDLK_e: gs->input.e = true; break; } } @@ -38,6 +40,8 @@ static void HandleKeyUp(GameState *gs, SDL_KeyCode sym) case SDLK_a: gs->input.a = false; break; case SDLK_s: gs->input.s = false; break; case SDLK_d: gs->input.d = false; break; + case SDLK_q: gs->input.q = false; break; + case SDLK_e: gs->input.e = false; break; } } diff --git a/src/render.c b/src/render.c index 387c7c5..d20a92c 100644 --- a/src/render.c +++ b/src/render.c @@ -217,7 +217,7 @@ bool Render_Init(GameState *gs) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); - gs->window = SDL_CreateWindow("Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1920, 1080, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);; + gs->window = SDL_CreateWindow("Sandbox", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1920, 1080, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);; gs->glContext = SDL_GL_CreateContext(gs->window); printf("Created OpenGL window.\n"); @@ -236,7 +236,7 @@ bool Render_Init(GameState *gs) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); printf("Initialized OpenGL.\n"); - Shape *shape = Shape_MakePyramid(3); + Shape *shape = Shape_MakePyramid(5); gs->testShape = shape; glGenVertexArrays(1, &shape->VAO); glGenBuffers(1, &shape->VBO); diff --git a/src/shape.c b/src/shape.c index 5c93668..170b9ef 100644 --- a/src/shape.c +++ b/src/shape.c @@ -62,15 +62,15 @@ Shape *Shape_MakePyramid(int numInstances) for (int i = 0; i < numInstances; i++) { ShapeInstance *instance = shape->instances + i; - instance->position[0] = -4.0f; instance->position[0] = 0.0f; - instance->position[0] = (5.0f * i) - 2.0f; + instance->position[0] = 0.0f; + instance->position[0] = (5.0f * i) - 10.0; instance->scale = 1.0f; instance->collisionRadius = 1.0f; glm_vec3_zero(instance->velocity); glm_vec3_zero(instance->rotation); float *textureId = shape->instanceData + (i * 17); - *textureId = 0; + *textureId = i; mat4 *matrix = (void*)(textureId + 1); }