Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void updateTilemap() {
- float u, v, u2, v2;
- for (int i = 0; i < (64 * 64); i++) {
- u = (float)((tiles[i] % 16) * 16) / 256;
- v = (float)((tiles[i] / 16) * 16) / 256;
- u2 = (float)(((tiles[i] % 16) * 16) + 16) / 256;
- v2 = (float)(((tiles[i] / 16) * 16) + 16) / 256;
- if (switchBlockActivated) {
- if (tiles[i] == 9) {
- u = (float)((10 % 16) * 16) / 256;
- v = (float)((10 / 16) * 16) / 256;
- u2 = (float)(((10 % 16) * 16) + 16) / 256;
- v2 = (float)(((10 / 16) * 16) + 16) / 256;
- } else if (tiles[i] == 10) {
- u = (float)((9 % 16) * 16) / 256;
- v = (float)((9 / 16) * 16) / 256;
- u2 = (float)(((9 % 16) * 16) + 16) / 256;
- v2 = (float)(((9 / 16) * 16) + 16) / 256;
- } else if (tiles[i] == 7) {
- u = (float)((8 % 16) * 16) / 256;
- v = (float)((8 / 16) * 16) / 256;
- u2 = (float)(((8 % 16) * 16) + 16) / 256;
- v2 = (float)(((8 / 16) * 16) + 16) / 256;
- }
- }
- bgVertices[i * 24] = (float)(i % 64);
- bgVertices[(i * 24) + 1] = (float)((i / 64) + 1);
- bgVertices[(i * 24) + 2] = u;
- bgVertices[(i * 24) + 3] = v2;
- bgVertices[(i * 24) + 4] = (float)((i % 64) + 1);
- bgVertices[(i * 24) + 5] = (float)(i / 64);
- bgVertices[(i * 24) + 6] = u2;
- bgVertices[(i * 24) + 7] = v;
- bgVertices[(i * 24) + 8] = (float)(i % 64);
- bgVertices[(i * 24) + 9] = (float)(i / 64);
- bgVertices[(i * 24) + 10] = u;
- bgVertices[(i * 24) + 11] = v;
- bgVertices[(i * 24) + 12] = (float)(i % 64);
- bgVertices[(i * 24) + 13] = (float)((i / 64) + 1);
- bgVertices[(i * 24) + 14] = u;
- bgVertices[(i * 24) + 15] = v2;
- bgVertices[(i * 24) + 16] = (float)((i % 64) + 1);
- bgVertices[(i * 24) + 17] = (float)((i / 64) + 1);
- bgVertices[(i * 24) + 18] = u2;
- bgVertices[(i * 24) + 19] = v2;
- bgVertices[(i * 24) + 20] = (float)((i % 64) + 1);
- bgVertices[(i * 24) + 21] = (float)(i / 64);
- bgVertices[(i * 24) + 22] = u2;
- bgVertices[(i * 24) + 23] = v;
- }
- glBindVertexArray(bgVAO);
- glBindBuffer(GL_ARRAY_BUFFER, bgVBO);
- glBufferData(GL_ARRAY_BUFFER, sizeof(bgVertices), bgVertices, GL_DYNAMIC_DRAW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement