- Timestamp:
- Aug 8, 2017, 2:38:57 AM (7 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 4046b51
- Parents:
- eeece4e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pong.cpp
reeece4e r363d5ff 96 96 97 97 GLfloat points_paddle[] = { 98 -1.0f, 1.0f, 0.0f,99 -1.0f, 0.7f, 0.0f,100 -0.9f, 0.7f, 0.0f,101 -1.0f, 1.0f, 0.0f,102 -0.9f, 0.7f, 0.0f,103 -0.9f, 1.0f, 0.0f,98 -1.0f, 0.15f, 0.0f, 99 -1.0f, -0.15f, 0.0f, 100 -0.9f, -0.15f, 0.0f, 101 -1.0f, 0.15f, 0.0f, 102 -0.9f, -0.15f, 0.0f, 103 -0.9f, 0.15f, 0.0f, 104 104 }; 105 105 … … 142 142 float speed = 1.0f; 143 143 float last_position = 0.0f; 144 float last_paddle_pos = 0.0f; 144 145 145 146 double previous_seconds = glfwGetTime(); … … 156 157 157 158 model[12] = 0.0f; 159 model[13] = last_paddle_pos; 158 160 glUniformMatrix4fv(location, 1, GL_FALSE, model); 159 161 … … 166 168 model[12] = last_position + speed*elapsed_seconds; 167 169 last_position = model[12]; 170 model[13] = 0.0f; 168 171 glUniformMatrix4fv(location, 1, GL_FALSE, model); 169 172 … … 179 182 if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_ESCAPE)) { 180 183 glfwSetWindowShouldClose(window, 1); 184 } 185 if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_UP)) { 186 last_paddle_pos += 1.0f * elapsed_seconds; 187 if (last_paddle_pos > 0.85f) { 188 last_paddle_pos = 0.85f; 189 } 190 } 191 if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_DOWN)) { 192 last_paddle_pos -= 1.0f * elapsed_seconds; 193 if (last_paddle_pos < -0.85f) { 194 last_paddle_pos = -0.85f; 195 } 181 196 } 182 197 }
Note:
See TracChangeset
for help on using the changeset viewer.