/************************************************************************************** INITIAL SETUP **************************************************************************************/ void initial_setup() { // Random seed srand(time(NULL)); // Loading my models and textures myModels.loadModels(); myModels.loadTextures(); // Creating shader program texLightProgramID = readAndCompileShader("Shaders/texture_light_vs.txt", "Shaders/texture_light_fs.txt"); // Loading font and creating text labels assert(init_text_rendering("Fonts/freemono.png", "Fonts/freemono.meta", width, height)); score_txtLabel = add_text("Score: 0", -0.2, 0.8, 30.0f, 1.0f, 0.0f, 0.0f, 1.0f); speed_txtLabel = add_text("", -0.2, 0.9, 30.0f, 1.0f, 0.0f, 0.0f, 1.0f); // Setting View and Perspective matrices mat4 view_matrix = look_at(vec3(0.0f, 10.0f, -40.0f), vec3(0, 0, 0), vec3(0.0f, 1.0f, 0.0f)); mat4 persp_matrix = perspective(45.0, (float)width/(float)height, 0.1, 900.0); camera.setViewMatrix(&view_matrix); camera.setPerspMatrix(&persp_matrix); // Setting the hero hero = Hero(vec3(0.0f, 0.0f, 0.0f), hero_vao, hero_point_count, texLightProgramID, camera.getViewMatrix(), camera.getPerspMatrix()); hero.setSpeed(game_speed); hero.setTextureID(hero_tex, hero_texture_active); hero.setRadius(3.0f); hero.attachArm(hero_arm_vao, hero_arm_point_count); hero.attachArmTex(arm_tex, arm_texture_active); // Setting the floor game_floor = Object(vec3(0.0f, 0.0f, 0.0f), gameFloor_vao, gameFloor_point_count, texLightProgramID, camera.getViewMatrix(), camera.getPerspMatrix()); game_floor.setTextureID(gameFloor_tex, gameFloor_texture_active); // Setting Pine to be collected float x = rand()%200 - 100; float z = rand()%200 - 100; pine = Pine(vec3(x, 0.0f, z), gamePine_vao, gamePine_point_count, texLightProgramID, camera.getViewMatrix(), camera.getPerspMatrix()); pine.setRadius(4.0f); pine.setTextureID(pine_tex, pine_texture_active); pine.setBounce(GL_TRUE); // Creating the queue for(int i=0; i<WIN_CONDITION; i++) { pines_collected[i] = Pine(vec3(x, 0.0f, z), gamePine_vao, gamePine_point_count, texLightProgramID, camera.getViewMatrix(), camera.getPerspMatrix()); pines_collected[i].setRadius(4.0f); pines_collected[i].setTextureID(pine_tex, pine_texture_active); } // Creating the monster for(int i=0; i<NUMBER_OF_MONSTERS; i++) { x = rand()%200 - 100; z = rand()%200 - 100; monster[i] = Pine(vec3(x, -1.0f, z), monster_vao, monster_point_count, texLightProgramID, camera.getViewMatrix(), camera.getPerspMatrix()); monster[i].setRadius(5.0f); monster[i].setTextureID(monster_tex, monster_texture_active); monster[i].setSpeed(30.0f); monster[i].setTargetToFollow(NULL); monster[i].hitted = GL_TRUE; monster[i].isPine = GL_FALSE; } // Creating snow for(int i=0; i<NUMBER_PARTICLES; i++) { float x = rand()%400 - 200; float z = rand()%400 - 200; snow[i] = Particle(vec3(x, 30.0f, z), particle_vao, particle_point_count, texLightProgramID, camera.getViewMatrix(), camera.getPerspMatrix()); snow[i].setTextureID(particle_tex, particle_texture_active); snow[i].setMaxSpeed(20.0f); snow[i].setRespawn(2); } camera.setSpeedRotation(5.0f); camera.rotation360(); camera.initial_rotation = GL_TRUE; }