예제 #1
0
void GameState::menuMouseHandling(sf::Vector2i location)
{
	//std::cout<<location.x << "  " << location.y << "\n";
	if (button_play.checkClick(location))
	{	
		startShop();
	}
	if (button_help.checkClick(location))
	{	
		m_game_state = STATE_CONTROLS;
	}

	
	if (button_credits.checkClick(location))
	{
		startCredits();
	}
	
	if (button_quit.checkClick(location))
	{	
		//m_wnd->close();;
		std::cout << "MACH MICH ZU DU SAU!!!!" << std::endl;
	}


}
예제 #2
0
void tinapp_purchase::pre_show(CVideo& /*video*/, twindow& window)
{
	std::stringstream strstr;
	if (browse_) {
		utils::string_map symbols;
		symbols["platforms"] = tintegrate::generate_format("iOS", "green");

		tlabel* label = find_widget<tlabel>(&window, "flag", false, true);
		strstr.str("");
		strstr << "(";
		strstr << vgettext2("Only $platforms support in-app purchase", symbols);
		strstr << ")";
		label->set_label(strstr.str());
	}

	restore_ = find_widget<tbutton>(&window, "restore", false, true);
	purchase_ = find_widget<tbutton>(&window, "purchase", false, true);
	status_ = find_widget<tlabel>(&window, "status", false, true);
	list_ = find_widget<tlistbox>(&window, "item_list", false, true);

	refresh_list(true);
	list_->set_callback_value_change(dialog_callback3<tinapp_purchase, tlistbox, &tinapp_purchase::item_selected>);

	// current no non-consumable in-purchase, don't use restore
	purchase_->set_active(!browse_);
	bool no_nonconsumable = true;
	for (std::vector<tinapp_item>::const_iterator it = items_.begin(); it != items_.end(); ++ it) {
		if (!it->consumable) {
			no_nonconsumable = false;
			break;
		}
	}
	if (no_nonconsumable) {
		restore_->set_visible(twidget::INVISIBLE);
	}

	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "restore", false)
		, boost::bind(
			&tinapp_purchase::restore
			, this
			, boost::ref(window)));
	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "purchase", false)
		, boost::bind(
			&tinapp_purchase::purchase
			, this
			, boost::ref(window)));

	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "quit", false)
		, boost::bind(
			&tinapp_purchase::quit
			, this
			, boost::ref(window)));

	startShop();
}
예제 #3
0
void GameState::updateGameState()
{
	// Do nothing if the game is not in playing state
	if(m_game_state == STATE_MENU)
	{
		
		//s->setBgVolume(0);
		s->playSound(SOUND_INTRO);
	}
	else if (m_game_state == STATE_SHOP)
	{
		
		//s->playSound(SOUND_INTRO);
	}
	else if(m_game_state == STATE_PLAYING)
	{
		// Update the player location
		sf::Vector2f delta;

		switch(m_player_direction)
		{
			case DIRECTION_LEFT:
			delta = sf::Vector2f(-5,0);
			m_velocity -= gravity/(rocket.aerodynamic/10);
			break;

			case DIRECTION_RIGHT:
			delta = sf::Vector2f(5,0);
			m_velocity -= gravity/(rocket.aerodynamic/10);
			break;

			default:
			delta = sf::Vector2f(0,0);
			break;
		}
		delta.y -= m_velocity;
		
		m_velocity -= gravity;
		

		
		// Apply delta to the player position
		sf::Vector2f new_location(getPlayerLocation() + delta);

		// Check if new position is inside the game area
		if(new_location.x < 0)
		{
			new_location.x = 0;
		}
		else if(new_location.x + ROBOT_WIDTH >= m_size_x)
		{
			new_location.x = m_size_x - ROBOT_WIDTH;
		}
		setPlayerLocation(new_location); // Update location
		if(new_location.y < 0 && m_velocity < 0)
		{
			setTotalDodgecoins(total_dodgecoins + m_dodgecoins_collected);
			m_dodgecoins_collected =0;
			setPlayerLocation(sf::Vector2f(m_size_x/2-ROBOT_WIDTH/2,m_size_y/2-ROBOT_HEIGHT/2)); 		// Reset Player Location
			std::cout << "totalcoins: " << total_dodgecoins <<std::endl;
			startShop();
		}
		else if ((getPlayerLocation().y/100)*-1 >= 2500 && rocket.coolness >= 9000) // Aus Präsentationsgründen auf 500 gesetzt, normal 2000
		{
			startEnd();
		}	
		
		// Bounding box of the player
		sf::FloatRect player_box(getPlayerLocation(),sf::Vector2f(ROBOT_WIDTH,ROBOT_HEIGHT));
		
		//ADD COIN
		addDodgecoin();
		
		//add meteor
		addMeteor();
		
		std::vector<sf::Vector2f>::iterator s_it;
		s_it = m_dodgecoin_locations.begin();

		
		// Check for each coin location ...
		while(s_it != m_dodgecoin_locations.end())
		{
			// ... if the rocket is collecting the coin
			sf::FloatRect dodgecoin_box(*s_it,sf::Vector2f(COIN_WIDTH,COIN_HEIGHT));
			if(dodgecoin_box.intersects(player_box))
			{
				// Remove coin
				m_dodgecoin_locations.erase(s_it);
				m_dodgecoins_collected++;
				
			}
			else
			{
				// Advance iterator to next coin
				s_it++;
			}
		}
		
		s_it = m_meteor_locations.begin();
		
		// Check for each meteor location ...
		while(s_it != m_meteor_locations.end())
		{
			// ... if the rocket is colliding the meteor
			sf::FloatRect meteor_box(*s_it,sf::Vector2f(80,80));
			if(meteor_box.intersects(player_box))
			{
				// Remove meteor
				m_meteor_locations.erase(s_it);
				m_velocity -= 50*gravity;
			}
			else
			{
				// Advance iterator to next coin
				s_it++;
			}
		}
		
	}
	else if(m_game_state == STATE_MINI)
	{
		// Update the player location
		sf::Vector2f delta;
		
		
		switch(m_player_direction)
		{
			case DIRECTION_LEFT:
			delta = sf::Vector2f(-5,0);
			break;
			//std::cout << "leftmini" <<std::endl;
			
			case DIRECTION_RIGHT:
			delta = sf::Vector2f(5,0);
			break;
			//std::cout << "rightmini" <<std::endl;

			case DIRECTION_UP:
			delta = sf::Vector2f(0,0);
			break;

			case DIRECTION_DOWN:
			delta = sf::Vector2f(0,0);
			break;

			default:
			delta = sf::Vector2f(0,0);
			break;
		}
		
		// Apply delta to the player position
		sf::Vector2f new_location(getPlayerLocation() + delta);

		// Check if new position is inside the game area
		if(new_location.x >= 0 && new_location.x + ROBOT_WIDTH <= m_size_x)
		{
			setPlayerLocation(new_location); // Update location
			//std::cout << "neue position??" << std::endl;
		}
		if(new_location.x >=1200)
		{
			setTotalDodgecoins(total_dodgecoins + m_dodgecoins_collected);
			m_dodgecoins_collected =0;
			startShop();
		}	
		
		// Bounding box of the player
		sf::FloatRect player_box(getPlayerLocation(),sf::Vector2f(ROBOT_WIDTH,ROBOT_HEIGHT));
		
		std::vector<sf::Vector2f>::iterator s_it;
		s_it = m_dodgecoin_locations.begin();

		
		// Check for each coin location ...
		while(s_it != m_dodgecoin_locations.end())
		{
			// ... if the nils is collecting the coin
			sf::FloatRect dodgecoin_box(*s_it,sf::Vector2f(COIN_WIDTH,COIN_HEIGHT));
			if(dodgecoin_box.intersects(player_box))
			{
				// Remove coin
				m_dodgecoin_locations.erase(s_it);
				m_dodgecoins_collected++;
				//std::cout << "coooooooooooooiiiiin" << std::endl;
				//setTotalDodgecoins(total_dodgecoins + m_dodgecoins_collected);
				std::cout << "totalcoins: " << total_dodgecoins <<std::endl;
				std::cout << "collectedcoins: " << m_dodgecoins_collected <<std::endl;
				
			}
			else
			{
				// Advance iterator to next coin
				s_it++;
			}
		}
	}		
	
	else if(m_game_state == STATE_CREDITS)
	{
	}	
	else if (m_game_state == STATE_END)
	{
	}
	else // Do nothing if the game is not in mini state
	{		
		return;
	}
	//startEnd();
	
}