bool setup() { win = new Engine::glfwWindow; DefaultGameStateManager *manager = new DefaultGameStateManager(win); win->setApplication(this); win->setState(manager); win->setup(); //AssetManager::setBasePath(""); scene = manager->sceneState->scene; scene->systemManager->addSystem(new PhysicsSubSystem()); scene->systemManager->addSystem(new GenericSubSystem()); scene->systemManager->addSystem(new Generic30fpsSubSystem()); scene->systemManager->addSystem(new Generic60fpsSubSystem()); scene->systemManager->addRenderSystem(new DefaultRenderSubSystem()); DebugRenderSubSystem *dr = new DebugRenderSubSystem(); scene->systemManager->addRenderSystem(dr); scene->setEffect(new PostProcessor(scene)); mainchar = addMainActor(scene); scene->addActor(addModel("Data/Model/mappa4.obj", vec3(-10, 0, -10), vec3(1.5))); scene->addActor(addModel("Data/Model/mappa5.obj", vec3(0), vec3(1.1))); scene->addActor(addAxis1()); // addLucy(scene); addParticleSystem(scene,new ParticleSystem(),vec3(10,0,20)); addParticleSystem(scene,new ParticleSystem1(),vec3(-20,0,20)); addSun(scene); loadScene(AssetManager::getBasePath() + "Data/Level/prova/", scene); loadScene(AssetManager::getBasePath() + "Data/Level/handmade/", scene); Debug("Setup done!\n\n\n\n\nPress F1 to switch to FreeCam\nPress F2 to spawn a light sphere\nPress F3 to get the position\n\n\n\nFor any question contact me at: [email protected]\n\n\n"); }
//Update plants void Gameboard::UpdatePlants() { //for each squarelist for (int i = 0; i < squaresList.size(); i++) { Plant* plant = squaresList.at(i).getPlant(); //if there is a plant if (plant != nullptr) { //if the plant is a Peashooter if (plant->getType() == "PEASHOOTER"){ //if there are zombies if (!zombiesList.empty()) //shoot ! addBullet(((PeaShooter*)plant)->shoot()); } //if the plant is a Sunplant if (plant->getType() == "SUNPLANT") { //add a sun addSun(((SunPlant*)plant)->produceSun()); } } } }
void display( void ) { glClear( GL_COLOR_BUFFER_BIT ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); switch(draw_mode){ case 1: //First half of red arch glLoadIdentity(); glPushMatrix(); //glTranslatef(0.0f, 0.0f, 0.0f); glColor3f(1.0f, 0.0f, 0.0f); drawLeftHalfArch(); drawRightHalfArch(); //now the flipped arch is added addSun(); break; case 2: //copy code from case 1 glLoadIdentity(); glPushMatrix(); glColor3f(1.0f, 0.0f, 0.0f); //drawLeftHalfArch(); glColor3f(1.0f, 1.0f, 0.0f); //drawRightHalfArch(); //now the flipped arch is added //HELEN'S ADDITION: Here I'm trying to see what we can do with translating and scaling. I can't figure out how to get the second arch to appear behind the first one, however. glColor3f(0.0f, 1.0f, 1.0f); glTranslatef(0.175f,0.05f,-0.5f); glScalef(0.85f, 0.85f, 0.f); drawLeftHalfArch(); drawRightHalfArch(); glPopMatrix(); glColor3f(1.0f, 0.0f, 0.0f); drawLeftHalfArch(); drawRightHalfArch(); addSun(); break; case 3: //copy code from case 1 glLoadIdentity(); glPushMatrix(); //glColor3f(1.0f, 0.0f, 0.0f); //drawLeftHalfArch(); //glColor3f(1.0f, 1.0f, 0.0f); //drawRightHalfArch(); //now the flipped arch is added //HELEN'S ADDITION: Here I'm trying to see what we can do with translating and scaling. I can't figure out how to get the second arch to appear behind the first one, however. glColor3f(0.0f, 1.0f, 0.0f); glTranslatef(0.35f,0.09f,-0.5f); glScalef(0.7f, 0.7f, 0.f); drawLeftHalfArch(); drawRightHalfArch(); glPopMatrix(); glPushMatrix(); glColor3f(0.0f, 1.0f, 1.0f); glTranslatef(0.175f,0.05f,-0.5f); glScalef(0.85f, 0.85f, 0.f); drawLeftHalfArch(); drawRightHalfArch(); glPopMatrix(); glColor3f(1.0f, 0.0f, 0.0f); drawLeftHalfArch(); drawRightHalfArch(); addSun(); break; // Draw a triangle /*glColor3f(0.f,0.f,1.f); glBegin(GL_TRIANGLES); glVertex3f(0.2f,0.1f,0.f); glVertex3f(0.4f,0.1f,0.f); glVertex3f(0.3f,0.2f,0.f); glEnd();*/ break; case 4:// Draw a quad glColor3f(1.f,1.f,0.f); glBegin(GL_QUADS); glVertex3f(0.6f,0.7f,0.f); glVertex3f(0.8f,0.7f,0.f); glVertex3f(0.8f,0.9f,0.f); glVertex3f(0.6f,0.9f,0.f); glEnd(); break; case 5:// Draw a polygon glColor3f(1.f,0.f,1.f); glBegin(GL_POLYGON); glVertex3f(0.6f,0.7f,0.f); glVertex3f(0.8f,0.9f,0.f); glVertex3f(0.9f,0.7f,0.f); glVertex3f(0.8f,0.8f,0.f); glVertex3f(0.6f,0.9f,0.f); glEnd(); break; case 6://triangle strip glLoadIdentity(); glBegin(GL_TRIANGLE_STRIP); glColor3f(1.f,0.f,0.f); glVertex2f(0.2f,0.2f); glColor3f(0.f,1.f,0.f); glVertex2f(0.2f,0.8f); glColor3f(0.f,0.f,1.f); glVertex2f(0.5f,0.2f); glColor3f(1.f,1.f,0.f); glVertex2f(0.5f,0.8f); glColor3f(0.f,1.f,1.f); glVertex2f(0.8f,0.2f); glColor3f(1.f,0.f,1.f); glVertex2f(0.8f,0.8f); glEnd(); break; case 7://use transforms glLineWidth(4.); glLoadIdentity(); //body glPushMatrix(); //push identity glTranslatef(0.5f,0.75f,0.f); glBegin(GL_LINES); glColor3f(1.f,1.f,1.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); //right arm glPushMatrix(); //push body transform glRotatef(35.f,0.f,0.f,1.f); glBegin(GL_LINES); glColor3f(1.f,0.f,0.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); //right forearm glPushMatrix(); //push right arm transform glTranslatef(0.f,-0.25f,0.f); glRotatef(-15.f,0.f,0.f,1.f); glBegin(GL_LINES); glColor3f(0.f,1.f,0.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); glPopMatrix(); //load right arm transform glPopMatrix(); //load body transform //left arm glPushMatrix(); //push body transform glRotatef(-35.f,0.f,0.f,1.f); glBegin(GL_LINES); glColor3f(1.f,0.f,0.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); //left forearm glPushMatrix(); //push left arm transform glTranslatef(0.f,-0.25f,0.f); glRotatef(15.f,0.f,0.f,1.f); glBegin(GL_LINES); glColor3f(0.f,1.f,0.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); glPopMatrix(); //load left arm transform glPopMatrix(); //load body transform //right leg glPushMatrix(); //push body transform glTranslatef(0.f,-0.25f,0.f); glRotatef(25.f,0.f,0.f,1.f); glBegin(GL_LINES); glColor3f(0.f,0.f,1.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); //right lower leg glPushMatrix(); //push right leg transform glTranslatef(0.f,-0.25f,0.f); glRotatef(-15.f,0.f,0.f,1.f); glBegin(GL_LINES); glColor3f(1.f,1.f,0.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); glPopMatrix(); //load right leg transform glPopMatrix(); //load body transform //left leg glPushMatrix(); //push body transform glTranslatef(0.f,-0.25f,0.f); glRotatef(-25.f,0.f,0.f,1.f); glBegin(GL_LINES); glColor3f(0.f,0.f,1.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); //left lower leg glPushMatrix(); //push left leg transform glTranslatef(0.f,-0.25f,0.f); glRotatef(15.f,0.f,0.f,1.f); glBegin(GL_LINES); glColor3f(1.f,1.f,0.f); glVertex3f(0.0f,0.0f,0.f); glVertex3f(0.0f,-0.25f,0.f); glEnd(); glPopMatrix(); //load left leg transform glPopMatrix(); //load body transform glBegin(GL_TRIANGLES); glColor3f(1.f,1.f,1.f); glVertex3f(-0.1f,0.f,0.f); glVertex3f(0.1f,0.f,0.f); glVertex3f(0.f,0.15f,0.f); glEnd(); break; } glutSwapBuffers(); }