//! Starts a special MD2 animation. bool CAnimatedMeshSceneNode::setMD2Animation(const c8* animationName) { if (!Mesh || Mesh->getMeshType() != EAMT_MD2) return false; IAnimatedMeshMD2* m = (IAnimatedMeshMD2*)Mesh; s32 begin, end, speed; if (!m->getFrameLoop(animationName, begin, end, speed)) return false; setAnimationSpeed( (f32)speed ); setFrameLoop(begin, end); return true; }
Chest::Chest(double x, double y) : PhysicsSprite("images/spr_chest.png") { setPosition(x,y); //animations: // 0 - open // 1 - locked // 2 - opening // ANIMATION SETUP // setNumberOfAnimations(3); setSpriteFrameSize(64, 64); //Chest Opening addSpriteAnimRow(2, 0, 0, 64, 0, 7); setAnimationSpeed(0, 0.25); //Chest Locked addSpriteAnimRow(0, 0, 0, 64, 0, 2); setAnimationSpeed(0, 0.25); //Chest Opened addSpriteAnimRow(1, 0, 0, 64, 0, 1); setAnimationSpeed(0, 0.25); setCurrentAnimation(0); // PHYSICAL PROPERTIES // mass = 1; //Behavioural State itemObtained=false; locked=false; opening= false; }
void PreferencesDefaults::syncSettings() { auto general = SettingsObjectWrapper::instance()->general_settings; general->setDefaultFilename(ui->defaultfilename->text()); general->setDefaultCylinder(ui->default_cylinder->currentText()); general->setUseDefaultFile(ui->btnUseDefaultFile->isChecked()); if (ui->noDefaultFile->isChecked()) general->setDefaultFileBehavior(NO_DEFAULT_FILE); else if (ui->localDefaultFile->isChecked()) general->setDefaultFileBehavior(LOCAL_DEFAULT_FILE); else if (ui->cloudDefaultFile->isChecked()) general->setDefaultFileBehavior(CLOUD_DEFAULT_FILE); auto display = SettingsObjectWrapper::instance()->display_settings; display->setDivelistFont(ui->font->currentFont().toString()); display->setFontSize(ui->fontsize->value()); display->setDisplayInvalidDives(ui->displayinvalid->isChecked()); auto animation = SettingsObjectWrapper::instance()->animation_settings; animation->setAnimationSpeed(ui->velocitySlider->value()); }
void PlayerObj::MoveMe(gp2d::Sprite *blocker) { int i = 0; GLfloat xMovement; GLfloat yMovement; // If any x movement needed this frame - this is what it will be xMovement = gp2d::getMovementFactor(MOVE_VEL, myGameTimer.getTicks()); if (this->CanJump == false) // Falling / Already Jumping!!!!!!!!!!!!!!!!!!!!!!!!!!! { // Add the free fall acceleration to the velocity based on loop time GRAVITY!!! this->vY += gp2d::getMovementFactor(GRAVITY, myGameTimer.getTicks()); // Calculated the distance to move since last time round the loop yMovement = gp2d::getMovementFactor(this->vY, myGameTimer.getTicks()); this->y += yMovement; // Comment out this line if you dont want gravity to take effect //this->y += gp2d::getMovementFactor(100.0f, myGameTimer.getTicks()); //Use this line for no gravity // Test if at any point within the required distance to move if // there is a collision with an object. Most of the time this will be true if (CollisionPixel(this,blocker,0,0)) { this->CanJump = true; // made a collision -> stop moving downwards // reverse the last movement and find at what pixel // the collision happened. this->y -= this->vY; this->vY = 0; while(!CollisionPixel(this,blocker,0,0)) { // as long as there isnt a collision this->y += 1.0f; // move the player downwards 1 pixel } // Because we do have a collision now, we should move it back up 1 pix this->y -= 1.0f; } } else { if (gp2d::KeyPressed(SDLK_UP)) { // We would like to jump this->CanJump = false; this->vY = -JUMP_VEL; this->y += START_JUMP; } } if(this->CanMove==true){ // Can we move? if( (gp2d::KeyPressed(SDLK_LEFT)) || (gp2d::KeyPressed(SDLK_RIGHT))) { setAnimationSpeed(24.0f); } else { setAnimationSpeed(0.0f); } i=0; if(gp2d::KeyPressed(SDLK_LEFT)){ this->CanJump = false; this->Mirror=true; // Player looks to the left this->x -= xMovement; while(CollisionPixel(this,blocker,0,0)) { // If there is a collision this->y -= 1.0f; // Move player 1 pixel up if (++i >= 4) { // If we moved the player already 4 pixels up this->y += 4.0f; // Encountered wall, set character back this->x+=xMovement; break; } } } i=0; if(gp2d::KeyPressed(SDLK_RIGHT)){ this->CanJump = false; this->Mirror=false; // Player looks to the left this->x += xMovement; while(CollisionPixel(this,blocker,0,0)) { // If there is a collision this->y -= 1.0f; // Move player 1 pixel up if (++i >= 4) { // If we moved the player already 4 pixels up this->y += 4.0f; // Encountered wall, set character back this->x-=xMovement; break; } } } } }
void PlayerObj::MoveMe() { this->vY += 0.2f; this->y += this->vY; int i = 0; if (CollisionPixel(this,&Level[0],0,0)) { this->y -= this->vY; // touch the ground -> stop moving downwards this->vY = 0; // it could be that we are now way up in the air, becouse the velocity our dude is traveling can be rather fast while(!CollisionPixel(this,&Level[0],0,0)) { // as long as there isnt a collision this->y += 1.0f; // move the player downwards 1 pixel } // Because we do have a collision now, we should move it back up 1 pix this->y -= 1.0f; if(this->CanMove==true){ // Can we move? if(this->CanJump==true){ // Can we jump? if (Movement.jumping) { // We would like to jump // iteam::Sound[0].Play(); this->vY = -6.0f; this->y += -6.0f; } } } } if(this->CanMove==true){ // Can we move? if(Movement.walkingLeft || Movement.walkingRight) { setAnimationSpeed(24.0f); } else { setAnimationSpeed(0.0f); } i=0; if(Movement.walkingLeft){ this->Mirror=true; // Player looks to the left this->x -= 2.0f; while(CollisionPixel(this,&Level[0],0,0)) { // If there is a collision this->y -= 1.0f; // Move player 1 pixel up if (++i >= 4) { // If we moved the player already 4 pixels up this->y += 4.0f; // Encountered wall, set character back this->x+=2.0f; break; } } } i=0; if(Movement.walkingRight){ this->Mirror=false; // Player looks to the left this->x += 2.0f; while(CollisionPixel(this,&Level[0],0,0)) { // If there is a collision this->y -= 1.0f; // Move player 1 pixel up if (++i >= 4) { // If we moved the player already 4 pixels up this->y += 4.0f; // Encountered wall, set character back this->x-=2.0f; break; } } } } }