Ejemplo n.º 1
0
//Climbing
void ce_player::climbUp(){

	//Setup climbing
	if (!isClimbingUp){
		isClimbing = true;
		isWalkingRight = false;
		isWalkingLeft = false;
		isClimbingUp = true;
		isClimbingDown = false;
		
		//Setup and start animation sequence
		stopAnimating();
		frame.size.height = 72;
		frame_y = 384;
		frame_sequence.clear();
		frame_sequence.push_back(0);
		frame_sequence.push_back(1);
		frame_sequence.push_back(2);
		frame_sequence.push_back(1);
		startAnimating();

		//Snap to grid
		frame.cord.x = actorTouching(cet_ladder)->frame.cord.x;
	}

	//Climb
	moveUp(player_speed);
}
Ejemplo n.º 2
0
void ce_player::walkRight(){

	//Start walking
	if (!isWalkingRight){
		isClimbing = false;
		isWalkingRight = true;
		isWalkingLeft = false;
		isClimbingUp = false;
		isClimbingDown = false;
		
		//Setup and start animation sequence
		stopAnimating();
		frame.size.height = 64;
		frame_y = 0;
		frame_sequence.clear();
		frame_sequence.push_back(0);
		frame_sequence.push_back(1);
		frame_sequence.push_back(0);
		frame_sequence.push_back(2);
		startAnimating();
	}

	//Walk
	moveRight(player_speed);
}
Ejemplo n.º 3
0
void Player::reset()
{
    stopAnimating();
    m_PathFinder->reset();
    m_DestinationTile = NULL;
    m_Health = 10;
    setIsActive(true);


}
Ejemplo n.º 4
0
void Layer::removeAnimation(const string& key)
{
  auto pos = animations.find(key);
  if(pos != animations.end())
  {
    animations.erase(pos);
    if(animations.size() == 0)
    {
      stopAnimating();
    }
  }
}
Ejemplo n.º 5
0
void JetpackUI::switch_contexts(Fl_Group *display) {
	if (display == m_load_group) {
		stopAnimating();
		m_menubar_editor->hide();
		m_menubar_gamePlay->hide();
		m_loader->update("test.level");
		m_gamePlay_group->hide();
		m_editor_group->hide();
		m_save_group->hide();
		m_load_group->show();
	} else if (display == m_save_group) {
		stopAnimating();
		m_menubar_editor->hide();
		m_menubar_gamePlay->hide();
		m_saver->update("test.level");
		m_gamePlay_group->hide();
		m_editor_group->hide();
		m_save_group->show();
		m_load_group->hide();
	} else if (display == m_editor_group) {
		m_current = m_editor;
		m_menubar_editor->show();
		m_menubar_gamePlay->hide();
		m_gamePlay_group->hide();
		m_editor_group->show();
		m_save_group->hide();
		m_load_group->hide();
		startAnimating();
	} else if (display == m_gamePlay_group) {
		m_current = m_gamePlay;
		m_menubar_editor->hide();
		m_menubar_gamePlay->show();
		m_gamePlay_group->show();
		m_editor_group->hide();
		m_save_group->hide();
		m_load_group->hide();
		startAnimating();
	}
}
Ejemplo n.º 6
0
void ce_player::climbDown(){
	
	//Start climbing
	if (!isClimbingDown){
		isClimbing = true;
		isWalkingRight = false;
		isWalkingLeft = false;
		isClimbingUp = false;
		isClimbingDown = true;
		
		//Setup and start animation sequence
		stopAnimating();
		frame.size.height = 72;
		frame_y = 384;
		frame_sequence.clear();
		frame_sequence.push_back(0);
		frame_sequence.push_back(1);
		frame_sequence.push_back(2);
		frame_sequence.push_back(1);
		startAnimating();

		//Snap to grid
		frame.cord.x = actorTouching(cet_ladder)->frame.cord.x;
	}

	//Stop climbing if player has hit the floor
	if (isTouching(cet_wall)){
		isClimbingDown = false;
		isClimbing = false;
		stopAnimating();
		return;
	}

	//Climb
	moveDown(player_speed);
}
Ejemplo n.º 7
0
void Player::update(double aDelta)
{
    std::string ammoCount = "";
    std::stringstream ammoAmount;
    ammoAmount << m_Ammo;
    ammoAmount >> ammoCount;
    m_Font->setText(ammoCount.c_str());


    //update the projectile
    for(int i = 0; i < m_Projectiles.size(); i++)
    {
        if(m_Projectiles.at(i)->getIsActive() == true)
        {
            m_Projectiles.at(i)->update(aDelta);

        }
    }
    //Tower1
    for(int i = 0; i < m_Level->getNumberOfTiles(); i++)
    {
        if(m_Level->getTileTypeForIndex(i) == TileTypeTower)
        {
            TowerTile* temp = (TowerTile*) m_Level->getTileForIndex(i);
            for(int location = 0; location < temp->getProjecticle().size(); location++)
            {
                if (temp->getProjecticle().at(location)->getIsActive())
                    temp->getProjecticle().at(location)->update(aDelta);
            }
        }
    }
    //remove aby inactive projectiles from the projectiles vectors
    int index = 0;
    while(index != m_Projectiles.size())
    {
        if(m_Projectiles.at(index)->getIsActive() == false)
        {

            //delete the projectile and remove it from the vector
            delete m_Projectiles.at(index);
            m_Projectiles.erase(m_Projectiles.begin() + index);
        }
        else
        {
            index++;
        }
    }

    if (m_PathFinder->isSearchingPath() == true)
    {
        m_PathFinder->update(aDelta);
    }

    if (isAnimating() && m_AnimationPathNodeIndex > -1)
    {
        PathNode* pathNode = m_PathFinder->getPathNodeAtIndex(m_AnimationPathNodeIndex);
        Tile* tile = pathNode != NULL ? pathNode->getTile() : NULL;

        if(tile)
        {
            float centerX = tile->getX() + (tile->getWidth() - getWidth()) / 2.0f;
            float centerY = tile->getY() + (tile->getHeight() - getHeight()) / 2.0f;
            Tile * playerTile = m_Level->getTileForPosition(getX(), getY());
            float speed = playerTile->getTileSpeed();

            float playerX = animate(getX(), centerX, aDelta, speed);
            float playerY = animate(getY(), centerY, aDelta, speed);
            setPosition(playerX, playerY);

            //change G as float for slower and faster tiles

            if (playerX == centerX && playerY == centerY)
            {
                m_AnimationPathNodeIndex++;
                m_CurrentTile->setIsPath(false);
                setCurrentTile(tile);
                if (m_AnimationPathNodeIndex >= m_PathFinder->getPathSize())
                {
                    stopAnimating();
                    m_CurrentTile->setIsPath(false);
                }

                if(m_AbortAnimation)
                {
                    m_AbortAnimation = false;

                    findPath();
                }
            }
            else
            {
                if(m_AbortAnimation == true)
                {
                    m_AbortAnimation =false;
                    findPath();
                }
            }
        }

    }
}
Ejemplo n.º 8
0
void Layer::removeAllAnimations()
{
  animations.clear();
  stopAnimating();
}