0 Members and 1 Guest are viewing this topic.
... /************************ EVENTOS DE TECLADO ************************/ //TECLA PRESIONADA if (screen.GetInput().IsKeyDown(sf::Key::P) && key_pressed == false) { world.paused = world.paused?false:true; } if (last_event.Type == sf::Event::KeyPressed && key_pressed == false) { CPerson::STATE *char_state = &world.person->state; if(screen.GetInput().IsKeyDown(sf::Key::Space) && char_state->character != STATE_DOUBLEJUMP) { world.person->body->SetLinearVelocity(b2Vec2(world.person->body->GetLinearVelocity().x, 0)); if (char_state->character == STATE_GROUND) { char_state->character = STATE_JUMP; world.person->body->ApplyImpulse(b2Vec2(0,-50), world.person->pos); } else if (char_state->character == STATE_JUMP) { char_state->character = STATE_DOUBLEJUMP; world.person->body->ApplyImpulse(b2Vec2(0,-30), world.person->pos); } //playSound(SOUND_JUMP); } if((screen.GetInput().IsKeyDown(sf::Key::A) && world.person->body->GetLinearVelocity().x > 0.0f) || (screen.GetInput().IsKeyDown(sf::Key::D) && world.person->body->GetLinearVelocity().x < 0.0f)) world.person->body->SetLinearVelocity(b2Vec2(world.person->body->GetLinearVelocity().x/2, world.person->body->GetLinearVelocity().y)); key_pressed = true; } //TECLA SOLTADA if (last_event.Type == sf::Event::KeyReleased && key_pressed == true) key_pressed = false; } //Raton sf::Vector2f mousepos = screen.ConvertCoords(screen.GetInput().GetMouseX(), screen.GetInput().GetMouseY()); mouse.x = mousepos.x; mouse.y = mousepos.y; resources.sprt_cursor.SetPosition(mouse.x, mouse.y); //Movimientos del Personaje (TODO: Se tiene que mejorar la jugabilidad!) if(screen.GetInput().IsKeyDown(sf::Key::A)) { CPerson::STATE *char_state = &world.person->state; //Velocidad inicial Positiva if (world.person->body->GetLinearVelocity().x > -1.0f) { if (char_state->character == STATE_GROUND ) world.person->body->ApplyForce(b2Vec2(-70.0f, 0.0f), world.person->pos); else if (world.person->body->GetLinearVelocity().x > -6.0f) world.person->body->ApplyForce(b2Vec2(-30.0f, 0.0f), world.person->pos); } else { //Impulso if (world.person->state.character == STATE_GROUND) world.person->body->ApplyForce(b2Vec2(-150.0f, 0.0f), world.person->pos); else world.person->body->ApplyForce(b2Vec2(-10.0f, 0.0f), world.person->pos); } } if(screen.GetInput().IsKeyDown(sf::Key::D)) { CPerson::STATE *char_state = &world.person->state; //Velocidad inicial Positiva if (world.person->body->GetLinearVelocity().x < 1.0f) { if (char_state->character == STATE_GROUND) world.person->body->ApplyForce(b2Vec2(70.0f, 0.0f), world.person->pos); else if (world.person->body->GetLinearVelocity().x < 6.0f) world.person->body->ApplyForce(b2Vec2(30.0f, 0.0f), world.person->pos); } else { //Impulso if (world.person->state.character == STATE_GROUND) world.person->body->ApplyForce(b2Vec2(150.0f, 0.0f), world.person->pos); else world.person->body->ApplyForce(b2Vec2(10.0f, 0.0f), world.person->pos); } }...