private void generateLevel() {
        doors = new ArrayList<>();
        enemies = new ArrayList<>();
        collisionPosStart = new ArrayList<>();
        collisionPosEnd = new ArrayList<>();
        medKits = new ArrayList<>();

        ArrayList<Vertex> vertices = new ArrayList<>();
        ArrayList<Integer> indices = new ArrayList<>();

        for(int i = 0; i < level.getWidth(); i++){
            for(int j = 0; j < level.getHeight(); j++){
                if((level.getPixel(i, j) & 0xFFFFFF) == 0)
                    continue;

                float[] texCoords = calcTexCoords((level.getPixel(i, j) & 0x00FF00) >> 8);

                addSpecial((level.getPixel(i, j) & 0x0000FF), i, j);

                //Generate floor
                addFace(indices, vertices.size(), true);
                addVertices(vertices, i, j, 0, false, true, true, texCoords);

                //Generate ceiling
                addFace(indices, vertices.size(), false);
                addVertices(vertices, i, j, 1, false, true, true, texCoords);

                //Generate walls
                texCoords = calcTexCoords((level.getPixel(i, j) & 0xFF0000) >> 16);


                if((level.getPixel(i, j - 1) & 0xFFFFFF) == 0) {
                    collisionPosStart.add(new Vector2f(i * SPOT_WIDTH, j * SPOT_LENGTH));
                    collisionPosEnd.add(new Vector2f((i + 1) * SPOT_WIDTH, j * SPOT_LENGTH));
                    addFace(indices, vertices.size(), false);
                    addVertices(vertices, i, 0, j, true, false, true, texCoords);
                }
                if((level.getPixel(i, j + 1) & 0xFFFFFF) == 0) {
                    collisionPosStart.add(new Vector2f(i * SPOT_WIDTH, (j + 1) * SPOT_LENGTH));
                    collisionPosEnd.add(new Vector2f((i + 1) * SPOT_WIDTH, (j + 1) * SPOT_LENGTH));
                    addFace(indices, vertices.size(), true);
                    addVertices(vertices, i, 0, (j + 1), true, false, true, texCoords);
                }
                if((level.getPixel(i - 1, j) & 0xFFFFFF) == 0) {
                    collisionPosStart.add(new Vector2f(i * SPOT_WIDTH, j * SPOT_LENGTH));
                    collisionPosEnd.add(new Vector2f(i * SPOT_WIDTH, (j + 1) * SPOT_LENGTH));
                    addFace(indices, vertices.size(), true);
                    addVertices(vertices, 0, j, i, true, true, false, texCoords);
                }
                if((level.getPixel(i + 1, j) & 0xFFFFFF) == 0) {
                    collisionPosStart.add(new Vector2f((i + 1) * SPOT_WIDTH, j * SPOT_LENGTH));
                    collisionPosEnd.add(new Vector2f((i + 1)  * SPOT_WIDTH, (j + 1) * SPOT_LENGTH));
                    addFace(indices, vertices.size(), false);
                    addVertices(vertices, 0, j, (i + 1), true, true, false, texCoords);
                }
            }
        }

        Vertex[] vertArray = new Vertex[vertices.size()];
        Integer[] intArray = new Integer[indices.size()];

        vertices.toArray(vertArray);
        indices.toArray(intArray);

        mesh = new Mesh(vertArray, Util.toIntArray(intArray));
    }